Skip to content

Instantly share code, notes, and snippets.

@karmanyaahm
Last active July 31, 2020 19:43
Show Gist options
  • Save karmanyaahm/d4090b3773a7b880e8150ba9d3f462f4 to your computer and use it in GitHub Desktop.
Save karmanyaahm/d4090b3773a7b880e8150ba9d3f462f4 to your computer and use it in GitHub Desktop.
Hacktivitycon CTF Tootsie Pop
#it stops once because of python recursion limits but can be manually restarted
#it extracts files and then moves them to one directory so the filename doesn't get too long(which is not supported in some tools like bzip)
from xtract import xtract
import os
import glob
# def names():
def delempty(dirr):
for i in [f[0] for f in os.walk(dirr) if os.path.isdir(f[0])]:
try:
os.rmdir(i)
except OSError:
pass
def ext(inp):
delempty('.')
for i in inp:
if i =="pop.zip":
try: xtract('pop.zip')
except: pass
out='pop'
else:
out = xtract(i)
if i != "pop.zip":
os.remove(i)
if os.path.isdir(out):
th = [
i for i in glob.glob(out + "/**", recursive=True) if os.path.isfile(i)
]
ext(th)
else:
os.rename(out, "pop/" + os.path.basename(out))
ext(["pop/" + os.path.basename(out)])
ext(["pop.zip"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment