Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aslian
Created July 22, 2014 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslian/57f6e313c078cf3dcbdf to your computer and use it in GitHub Desktop.
Save aslian/57f6e313c078cf3dcbdf to your computer and use it in GitHub Desktop.
Decode adf.ly links. Credits https://gist.github.com/alexdrk/6113685
#!/usr/bin/env python
import sys
from base64 import b64decode as atob
from urllib2 import urlopen
from re import search
if len(sys.argv) <= 1:
print """\
[unadf.ly.py - Decode adf.ly links]
Based on github.com/alexdrk approach
Usage: unadf.ly.py <link>
"""
sys.exit()
link = sys.argv[1]
page = urlopen(link).read()
key = search('ysmm\s=\s\'(.*)\'', page).group(True)
parts = ['', '']
for i,v in enumerate(key):
if i%2 == 0:
parts[0] += key[i]
else:
parts[1] = key[i] + parts[1]
print atob(''.join(parts))[2:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment