Stocker
Enumeration
Rustscan
mkdir rust; sudo rustscan -t 1500 -b 1500 --ulimit 65000 -a 10.129.131.220 -- -sV -sC -oA ./rust/{{ip}}Ports
Open 10.129.131.220:22
Open 10.129.131.220:80Services
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp open http syn-ack ttl 63 nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://stocker.htb
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: nginx/1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelSubdomains
Dirsearch
stocker.htb
dev.stocker.htb
Website
Visiting http://stocker.htb we can see that it is just a plain simple html page without anything that indicates an attack vector
When checking http://dev.stocker.htb](http://devstocker.htb) we are getting redirected to a login page
Exploitation
NoSQL Auth Bypass
After trying different things for a while I discovered that the login is vulnerable to NoSQL Authentication Bypass.
Burp: POST-Request
Server Side XSS (PDF)
While checking the page-source of http://dev.stocker.htb/stock we see a function that looks interesting.
Using JSON.stringify can cause XSS vulnerabilites. Maybe we should check that out. We'll abuse one of those snippets from Hacktricks - Server Side XSS (Dynamic PDF)
Read /etc/passwd
Burp: Request
Burp: Result
We can use the orderID to open http://dev.stocker.htb/api/po/63c59bab9a4ca468a539a9f4 which will render the PDF and includes our /etc/passwd content.
Finding
Read /var/www/dev/index.js
Burp: Request
Burp: Response
We can use the orderID to open http://dev.stocker.htb/api/po/63c59f799a4ca468a539aa26 which will render the PDF and includes the source code of /var/www/dev/index.js.
Finding
SSH Access
Using the user we identified by reading /etc/passwd and the password found in /var/www/dev/index.js we are able to ssh into the machine.
Escalation
Enumeration
Seems like we are allowed to run any script ending with .js located in /usr/local/scripts/ as root.
Become Root
We'll abuse the sudo permissions as there's no check for directory traverseral to change the permissions of /bin/bash.
perm.js
Change Perms
Escalate
Last updated