Advertisement
Guest User

xplor.py , Server Symlink Bypass - FlashcRew.In

a guest
May 22nd, 2012
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # devilzc0de.org (c) 2012
  3. import sys
  4. import os
  5.  
  6. def copyfile(source, dest, buffer_size=1024*1024):
  7.     if not hasattr(source, 'read'):
  8.         source = open(source, 'rb')
  9.     if not hasattr(dest, 'write'):
  10.         dest = open(dest, 'wb')
  11.     while 1:
  12.         copy_buffer = source.read(buffer_size)
  13.         if copy_buffer:
  14.             dest.write(copy_buffer)
  15.         else:
  16.             break
  17.     source.close()
  18.     dest.close()
  19.  
  20. if __name__=="__main__":
  21.     if not len(sys.argv) == 3 and not len(sys.argv) == 2:
  22.         sys.stdout.write('usage : python ' + os.path.basename(sys.argv[0]) + ' [path to dir/file] [path to save file]\r\n')
  23.         sys.stdout.write('ex    : python ' + os.path.basename(sys.argv[0]) + ' /etc\r\n')
  24.         sys.stdout.write('ex    : python ' + os.path.basename(sys.argv[0]) + ' /etc/issue\r\n')
  25.         sys.stdout.write('ex    : python ' + os.path.basename(sys.argv[0]) + ' /etc/issue issue_new_copy\r\n')
  26.         sys.exit(1)
  27.    
  28.     target = sys.argv[1].replace("\\","/")
  29.     if os.path.isdir(target):
  30.         if not target.endswith("/"):
  31.             target = target + "/"
  32.         dir = os.listdir(target)
  33.         for d in dir:
  34.             fs = ""
  35.             if os.path.isdir(target + d):
  36.                 fs = "[ DIR ]"
  37.             elif os.path.isfile(target + d):
  38.                 fs = os.path.getsize(target + d)
  39.                 fs = str(fs)
  40.                
  41.             sys.stdout.write(fs.rjust(12, " ") + " " + d + "\r\n")
  42.     elif os.path.isfile(target):
  43.         if len(sys.argv) == 3:
  44.             copyfile(target, sys.argv[2])
  45.         else:
  46.             f = open(target, "rb")
  47.             try:
  48.                 byte = f.read(1024)
  49.                 sys.stdout.write(byte)
  50.                 sys.stdout.flush()
  51.                 while byte != "":
  52.                     byte = f.read(1024)
  53.                     sys.stdout.write(byte)
  54.                     sys.stdout.flush()
  55.             finally:
  56.                 f.close()
  57.     else:
  58.         sys.stdout.write("Can't found file or folder : " + target)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement