Vulnhub靶机:DC-2

标签WordPressrbash爆破git提权

0x00 环境准备

下载地址:https://www.vulnhub.com/entry/dc-2,311/
flag数量:5
攻击机:kali
攻击机地址:192.168.1.22
靶机描述:

Much like DC-1, DC-2 is another purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.

As with the original DC-1, it's designed with beginners in mind.

Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.

Just like with DC-1, there are five flags including the final flag.

And again, just like with DC-1, the flags are important for beginners, but not so important for those who have experience.

In short, the only flag that really counts, is the final flag.

For beginners, Google is your friend. Well, apart from all the privacy concerns etc etc.

I haven't explored all the ways to achieve root, as I scrapped the previous version I had been working on, and started completely fresh apart from the base OS install.

0x01 信息搜集

1.探测靶机地址

命令:arp-scan -l

靶机地址是192.168.1.23

2.探测靶机开放端口

命令:nmap -sV -p- 192.168.1.23

有个80端口,有个SSH服务,那就先看一下80上的服务。

0x02 flag1

打开浏览器访问192.168.1.23,发现是wordpress CMS

看到了flag,打开发现了flag1

我看其他表哥做的时候不能直接访问靶机的80端口,要修改host文件,但是我这个直接就能访问了。
说一下修改kali host文件的方法吧,命令:vim /etc/hosts,按i键切换到插入模式,添加下图的语句,IP地址是你的靶机地址,然后按esc键,输入:wq就好了。

0x03 flag2

看一下flag1的提示

Flag 1:

Your usual wordlists probably won’t work, so instead, maybe you just need to be cewl.

More passwords is always better, but sometimes you just can’t win them all.

Log in as one to see the next flag.

If you can’t find it, log in as another.

大概意思是说要用cewl工具,登录后会看到下一个flag。
cewl是一个密码字典生成工具,它可以根据爬取的url来生成特定的密码字典。

命令:cewl -w /root/cewl/dc2_passwd.txt http://dc-2/

现在有了密码字典,但是还不知道用户名,kali自带了一个wpscan工具,它可以查询出wordpress的用户名。命令:wpscan --url http://dc-2/ -e u

-e u是枚举用户名,默认从1-10

这里枚举出了3个用户名,现在有了用户名,有了密码字典,只要找到登录链接就可以了。先去网上查一下默认的登录地址:

也可以使用dirb去扫目录,命令:dirb http://dc-2/

找到登录链接后,现在开始爆破,为了方便,先把刚才扫描到的3个用户名存到一个txt文件里当做用户名字典。

爆破使用wpscan,命令:wpscan --url http://dc-2 -U /root/cewl/dc2_user.txt -P /root/cewl/dc2_passwd.txt

在枚举处的三个用户名中,爆破出了2个,分别是:jerry / adipiscingtom / parturient
登录jerry账号,发现了flag2

提示:

Flag 2:

If you can't exploit WordPress and take a shortcut, there is another way.

Hope you found another entry point.

大概意思是不要走wordpress的捷径,换一个切入点。

0x04 flag3

刚才扫描的时候还发现了SSH服务,那就尝试用刚才爆破出的账号登录SSH。
jerry不能登录,tom可以

ls查看当前目录,发现了flag3.txtcat查看,不能执行

看了一下表哥的文章,原因是我们的shell是rbash,所以 shell 被限制了。

受限shell是LinuxShell限制一些bash shell中的功能,并且是从名字上很清楚。 该限制很好地实现了命令以及脚本在受限shell中运行。 它为Linux中的bash shell提供了一个额外的安全层。

我是第一次遇到,所以用表哥的方法绕过一下,先查看环境变量:echo $PATH,发现被写到了/home/tom/usr/bin下面,用vi转义受限制的shell:

vi
:set shell=/bin/bash
:shell

然后再设置一下环境变量:

export PATH=/bin:/usr/bin:$PATH
export SHELL=/bin/bash:$SHELL

这个时候就可以执行命令了

Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.

翻译成中文:可怜的老汤姆总是在追求杰瑞。也许他应该为他所造成的压力而道歉。一脸懵逼,看一下表哥怎么做的。

0x05 flag4

原来是要切换到jerry用户,使用su jerry进行切换,但是当我输入密码的时候,只输入一个字符它就会自动回车,最后没办法,我只好把密码复制到剪切板上,输入密码时直接粘贴上去,密码就是上面爆破出来的密码,终于进去了。

ls查看当前目录,报错了,那就cd /home/jerry/切换到jerry的目录,ls看到了flag4.txt

Good to see that you've made it this far - but you're not home yet. 

You still need to get the final flag (the only flag that really counts!!!).  

No hints here - you're on your own now.  :-)

Go on - git outta here!!!!

大概意思是:很高兴看到你已经走了这么远,但你还没有到家。您仍然需要获得最后的标志(惟一真正有意义的标志!!)。这里没有提示——你现在只能靠自己了。

0x06 flag5

看提示应该是要我们用git提权,这又到了我的知识盲区了,去网上查一下吧,发现了一个用git提权的方法。

动手尝试一下,命令:sudo git help config,然后输入!/bin/bash,保存退出

提权成功了,ls发现了flag文件


截止到现在5个flag就全部找到了。

由于我不会每天都登录,所以有什么私信或者评论我都不能及时回复,如果想要联系我最好给我发邮件,邮箱:Z2djMjUxMTBAMTYzLmNvbQ==,如果发邮件请备注“”

你可能感兴趣的:(Vulnhub靶机:DC-2)