Created
December 18, 2025 23:56
-
-
Save veygax/a8cc2e665bb37edc5dbd71208fefd3e6 to your computer and use it in GitHub Desktop.
splits webcrack deobfuscated.js into seperate, manageable files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re, os, sys | |
| def split_deobfuscated(fp, od): | |
| print(f"reading {fp}...") | |
| os.makedirs(od, exist_ok=True) | |
| with open(fp, 'r', encoding='utf-8') as f: | |
| content = f.read() | |
| start_match = re.search(r'var \w+\s*=\s*\{', content) | |
| if not start_match: | |
| return print("could not find object start.") | |
| pattern = re.compile(r'(\d+|[\"\']\d+[\"\'])\s*:\s*(\([^)]*\)|function\s*\([^)]*\))\s*=>\s*\{') | |
| cursor, count = start_match.end(), 0 | |
| while True: | |
| match = pattern.search(content, cursor) | |
| if not match: break | |
| module_id = match.group(1).strip('\"\'') | |
| start_pos = match.start() | |
| idx, balance = match.end(), 1 | |
| in_str, escape = None, False | |
| # parse to end of module block handling strings and comments | |
| while idx < len(content) and balance > 0: | |
| char = content[idx] | |
| if in_str: | |
| if escape: escape = False | |
| elif char == '\\': escape = True | |
| elif char == in_str: in_str = None | |
| else: | |
| if char in "\"'`": in_str = char | |
| elif char == '{': balance += 1 | |
| elif char == '}': balance -= 1 | |
| elif char == '/' and idx + 1 < len(content): | |
| if content[idx+1] == '/': | |
| idx += 1 | |
| while idx < len(content) and content[idx] != '\n': idx += 1 | |
| continue | |
| elif content[idx+1] == '*': | |
| idx += 2 | |
| while idx + 1 < len(content) and not (content[idx] == '*' and content[idx+1] == '/'): idx += 1 | |
| idx += 1; continue | |
| idx += 1 | |
| with open(os.path.join(od, f"{module_id}.js"), 'w', encoding='utf-8') as out: | |
| out.write(content[start_pos:idx]) | |
| count += 1 | |
| cursor = idx | |
| print(f"finished. extracted {count} modules.") | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 3: print("usage: python split_js.py <input_file> <output_dir>") | |
| else: split_deobfuscated(sys.argv[1], sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment