tl;dr
- Part-1: .bzr file retrival using any tool
- Part-1: exploiting ssrf via ffmpeg to read /flag file to a video and download it before it gets deleted
Challenge Author: Captain-Kay
Source: here
In this challenge the players are welcomed with a harmless looking index.php page
which has only 1 textbox and some text saying ENTER THE SUPER SECRET KEY
The First Step is to find the hidden .bzr
(Use anything like dirb gobuster dirbuster) folder and a quick google will reveal to you that
.bzr is basically a open source version control system. Basically its somewhat the same as .git
After Finding .bzr the next step would be to retrive the source code. But i couldnt find any tools to do it so u might have to manually get it
steps to follow to get source code
1 | 1. Install bzr on your system |
So Now you have a bzr repository with the .bzr directory
Next
1 | 9. cd .bzr/branch |
Basically we are getting and replacing our last-revision
with the one on the server
We follow the same steps for dirstate
and pack-names
1 | 12. cd ../checkout |
So now we have all the important files which point to the commit history
Next we do a bzr check
which will spit out all the name of the missing files
then simply wget them to the approprite folder
1 | cd .bzr/repository/indces/ |
Then dobzr status
and bzr revert
And you will have the source files of the challenge
After Getting the source files you can get the
{SUPER SECRET PASSWORD
==>THIS_IS_THE_NEW_WAY_TO_DO_STUFF
}
Now To the Second Part of the challenge
In the source code we see its using ffmpeg to convert the videos,
and it has ALLOW-EXTENTIONS set to all,
And if you research a bit more u will find that ffmpeg has the ability/bug that it converts txt files to video files too.
Now we need to know how HLS playlist is handled
1 | 1. When processing a playlist, ffmpeg links all the segment contents together and processes them as a separate file |
So basically
1 | EXTM3U |
Ffmpeg sees the
EXTM3U
tag in the GAB2 subtitle block, and confirms that the file type is HLS playlist.
Now even though the file God.txt doesnt exist name is enough for ffmpeg to detect the file type as TXT
Ffmpeg links the contents of all segments of the playlist together, because only the file / etc / passwd actually exists, so the final content is the content of the / etc / passwd file
Because the file type is TXT, ffmpeg draws a terminal to print the file.
Now file:// is blacklisted in the source code No problem
we can just direclty do /etc/passwd
So now we have file read on the system
how do we retrive the file
if you see there is a sleep statement before the deletion of the files
and the file names are always the same (md5 of the given filename)
So we can easily execute a race condition to download the file before it gets deleted
FINAL PAYLOAD FOR SECOND PART
1 | #EXTM3U |
Paste into a file with .mp4 extention (any extention will do)
convert to something
Race to download the file and read the flag
and Race condition
1 | while 1 |
HOPE YOU ENJOYED IT :)
REFERENCES USE TO MAKE CHALLENGE
https://ctftime.org/writeup/13380
https://www.blackhat.com/docs/us-16/materials/us-16-Ermishkin-Viral-Video-Exploiting-Ssrf-In-Video-Converters.pdf
https://developpaper.com/analysis-of-ffmpeg-arbitrary-file-reading-vulnerability/