Created
February 13, 2026 00:00
-
-
Save sohaibilyas/5f155be8e5df427a2eb4e4133f32aa79 to your computer and use it in GitHub Desktop.
SAE Systems Tracking URL Decoder
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
| #!/bin/bash | |
| # SAE Systems Tracking URL Decoder | |
| # Usage: ./sae-decode.sh "YOUR_URL_HERE" | |
| # Or run without arguments to paste interactively | |
| set -e | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| NC='\033[0m' # No Color | |
| echo "==========================================" | |
| echo "SAE Systems Tracking URL Decoder" | |
| echo "==========================================" | |
| echo "" | |
| # Check if Python3 is available | |
| if ! command -v python3 &> /dev/null; then | |
| echo -e "${RED}Error: Python3 is required but not installed.${NC}" | |
| echo "Please install Python3 first:" | |
| echo " Ubuntu/Debian: sudo apt-get install python3" | |
| echo " Mac: brew install python3" | |
| exit 1 | |
| fi | |
| # Get input | |
| if [ -z "$1" ]; then | |
| echo "Paste the full URL (or just the 'j' parameter value):" | |
| read -r INPUT_URL | |
| else | |
| INPUT_URL="$1" | |
| fi | |
| if [ -z "$INPUT_URL" ]; then | |
| echo -e "${RED}Error: No input provided${NC}" | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "Decoding..." | |
| # Python script to do the actual decoding | |
| python3 << EOF | |
| import sys | |
| import base64 | |
| import zlib | |
| import json | |
| import urllib.parse | |
| import re | |
| try: | |
| input_data = """$INPUT_URL""" | |
| # If it's a full URL, extract the 'j' parameter | |
| if '?' in input_data: | |
| match = re.search(r'[?&]j=([^&]+)', input_data) | |
| if match: | |
| encoded = match.group(1) | |
| print("Extracted 'j' parameter from URL") | |
| else: | |
| encoded = input_data | |
| print("No 'j' parameter found, using full input") | |
| else: | |
| encoded = input_data | |
| print("Using input as raw parameter") | |
| print(f"Input length: {len(encoded)} characters") | |
| # Step 1: URL Decode | |
| step1 = urllib.parse.unquote(encoded) | |
| print(f"Step 1 - URL decoded: {len(step1)} chars") | |
| # Step 2: Remove '0' prefix | |
| if step1.startswith('0'): | |
| step2 = step1[1:] | |
| print(f"Step 2 - Removed '0' prefix: {len(step2)} chars") | |
| else: | |
| step2 = step1 | |
| print(f"Step 2 - No '0' prefix found, continuing...") | |
| # Step 3: Fix base64 padding | |
| remainder = len(step2) % 4 | |
| if remainder: | |
| padding = 4 - remainder | |
| step2 += '=' * padding | |
| print(f"Step 3 - Added {padding} padding character(s)") | |
| else: | |
| print(f"Step 3 - No padding needed") | |
| # Step 4: Base64 decode | |
| try: | |
| compressed = base64.b64decode(step2) | |
| print(f"Step 4 - Base64 decoded: {len(compressed)} bytes") | |
| except Exception as e: | |
| print(f"ERROR: Base64 decode failed: {e}") | |
| sys.exit(1) | |
| # Step 5: Zlib decompress | |
| try: | |
| decompressed = zlib.decompress(compressed) | |
| print(f"Step 5 - Zlib decompressed: {len(decompressed)} bytes") | |
| except Exception as e: | |
| print(f"ERROR: Zlib decompression failed: {e}") | |
| print("Make sure you removed the '0' prefix correctly!") | |
| sys.exit(1) | |
| # Step 6: Parse outer JSON | |
| outer = json.loads(decompressed) | |
| print(f"Step 6 - Parsed outer JSON (keys: {', '.join(outer.keys())})") | |
| # Step 7: Decode inner fields | |
| print("\\n" + "="*50) | |
| print("DECODED EVENT DATA") | |
| print("="*50) | |
| def decode_field(name, data): | |
| if name not in data: | |
| return None | |
| try: | |
| b64 = data[name] | |
| # Fix padding | |
| if len(b64) % 4: | |
| b64 += '=' * (4 - len(b64) % 4) | |
| decoded = base64.b64decode(b64) | |
| return json.loads(decoded) | |
| except Exception as e: | |
| return {"error": str(e)} | |
| # Decode main event | |
| e_data = decode_field('e', outer) | |
| if e_data and 'error' not in e_data: | |
| print(f"\\n>>> MAIN EVENT (e):") | |
| print(json.dumps(e_data, indent=2)) | |
| # Show key fields summary | |
| print(f"\\n--- KEY FIELDS ---") | |
| key_fields = ['ip', 'ur', 'pr', 'ts', 'kw', 'di'] | |
| for field in key_fields: | |
| if field in e_data: | |
| val = e_data[field] | |
| if len(str(val)) > 60: | |
| val = str(val)[:57] + "..." | |
| print(f"{field:10}: {val}") | |
| # Decode click event if different | |
| ce_data = decode_field('ce', outer) | |
| if ce_data and ce_data != e_data: | |
| print(f"\\n>>> CLICK EVENT (ce):") | |
| if 'et' in ce_data: | |
| print(f"Event time: {ce_data['et']}ms") | |
| # Decode search event if different | |
| se_data = decode_field('se', outer) | |
| if se_data and se_data != e_data: | |
| print(f"\\n>>> SEARCH EVENT (se):") | |
| if 'et' in se_data: | |
| print(f"Event time: {se_data['et']}ms") | |
| # Show metadata | |
| print(f"\\n--- METADATA ---") | |
| meta_fields = ['s', 'ci', 'cr', 'cs', 'ic'] | |
| for field in meta_fields: | |
| if field in outer: | |
| val = outer[field] | |
| if len(str(val)) > 50: | |
| val = str(val)[:47] + "..." | |
| print(f"{field:10}: {val}") | |
| except Exception as e: | |
| print(f"ERROR: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |
| EOF | |
| echo "" | |
| echo "==========================================" | |
| echo -e "${GREEN}Decoding complete!${NC}" | |
| echo "==========================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment