Skip to content

Instantly share code, notes, and snippets.

@streanger
Last active February 16, 2020 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save streanger/42a319e99559b5dfdbc53b492a277d7d to your computer and use it in GitHub Desktop.
Save streanger/42a319e99559b5dfdbc53b492a277d7d to your computer and use it in GitHub Desktop.
deep_dive_writeup
import sys
import os
import subprocess
def write_bin(file, data):
with open(file, 'wb') as f:
f.write(data)
f.close()
return True
def unzip_file(file):
'''require 7z installed
https://www.7-zip.org/download.html
'''
sevenz_path = r'D:\PATH\7z\7-Zip\7z.exe'
out = subprocess.check_output([sevenz_path, "x", "-y", "-so", file])
return out
if __name__ == "__main__":
os.chdir(os.path.realpath(os.path.dirname(sys.argv[0])))
file = "flag.txt"
key = 0
while True:
try:
out = unzip_file(file)
file_size_kb = sys.getsizeof(out)//1024
file = 'flag.zip'
print('{:003}. size: {:003} [kb]'.format(key, file_size_kb), end='\r', flush=True)
write_bin(file, out)
key += 1
except:
break
flag = open(file, 'r').read()
print(flag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment