description: M0th3r > Quelque chose me perturbe. Comment un Androïde a pu passer le test des pirates cybernétique. Duke le premier de son genre n’a été crée par personne du gouvernement. Aujourd’hui disparu je veux retrouver son core. Si tu veux m’aider, tu dois passer le test des pirate Cybernétique. C’est le test que Duke-083 a passé haut la main. Récupère tout ce que tu sais sur Zedcorp.
category: Web
Two endpoints were given for this challenge http = ctf.hacklab-esgi.org:5008 and ssh = ctf.hacklab-esgi.org:5007. On the web interface we find a robots.txt with the following entries:
Web Access
From there we can access the http://ctf.hacklab-esgi.org:5008/logs/ folder.
In these logs we find some credentials for the website/
These credentials worked on the login page.
After beeing logged as admin we can query access.log and error.log with a parameter log
Fiddling with it we can access some files, but they are truncated … The content of ../../../../../../../proc/self/environ gives us the current working directory
From there we can grab the content of the admin page with ../../../../../../../var/www/html/0cc175b9c0f1b6a831c399e269772661/admin.php. The website appears to filter some characters but we can use -n 10000 to force a longer output, turning this arbitratry read into command execution.
Shell Access
Let’s stick to the file read for the moment, we can read the /etc/passwd.
So there are two users trobin and test, what have they done recently ? Grabbing the .bash_history will tell us.
Nice, now we know there is a RSA key inside the .ssh/id_rsa, I lost some time looking for it inside the home of trobin. We can find it located at ../../../home/test/.ssh/id_rsa.
Real Shell
Unfortunately we are limited via SSH because of the /usr/sbin/nologin. At least we can initiate a SOCK proxy with ssh test@ctf.hacklab-esgi.org -p 5007 -i privkey -ND 9050 (Don’t forget to put the good permissions on the private key : chmod 600 privkey).
One logged we can start a bind shell with the following command.
And we can connect to the shell using proxychains to go through our SOCKS proxy.
Now we are not restricted for our commands, let’s inspect the network, the process and dig deeper inside the challenge.
So there are 3 machines : dev-server(the powned one), project-server and admin-server. Running an nmap gave us some interesting ports.
We target the port 8080 of 10.0.0.2, which was running a Apache Tomcat/7.0.81, based on that we checked CVEs and exploited CVE-2017-12617
CVE-2017-12617
Basically, CVE-2017-12617 is a Tomcat RCE via JSP Upload Bypass. The follow curl will create a page test.jsp with the content <% out.println(1 + 2); %>.
Again I lost some time because the exploit or the server is quite unstable there, if you have an error “500” just force refresh the page several times until you get an HTTP 200 result. The following Burp request will upload a CMD shell.
Here we are, with our first shell on project-server. Commands can be executed via http://10.0.0.2:8080/123456.jsp?cmd=id. It is time to dig into the box and look for sensitive data such as passwords.
Multiple users were created for this challenge but only one was interesting, once again we looked inside .bash_history and found the credential for the FTP of admin-server
Admin-Server
We can connect to the FTP admin with user=backup and pass=46t5r2e5t&2z!. Grabbing credentials.tar.gz, decrypting and extracting the archive iss trivial with the password pass:daniel2019`.
These credentials are useful to access the web interface on admin-server. A quick test is proxychains curl http://admin:zedc0rp2019\!@10.0.0.3 > index.html
If we log into the service with ceo without a password we get denied with the message ERROR: CEO session is currently deactivated for maintenance. Trying the others users revealed a status cookie.
user: status=dXNlcg== base64(user)
admin: status=YWRtaW4= base64(admin)
We can edit our cookie to be base64(ceo) and we get access to the following files.
The content of Rizone.pdf contains the flag : ESGI{W3_H0p3_t0_S33_y0u_N3xT_Y34R:)}
description: Kubor > Pssst Petit. Je t’ai contacté il y’a quelque jours pour resoudre cette enigme. Elle est beaucoup trop difficile pour moi !! Aide moi !!
category: Stegano
A .txt file was provided for this challenge, it was some 0 and 1.
At first sight it seems to be a QRcode transposed into binary visualization.
Version 1
The first attempt was to replace “0” by “⬛” (Large Black Square Unicode), and “1” by “⬜” (Large White Square Unicode) inside my text editor. The result looked like this, but it wasn’t enough to scan the QR code with my Android.
The next step, was to improve the QR code, we loaded it into Microsoft Paint an resize it to create a squared picture. Then we shrinked it, and we can scan the code with success.
Version 2
The previous version was working but unsatifying, I went back into the original idea of replacing characters.
description: Pas mal pour un Skid. Bah qu’est ce que tu attends, tu as son IP, son port. Alors go ! Rejoins M0th3r !
category: Forensic
The challenge was available at ctf.hacklab-esgi.org on port 8083. We can use netcat to connect to the service, it is asking for an host and a port. We supposed it would try to connect back or at least pung back. I put my VPS IP and the port 4242.
As expected we got a connect back from the challenge, revealing a sensitive data about it. The DeadEnd challenge is using Paramiko, a python library to interact with ssh. We set up a honeypot called sshesame from https://github.com/jaksi/sshesame.
We force sshesame to listen on port 22, and we wait for the connect back, if everything is working correctly we may get some credentials.
Here we see the credentials, and after connected it try to write the flag inside the /tmp/flag.
I’ve created a dastardly chain of zip files. Now you’ll never find my flag!
The first file is begin.zip, with password coolkarni.
Based on the instruction we can unzip begin.zip with coolkarni and we have the following files:
filename.txt : name of the next zip file
hash.txt
pattern.txt : pattern of the password for the next file.
The goal is quite clear, we have to unzip all the file and bruteforce the password based on the pattern.
The pattern wasn’t very understandable , at first I thought you had to guess the “_” when it fact this character was a part of the password.
Hint: You need to guess the password of the next zip file. However, the underscores in the pattern appear in the same positions as they do in the actual password, so you don’t need to guess them. For example, the first pattern is _0_0, which means that you need to guess the 3rd and 5th characters.
With this hint we can start cracking the passwords. Let’s start by generating our wordlist with mp64.
mp64 uses the following masks in order to generate a custom wordlist:
?l = abcdefghijklmnopqrstuvwxyz
?u = ABCDEFGHIJKLMNOPQRSTUVWXYZ
?d = 0123456789
?s = !"#$%&'()*+,-./:;<=>?@[\]^_{|}~
?a = ?l?u?d?s
?b = 0x00 - 0xff
With theses masks in mind we can parse the pattern to match our expectations, and then give the wordlists to fcrackzip
The final script took around 10min to find the passwords and extracts the 100 zip files.
Mind looking at this malware dropper I found?
Note: this isn’t actually malware, it just borrows obfuscation techniques from low quality malware.
Using PEiD we identified it was a .NET Binary, let’s use Reflector or another decompiler to inspect the C# code:
It seems the binary is loading itself and split into 3 parts which can be extracted with the following script:
Here we are with :
a binary which do the splitting
an another PE
some encrypted text
Once again we run Reflector on the second PE to discover what it does.
It appears the string was only “gzipped” after extracting it we have another .NET PE..
With the source code I recompiled it online using ideone, the output was the flag :D