0x00.前言

0x01.信息收集

nmap -sC -sV 10.10.10.6
nmap -p- -min-rate 1000 10.10.10.6
image-20220611020341629

0x02.文件上传拿低权限shell

80端口在工作,如下:

image-20220611020703473

扫目录,如下:

feroxbuster -u http://10.10.10.6/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt
image-20220611020737602

进入/torrent,

image-20220611020927083

找到历史漏洞,如下:

image-20220611020959246

有一个文件上传漏洞,描述如下:

image-20220611021616421

需要先注册一个用户(admin123/admin123),如下:

image-20220611021241126

然后用其提供的文件上传功能,上传一个torrent后缀的文件,

image-20220611022102687

接着浏览这个文件的详细页面,点击Edit this torrent后会弹出一个页面,在其中允许上传Screenshot,也就是一张图片,如下:

image-20220611023316026

但在这里可以绕过,服务端检测文件类型的方式仅通过Content-Type字段来确定,只要上传文件时将字段内容修改为image/png即可绕过过滤,如下:

image-20220611023222388

上传后点击访问图片即可在本地收到一个反弹shell,如下:

image-20220611023721405

0x03.内核提权

先获取一个tty,

python2 -c 'import pty;pty.spawn("/bin/bash")'

查看内核版本,如下:

image-20220611024053303

可以使用脏牛提权,本地起一个http服务器将exp传到目标机器的/tmp上,然后编译并给运行权限,

gcc -pthread 40839.c -o 40839exp -lcrypt
chmod +x 40839exp
./40839exp
image-20220611025105061

修改好root密码后,用su切换到用户firefart(利用完成后root用户名被替换为了firefart),如下:

image-20220611025420217

0x04.总结

中规中矩的一台机器。

参考文章:

https://medium.com/@fularam.prajapati/hack-the-box-popcorn-walkthrough-writeup-oscp-60dda6e326b2

https://infosecwriteups.com/hackthebox-popcorn-f1ace3de846d

image-20220531130238760