This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
24 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
''' | ||
@author Mudasir | ||
some util functions to generate flag and copy it to video | ||
some util function(s) to generate flag and copy it to video | ||
''' | ||
|
||
from PIL import Image, ImageDraw, ImageFont | ||
import io | ||
|
||
FLAG = 'camp{wH@7s_an_3xTr@_f!l3_aNYw@y$_r3dhi8ib28bf}' | ||
|
||
def generate_flag(): | ||
final_bytes = io.BytesIO() | ||
img = Image.new('RGB', (600, 100), color = (0, 0, 0)) | ||
d = ImageDraw.Draw(img) | ||
fnt = ImageFont.truetype('arial.ttf', 20) | ||
d.text((40,30), FLAG, font=fnt, fill=(255,255,255)) | ||
img.save('flag.png') | ||
# img.save('flag.png') | ||
img.save(final_bytes, format='PNG') | ||
final_bytes = final_bytes.getvalue() | ||
|
||
def copy_img_to_video(): | ||
with open('flag.png', 'rb') as f: | ||
flag = f.read() | ||
with open('funnyfile', '+ab') as f2: | ||
f2.write(flag) | ||
with open('funfile', '+ab') as f2: | ||
f2.write(final_bytes) | ||
|
||
generate_flag() | ||
copy_img_to_video() | ||
generate_flag() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# File headers | ||
|
||
Hint in the name: headers. Despite the lack of a file extension we can check the file header / magic number See: (https://en.wikipedia.org/wiki/List_of_file_signatures)[https://en.wikipedia.org/wiki/List_of_file_signatures] for more information on file headers. | ||
|
||
Opening the file in a text and/or hex editor shows us that we have an mp4 file. However, the video does not open in a media player. Further examination would show that the file has a PNG glued on to it. Separating the files shows us that the video is a red herring, and the PNG has the flag. | ||
|
||
|
||
Script is included at (solve.py)[solve.py], run in the same directory as the file. It creates (solve.png)[solve.png] with the flag. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
with open('funfile','rb') as f: | ||
data = f.read().split(b"\x89PNG") | ||
with open('solve.png','wb') as f2: | ||
f2.write(b"\x89PNG") | ||
f2.write(data[1]) | ||
print('Done') |