CREDS >>

TryHackMe – https://tryhackme.com/p/TheSysRat

HackTheBox (aka TheSysRat)

Discovery >

nmap >

FTP look interesting, let’s check >

21/FTP >

We can found file “update.txt” and there is message >

So we have first hint ! Location where is a pass.txt. Let’s continue >

80/HTTP>

Dirseacrh >

And there is some interesting files, we can inspect >

index.php >

/blog.php >

We need account to add any comment, let’s try to register >

Register works! After that we can login >

After login we can add and delete our comments.

So how to get local file? We can try some magics >

  • Special HTTP Headers,
  • Find LFI,
  • Find XSS,
  • Or something else 😀 …

First try to acces our /dir/pass.txt directly >

And it is Forbidden !

Let’s try Special HTTP Headers >

https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/special-http-headers

Our request >

And we can apply Intruder to check it >

Payload is copy from hacktricks >

But no luck, not work!

Let’s try LFI >

No luck too >

So we can try XSS >

First try no success >

But we can try other way , we can try add our script to registration >

After login and add some text and click to submit we have can found XSS!!

So we can try to read our pass.txt file over XSS vuln.

https://book.hacktricks.xyz/pentesting-web/xss-cross-site-scripting#steal-page-content

XSS > pass.txt > USER

Prepare >

We need prepare our stealer script like this>

Now in location our stealer.js script we need to run python http.server on port 8000>


Exploitation >

We need new registration and our payload will be like >

After add new comment we can get this, base64 encrypted content of file >

After decrypt we can found credentials to login on SSH >

NOTE: It take some time to send content of file. Sometime if you try many XSS ways, it didn’t work, So try to reset machine …

But we are in! User is DONE!


Root Path >>>

Research >>

We can found sudo -l >

GTFObins no luck, there we need found other way, let’s try linpeas.sh >

There is not too much, but some interesting files we can found in /opt >

Let’s look on it >

So we have to inspect .pcap file in wireshark >

But communication is encrypted! So we can try to find decrypt key >

And we can found it, let’s download and import to Wireshark >

Go to Edit >> Preferences >> Protocols >> TLS >>Import RSA

For port w can try filtered port 41312 in the beginning >

And now we can read communication, so let’s filter to HTTP >>

And there is something look like web shell !

And now we have probably way to backdoor :

  • Allow port 41312 in iptables
  • Try connect to backdoor
  • Get ROOT ?

Let’s try >>

sudo /usr/sbin/iptables >>

Run OK, we need to check it on server >

Look good and now check from outside >

Great!!

use backdoor >>

So we can try web shell if works >

And we can try get a reverse shell >

And we are IN >>

So we can look for some possibilities to get ROOT account >

And first try is success, so we can try >

AND we are ROOT !! Machine was completely PWNed !!

Happy Hacking and see you next time ! 😉

Leave a Reply

Your email address will not be published. Required fields are marked *