Skip to content

Instantly share code, notes, and snippets.

@zone559
Created July 23, 2025 21:22
Show Gist options
  • Select an option

  • Save zone559/187beda2c9004060b349fc564e1b05a9 to your computer and use it in GitHub Desktop.

Select an option

Save zone559/187beda2c9004060b349fc564e1b05a9 to your computer and use it in GitHub Desktop.
import base64
import re
def decode_url(encoded_str):
# Remove the last 2 characters
encoded_str = encoded_str[:-2]
# Split into characters, reverse, and join back
reversed_str = ''.join(reversed(list(encoded_str)))
# Base64 decode
return base64.b64decode(reversed_str)
# The encoded string from the file parameter
encoded_string = "A5YqbdwQBRQhUmfz==QbKZ0aYlFUVVVTZlmVBt2a9IzZpNnJ0ETN4kjMyAjYiFDZ0MmN2YWNmFmN1QDOkJGNjFGO3EWM0MjNhJGMyEWOmlTOzQDN3QTNxIGMkRmMlZzYiFzN40zZpNnJ1EDO2AzMzUzNx0TZtlGd/gTdz0mLxkTM1MTM4EzL4U3Mt9SbvNmLl52b6RWZrFWZs9yL6MHc0RHakvJuRU84TTFLyAzf"
# Decode and get bytes
decoded_bytes = decode_url(encoded_string)
# Convert to hex
hex_result = decoded_bytes.hex()
# Extract the URL portion (between '2f2f' and '.m3u8')
url_match = re.search(r'2f2f(.+?2e6d337538)', hex_result)
if url_match:
url_hex = url_match.group(1)
# Convert hex to ASCII
url = bytes.fromhex(url_hex).decode('utf-8')
# Reconstruct full URL
full_url = f"https://{url}"
print("Decoded URL:", full_url)
else:
print("Couldn't extract URL from hex:", hex_result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment