SERBIANHACKERS

SRBTOOL | HTTP Upload

Apr 14th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. #SRBHACKERS
  2.  
  3. #!/usr/bin/python
  4.  
  5.  
  6. import BaseHTTPServer
  7. import random
  8.  
  9. SERVER = '10.230.229.11'
  10. PORT = 8080
  11.  
  12. def get_filename():
  13.     chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
  14.     fn = ''.join([random.choice(chars) for i in xrange(12)])
  15.  
  16.     return fn
  17.  
  18.  
  19. class PostHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  20.  
  21.     def do_POST(self):
  22.         length = self.headers['content-length']
  23.         data = self.rfile.read(int(length))
  24.  
  25.         fn = get_filename()
  26.         with open(fn, 'w') as fh:
  27.             fh.write(data.decode())
  28.  
  29.         self.send_response(200)
  30.  
  31.         return
  32.  
  33.     def do_GET(self):
  34.         page = '''
  35.        <h1>Upload a File</h1>
  36.        <form action="/" method="post" enctype="multipart/form-data">
  37.        <input type="file" name="file" placeholder="Enter a filename."></input><br />
  38.        <input type="submit" value="Import">
  39.        </form>
  40.        '''
  41.  
  42.         self.send_response(200)
  43.         self.send_header("Content-type", "text/html")
  44.         self.end_headers()
  45.         self.wfile.write(page)
  46.  
  47.  
  48. if __name__ == '__main__':
  49.     from BaseHTTPServer import HTTPServer
  50.     server = HTTPServer((SERVER, PORT), PostHandler)
  51.     print 'Starting server on {0}:{1}, use <Ctrl-C> to stop'.format(SERVER, PORT)
  52.     server.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment