Last active
December 17, 2023 12:09
-
-
Save sekaiwish/7fa27d2b7d855ea35c09f87a1ce64f8c to your computer and use it in GitHub Desktop.
MHF HTTP Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import http.server | |
import socketserver | |
from urllib.parse import parse_qs | |
port = 80 | |
print_headers = True | |
print_params = True | |
class CustomHandler(http.server.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
if print_headers: | |
print('HEADERS:\n', self.headers) | |
if print_params: | |
qp = dict() | |
if '?' in self.path: | |
path, query_string = self.path.split('?', 1) | |
for param in query_string.split('&'): | |
key, value = param.split('=', 1) | |
qp[key] = value | |
print('PARAMS:', {k: v for k, v in qp.items()}) | |
fd = open(f".{self.path.partition('?')[0]}", 'rb').read() | |
self.send_response(200) | |
self.send_header('Content-Length', len(fd)) | |
self.send_header('Transfer-Encoding', 'chunked') | |
self.end_headers() | |
self.wfile.write(fd) | |
return | |
Handler = CustomHandler | |
with socketserver.TCPServer(("", port), Handler) as httpd: | |
httpd.serve_forever() |
Seems to want a response with a token like so:
{
"encrypt_key": "someBase64EncodedKey"
}
but I couldn't get the response to be valid. May need to be hashed with the client_pub_key sent.
client_pub_key is obfuscated Base64 by swapping + to - and / to _
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Process:
Create file
...\Servers\v1\crypt\commonkey\rsa
and enter JSON response there.