Last active
March 22, 2021 14:01
-
-
Save Snawoot/dd5fcb8f7b0df0057b2fefe5cbc1a50c to your computer and use it in GitHub Desktop.
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/env python3 | |
import ssl | |
import http.server | |
import socketserver | |
from http import HTTPStatus | |
class Handler(http.server.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(HTTPStatus.UNAUTHORIZED) | |
self.send_header('WWW-Authenticate', 'Basic realm="ApiDigest"') | |
self.end_headers() | |
print("auth=%s" % self.headers['Authorization']) | |
self.wfile.write(b'Unauthorized') | |
do_POST = do_GET | |
class MyTCPServer(socketserver.TCPServer): | |
allow_reuse_address = True | |
httpd = MyTCPServer(('', 8000), Handler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='/home/user/mitmproxy-ca/api.sec-tunnel.com.pem', keyfile='/home/user/mitmproxy-ca/api.sec-tunnel.com.key', server_side=True) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result is:
which translates to login:password
as observed on Opera 74.0.3911.232 @ Win10