Skip to content

Commit f52d74a

Browse files
committed
Removed LAN checking. You gotta know when chop stuff. Just don't forward the ports.
1 parent e9688f3 commit f52d74a

File tree

1 file changed

+50
-81
lines changed

1 file changed

+50
-81
lines changed

start.py

Lines changed: 50 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import hashlib
1919
from http.server import BaseHTTPRequestHandler
2020
from http.server import HTTPServer
21-
import ipaddress
2221
import mimetypes
2322
import os
2423
import re
@@ -52,65 +51,61 @@ def send_response(self, code, message=None):
5251

5352
def do_GET(self):
5453
"""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:
6776
self.send_response(200)
68-
self.send_header('Content-type', 'application/xml')
77+
self.send_header('Content-type', 'text/plain')
6978
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:
9992
self.send_error(404)
93+
except IOError:
94+
self.send_error(404)
10095

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
106101

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()
114109

115110

116111
def check_root():
@@ -140,32 +135,6 @@ def get_lan():
140135
return lan
141136

142137

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-
169138
def write_conf(lan):
170139
"""Writes the configuration file for FakeDns"""
171140
exists = os.path.isfile(DNS_LOC)

0 commit comments

Comments
 (0)