SHARE
TWEET

Untitled

a guest Oct 19th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import zipfile
  2. from os import listdir, remove, system, popen
  3. from os.path import isfile, join
  4. import tarfile
  5. import gzip
  6. import shutil
  7.  
  8. files = [f for f in listdir('/Users/bent/Desktop/flag') if isfile(join('/Users/bent/Desktop/flag', f))]
  9. for f in files:
  10.    remove('/Users/bent/Desktop/flag/' + f)
  11.  
  12. zip_ref = zipfile.ZipFile('/Users/bent/Desktop/Archive.zip', 'r')
  13. zip_ref.extractall('/Users/bent/Desktop/flag')
  14. zip_ref.close()
  15.  
  16. files = [f for f in listdir('/Users/bent/Desktop/flag') if isfile(join('/Users/bent/Desktop/flag', f))]
  17. i = 1
  18. while len(files) == 1:
  19.    print(i)
  20.    print(files[0])
  21.  
  22.    filetype = ""
  23.  
  24.    if files[0] == "flag":
  25.       filetype = popen('file /Users/bent/Desktop/flag/' + files[0]).read()
  26.       print(filetype)
  27.  
  28.    if 'tar' in filetype:
  29.       tar_ref = tarfile.open('/Users/bent/Desktop/flag/' + files[0])
  30.       remove('/Users/bent/Desktop/flag/' + files[0])
  31.       tar_ref.extractall('/Users/bent/Desktop/flag')
  32.       tar_ref.close()
  33.    elif 'gzip' in filetype:
  34.       with gzip.open('/Users/bent/Desktop/flag/' + files[0],"rb") as f_in, open('/Users/bent/Desktop/flag/flag',"wb") as f_out:
  35.          remove('/Users/bent/Desktop/flag/' + files[0])
  36.          shutil.copyfileobj(f_in, f_out)
  37.    else:
  38.       zip_ref = zipfile.ZipFile('/Users/bent/Desktop/flag/' + files[0], 'r')
  39.       remove('/Users/bent/Desktop/flag/' + files[0])
  40.       zip_ref.extractall('/Users/bent/Desktop/flag')
  41.       zip_ref.close()
  42.    files = [f for f in listdir('/Users/bent/Desktop/flag') if isfile(join('/Users/bent/Desktop/flag', f))]
  43.    i = i + 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top