Created
February 28, 2023 10:25
-
-
Save agajdosi/d611fe7f68a3fd2d90c20ace95c54535 to your computer and use it in GitHub Desktop.
Automated creation of HTTPS proxy from python script using the proxy.py module. The private and public keys are automatcally created by the script. Practical for the testing purposes, squishy squid no longer needed.
This file contains 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
import os | |
import time | |
import proxy | |
from proxy.common import pki | |
PASSWORD = '12dadadadlkahdlashjdlasdlalsdhlh3' | |
SUBJECT = '/CN=localhost' | |
LOG_FORMAT = '%(asctime)s.%(msecs)03d - [%(levelname)-.1s] %(module)s.%(funcName)s:%(lineno)d - %(message)s' | |
if __name__ == '__main__': | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | |
private_key_path = os.path.join(dir_path, 'private_key.pem') | |
public_key_path = os.path.join(dir_path, 'public_key.pem') | |
assert pki.gen_private_key(private_key_path, PASSWORD), 'failed to generate private key' | |
assert pki.remove_passphrase(private_key_path, PASSWORD, private_key_path), 'failed to remove passphrase' | |
assert pki.gen_public_key(public_key_path, private_key_path, PASSWORD, SUBJECT), 'failed to generate public key' | |
print(f"PUBLIC_KEY_PATH: {public_key_path}") | |
opts = [ | |
'--cert-file', public_key_path, | |
'--key-file', private_key_path, | |
'--log-format', LOG_FORMAT, | |
] | |
""" | |
opts = [ | |
'--basic-auth', "user:12345", | |
'--log-format', LOG_FORMAT, | |
] | |
""" | |
with proxy.Proxy(opts) as prx: | |
while True: | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment