|
18 | 18 | import hashlib
|
19 | 19 | from http.server import BaseHTTPRequestHandler
|
20 | 20 | from http.server import HTTPServer
|
21 |
| -import ipaddress |
22 | 21 | import mimetypes
|
23 | 22 | import os
|
24 | 23 | import re
|
@@ -52,65 +51,61 @@ def send_response(self, code, message=None):
|
52 | 51 |
|
53 | 52 | def do_GET(self):
|
54 | 53 | """Determines how to handle HTTP requests"""
|
55 |
| - client = self.client_address[0] |
56 |
| - if not check_lan(client, get_network(get_lan())): |
57 |
| - self.send_error(403) |
58 |
| - else: |
59 |
| - try: |
60 |
| - path = self.path.rsplit('/', 1)[-1] |
61 |
| - if path == 'ps4-updatelist.xml': |
62 |
| - region = self.path.split('/')[4] |
63 |
| - path = os.path.join(CWD, 'updates', 'ps4-updatelist.xml') |
64 |
| - with open(path, 'rb') as buf: |
65 |
| - xml = buf.read() |
66 |
| - xml = xml.replace(b'{{REGION}}', bytes(region, 'utf-8')) |
| 54 | + try: |
| 55 | + path = self.path.rsplit('/', 1)[-1] |
| 56 | + if path == 'ps4-updatelist.xml': |
| 57 | + region = self.path.split('/')[4] |
| 58 | + path = os.path.join(CWD, 'updates', 'ps4-updatelist.xml') |
| 59 | + with open(path, 'rb') as buf: |
| 60 | + xml = buf.read() |
| 61 | + xml = xml.replace(b'{{REGION}}', bytes(region, 'utf-8')) |
| 62 | + self.send_response(200) |
| 63 | + self.send_header('Content-type', 'application/xml') |
| 64 | + self.end_headers() |
| 65 | + self.wfile.write(xml) |
| 66 | + elif path == 'ps4-updatefeature.html': |
| 67 | + path = os.path.join(CWD, 'updates', path) |
| 68 | + with open(path, 'rb') as buf: |
| 69 | + self.send_response(200) |
| 70 | + self.send_header('Content-type', 'text/html') |
| 71 | + self.end_headers() |
| 72 | + self.wfile.write(buf.read()) |
| 73 | + elif self.path.endswith('.PUP'): |
| 74 | + path = os.path.join(CWD, 'updates', path) |
| 75 | + with open(path, 'rb') as buf: |
67 | 76 | self.send_response(200)
|
68 |
| - self.send_header('Content-type', 'application/xml') |
| 77 | + self.send_header('Content-type', 'text/plain') |
69 | 78 | self.end_headers()
|
70 |
| - self.wfile.write(xml) |
71 |
| - elif path == 'ps4-updatefeature.html': |
72 |
| - path = os.path.join(CWD, 'updates', path) |
73 |
| - with open(path, 'rb') as buf: |
74 |
| - self.send_response(200) |
75 |
| - self.send_header('Content-type', 'text/html') |
76 |
| - self.end_headers() |
77 |
| - self.wfile.write(buf.read()) |
78 |
| - elif self.path.endswith('.PUP'): |
79 |
| - path = os.path.join(CWD, 'updates', path) |
80 |
| - with open(path, 'rb') as buf: |
81 |
| - self.send_response(200) |
82 |
| - self.send_header('Content-type', 'text/plain') |
83 |
| - self.end_headers() |
84 |
| - self.wfile.write(buf.read()) |
85 |
| - elif re.match('/document/[a-zA-Z\-]{2,5}/ps4/', self.path): |
86 |
| - if not path: |
87 |
| - path = 'index.html' |
88 |
| - mime = mimetypes.guess_type(path) |
89 |
| - if not mime[0]: |
90 |
| - mime[0] = 'application/octet-stream' |
91 |
| - with open(os.path.join(EXPLOIT_LOC, path), 'rb') as buf: |
92 |
| - self.send_response(200) |
93 |
| - self.send_header('Content-type', mime[0]) |
94 |
| - self.end_headers() |
95 |
| - self.wfile.write(buf.read()) |
96 |
| - else: |
97 |
| - self.send_error(404) |
98 |
| - except IOError: |
| 79 | + self.wfile.write(buf.read()) |
| 80 | + elif re.match('/document/[a-zA-Z\-]{2,5}/ps4/', self.path): |
| 81 | + if not path: |
| 82 | + path = 'index.html' |
| 83 | + mime = mimetypes.guess_type(path) |
| 84 | + if not mime[0]: |
| 85 | + mime[0] = 'application/octet-stream' |
| 86 | + with open(os.path.join(EXPLOIT_LOC, path), 'rb') as buf: |
| 87 | + self.send_response(200) |
| 88 | + self.send_header('Content-type', mime[0]) |
| 89 | + self.end_headers() |
| 90 | + self.wfile.write(buf.read()) |
| 91 | + else: |
99 | 92 | self.send_error(404)
|
| 93 | + except IOError: |
| 94 | + self.send_error(404) |
100 | 95 |
|
101 |
| - if path == 'rop.js': |
102 |
| - payload_menu = True |
103 |
| - for thread in threading.enumerate(): |
104 |
| - if thread.name == 'Payload_Brain': |
105 |
| - payload_menu = False |
| 96 | + if path == 'rop.js': |
| 97 | + payload_menu = True |
| 98 | + for thread in threading.enumerate(): |
| 99 | + if thread.name == 'Payload_Brain': |
| 100 | + payload_menu = False |
106 | 101 |
|
107 |
| - if payload_menu: |
108 |
| - print('>> Exploit Sent...') |
109 |
| - thread = threading.Thread(name='Payload_Brain', |
110 |
| - target=payload_brain, |
111 |
| - args=(self.client_address[0],), |
112 |
| - daemon=True) |
113 |
| - thread.start() |
| 102 | + if payload_menu: |
| 103 | + print('>> Exploit Sent...') |
| 104 | + thread = threading.Thread(name='Payload_Brain', |
| 105 | + target=payload_brain, |
| 106 | + args=(self.client_address[0],), |
| 107 | + daemon=True) |
| 108 | + thread.start() |
114 | 109 |
|
115 | 110 |
|
116 | 111 | def check_root():
|
@@ -140,32 +135,6 @@ def get_lan():
|
140 | 135 | return lan
|
141 | 136 |
|
142 | 137 |
|
143 |
| -def get_network(ipaddr): |
144 |
| - """Guesses the private network based on the IP address""" |
145 |
| - ipaddr = ipaddr.split('.') |
146 |
| - |
147 |
| - if ipaddr[0] == '10': |
148 |
| - network = '10.0.0.0/8' |
149 |
| - elif ipaddr[0] == '172' and 16 <= int(ipaddr[1]) <= 31: |
150 |
| - network = '172.16.0.0/12' |
151 |
| - elif ipaddr[0] == '192' and ipaddr[1] == '168': |
152 |
| - network = '192.168.0.0/16' |
153 |
| - else: |
154 |
| - print('WARNING: Could not figure out private network, ' + |
155 |
| - 'LAN blocking will not work') |
156 |
| - network = '0.0.0.0/0' |
157 |
| - |
158 |
| - return network |
159 |
| - |
160 |
| - |
161 |
| -def check_lan(ipaddr, network): |
162 |
| - """Checks to see if the IP address is contained within the network""" |
163 |
| - if network == '0.0.0.0/0': |
164 |
| - return True |
165 |
| - elif bool(ipaddress.ip_address(ipaddr) in ipaddress.ip_network(network)): |
166 |
| - return True |
167 |
| - |
168 |
| - |
169 | 138 | def write_conf(lan):
|
170 | 139 | """Writes the configuration file for FakeDns"""
|
171 | 140 | exists = os.path.isfile(DNS_LOC)
|
|
0 commit comments