Skip to content

Commit

Permalink
Add Offline HTML5 Cache by @ps4miner #108
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Azif authored Jun 10, 2018
1 parent b4b4953 commit 8bf1732
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ def static_request(self):
data = buf.read()
self.my_sender(mime, data)

def generate_manifest(self):
if SETTINGS['Offline_Cache']:
manifest = 'CACHE MANIFEST\n'
manifest += '/index.html\n'

for path, subdirs, files in os.walk(os.path.join(THEME_LOC, SETTINGS['Theme'])):
for name in files:
manifest += os.path.join(path, name).replace(CWD, '').replace('\\', '/') + '\n'

for path, subdirs, files in os.walk(EXPLOIT_LOC):
for name in files:
manifest += os.path.join(path, name).replace(CWD, '').replace('\\', '/') + '\n'
self.my_sender('text/cache-manifest', bytes(manifest, 'utf-8'))
else:
self.send_error(404)

def inject_exploit_html(self, html):
try:
firmwares = os.listdir(EXPLOIT_LOC)
Expand Down Expand Up @@ -207,7 +223,12 @@ def inject_exploit_html(self, html):
data = json.dumps({'firmwares': ['I/O Error on Host']})
return html.replace(b'{{EXPLOITS}}', bytes(data, 'utf-8'))

return html.replace(b'{{EXPLOITS}}', data)
html = html.replace(b'{{EXPLOITS}}', data)

if SETTINGS['Offline_Cache']:
html = html.replace(b'<html>', b'<html manifest="offline.manifest">')

return html

def check_ua(self):
if self.headers['User-Agent'] in SETTINGS['Valid_UA']:
Expand All @@ -234,6 +255,8 @@ def do_GET(self):
self.send_error(400, explain='This PS4 is not on a supported firmware')
if not MENU_OPEN:
print('>> Unsupported PS4 attempted to access exploits')
elif re.match(r'\/offline.manifest$', self.path):
self.generate_manifest()
elif re.match(r'^\/exploits\/.*\/', self.path):
if not SETTINGS['UA_Check'] or self.check_ua():
self.exploit()
Expand Down Expand Up @@ -522,6 +545,11 @@ def import_settings(settings_file):
print('WARNING: HTTP is not port 80, User\'s Manual method will not work')
else:
print('WARNING: "HTTP_Port" in settings is invalid, using default')

if validate_setting(imported, 'Offline_Cache', bool):
SETTINGS['Offline_Cache'] = imported['Offline_Cache']
else:
print('WARNING: "Offline_Cache" in settings is invalid, using default')

if validate_setting(imported, 'Root_Check', bool):
SETTINGS['Root_Check'] = imported['Root_Check']
Expand Down

0 comments on commit 8bf1732

Please sign in to comment.