Created
September 24, 2021 10:38
-
-
Save Reelix/cd517fc69ae98f0ba40d400020eccf28 to your computer and use it in GitHub Desktop.
Badly Coded Multi Extract Solver For CTF Challenges
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
#!/bin/python3 | |
import os, sys | |
# Argument | |
file = sys.argv[1] | |
print("Processing " + file) | |
filetype = os.popen('file ' + file).read() | |
print("Type: " + filetype) | |
if (file + ": Zip archive data" in filetype): | |
print("Zip file detected") | |
if (not file.endswith(".zip")): | |
os.system("mv " + file + " " + file + ".zip") | |
file = file + ".zip" | |
os.system("unzip " + file) | |
os.system("rm " + file) | |
elif (file + ": Microsoft Cabinet archive data" in filetype): | |
print("Cab file detected") | |
if (not file.endswith(".cab")): | |
os.system("mv " + file + " " + file + ".cab") | |
file = file + ".cab" | |
os.system("cabextract -d . " + file) | |
os.system("rm " + file) | |
elif (file + ": bzip2 compressed data" in filetype): | |
print("bzip2 file detected") | |
if (not file.endswith(".bzip2")): | |
os.system("mv " + file + " " + file + ".bz2") | |
file = file + ".bz2" | |
os.system("bzip2 -d " + file) | |
elif (file + ": ARC archive data" in filetype): | |
print("ARC file detected") | |
if (not file.endswith(".arc")): | |
os.system("mv " + file + " " + file + ".arc") | |
file = file + ".arc" | |
os.system("nomarch " + file) | |
os.system("rm " + file) | |
elif (file + ": XZ compressed data" in filetype): | |
print("XZ file detected") | |
if (not file.endswith(".xz")): | |
os.system("mv " + file + " " + file + ".xz") | |
file = file + ".xz" | |
os.system("xz -d " + file) | |
elif (file + ": 7-zip archive data" in filetype): | |
print("7z file detected") | |
if (not file.endswith(".7z")): | |
os.system("mv " + file + " " + file + ".7z") | |
file = file + ".7z" | |
os.system("7z x " + file) | |
os.system("rm " + file) | |
elif (file + ": gzip compressed data" in filetype): | |
print("fzip file detected") | |
if (not file.endswith(".gz")): | |
os.system("mv " + file + " " + file + ".gz") | |
file = file + ".gz" | |
os.system("gzip -d " + file) | |
elif (file + ": POSIX tar archive" in filetype): | |
print("tar file detected") | |
if (not file.endswith(".tar")): | |
os.system("mv " + file + " " + file + ".tar") | |
file = file + ".tar" | |
os.system("tar -xvf " + file) | |
os.system("rm " + file) | |
elif (file + ": PPMD archive data" in filetype): | |
print("PPMD file detected") | |
if (not file.endswith(".ppmd")): | |
os.system("mv " + file + " " + file + ".ppmd") | |
file = file + ".ppmd" | |
os.system("ppmd d " + file) | |
os.system("rm " + file) | |
elif (file + ": KGB Archiver file with compression level 3" in filetype): | |
print("KGB file detected - Extraction may be slow") | |
if (not file.endswith(".kgb")): | |
os.system("mv " + file + " " + file + ".kgb") | |
file = file + ".kgb" | |
os.system("kgb " + file) | |
elif (file + ": ARJ archive data" in filetype): | |
print("ARJ file detected") | |
if (not file.endswith(".arj")): | |
os.system("mv " + file + " " + file + ".arj") | |
file = file + ".arj" | |
os.system("arj e " + file) | |
os.system("rm " + file) | |
elif (file + ": rzip compressed data" in filetype): | |
print("rzip file detected") | |
if (not file.endswith(".rz")): | |
os.system("mv " + file + " " + file + ".rz") | |
file = file + ".rz" | |
os.system("rzip -d " + file) | |
elif (file + ": Zoo archive data" in filetype): | |
# http://launchpadlibrarian.net/230277773/zoo_2.10-28_amd64.deb | |
print("zoo file detected") | |
if (not file.endswith(".zoo")): | |
os.system("mv " + file + " " + file + ".zoo") | |
file = file + ".zoo" | |
os.system("zoo -extract " + file) | |
os.system("rm " + file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment