Last active
August 29, 2015 14:05
-
-
Save yogeesh/66cfb2860c59b2c78fac to your computer and use it in GitHub Desktop.
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
#hitcon | |
import zipfile, tarfile | |
import os | |
import sys | |
sys.setrecursionlimit(10000) | |
def unzip(file, path): | |
print file | |
zip = zipfile.ZipFile(file) | |
zipList = zip.namelist() | |
for file in zipList: | |
if file.endswith('zip'): | |
break | |
zip.extract(file, path).split('\\') | |
for file in zipList: | |
if os.path.isdir(file): | |
return path+'/'+file | |
def untar(file, path): | |
print file | |
tar=tarfile.open(file) | |
tar.extractall() | |
tarList=tar.getnames() | |
for file in tarList: | |
if os.path.isdir(file): | |
return path+'/'+file | |
def dirHandle(path): | |
os.chdir(path) | |
for file in os.listdir(path): | |
if os.path.isfile(file): | |
if file.endswith('zip'): | |
path=unzip(file, path) | |
if file.endswith('.tar.bz2') or file.endswith('.tar.gz') or file.endswith('.tar'): | |
path=untar(file, path) | |
print path.replace('//', '\\') | |
dirHandle(path) | |
''' | |
def pathTruncate(): | |
dst='F:\studies\tutorials\CTF stuff\hitcon14' | |
for file in os.listdir(path): | |
if os.path.isfile(file): | |
copyfile(file, dst) | |
''' | |
path=r'F:\studies\tutorials\CTF stuff\hitcon14\\' | |
dirHandle(path) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment