diff --git a/start.py b/start.py index cec3d50..1b322ef 100755 --- a/start.py +++ b/start.py @@ -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) @@ -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'', b'') + + return html def check_ua(self): if self.headers['User-Agent'] in SETTINGS['Valid_UA']: @@ -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() @@ -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']