My hackthebox.eu rank is falling like a rock because I don’t have much time to spend. To remember better days I post my former rank banner which I saved before probably knowing what happens later on 😉
I was in the top 200! If you don’t know hackthebox head over to their website and enjoy hacking server and solving challenges like stego, reversing, forensic and others: https://www.hackthebox.eu/
hackthebox
Simple IPv4 and IPv6 HTTP Server
When doing hackthebox stuff I often use the SimpleHTTPServer module of python to download scripts and tools from my host system to the client.
Recently I needed an IPv6 http server because IPv4 was blocked. Since I didn’t find a simple way to host files via IPv6 I extent the SimpleHTTPServer module with IPv6 support. While I was at it I also implemented file upload via post.
The latest version can be found on my GitHub page https://github.com/wsoltys/tools
The current version as of this writing is listed below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
#!/usr/bin/python import sys import socket from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler class MyHandler(SimpleHTTPRequestHandler): def do_GET(self): if self.path == '/ip': self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write('Your IP address is %s' % self.client_address[0]) return else: return SimpleHTTPRequestHandler.do_GET(self) def do_POST(self): content_length = int(self.headers['Content-Length']) body = self.rfile.read(content_length) self.send_response(200) self.end_headers() self.wfile.write('ok') filename = self.path[1:] with open(filename, 'w') as f: f.write(body) return def do_PUT(self): MyHandler.do_POST(self) return class HTTPServerV6(HTTPServer): address_family = socket.AF_INET6 def main(): if len(sys.argv) > 1: port = int(sys.argv[1]) else: port = 80 server = HTTPServerV6(('::', port), MyHandler) print('Serving http on '+server.server_name+' port '+str(server.server_port)) print('Upload files with: curl -T <file> <server ip>') server.serve_forever() if __name__ == '__main__': main() |