Created
July 22, 2014 16:49
-
-
Save aslian/57f6e313c078cf3dcbdf to your computer and use it in GitHub Desktop.
Decode adf.ly links. Credits https://gist.github.com/alexdrk/6113685
This file contains 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
#!/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