Last active
July 31, 2020 19:43
-
-
Save karmanyaahm/d4090b3773a7b880e8150ba9d3f462f4 to your computer and use it in GitHub Desktop.
Hacktivitycon CTF Tootsie Pop
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
#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