Last active
June 11, 2024 06:58
-
-
Save JuanjoSalvador/aef62f1c1a8e2bf842c225d871d50c8c to your computer and use it in GitHub Desktop.
Extracts and decrypt a list of adf.ly links from a forum's post
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
# -*- coding: utf-8 -*- | |
import base64, requests, os, re, sys | |
from bs4 import BeautifulSoup | |
def _crack(code): | |
zeros = '' | |
ones = '' | |
for n,letter in enumerate(code): | |
if n % 2 == 0: | |
zeros += code[n] | |
else: | |
ones = code[n] + ones | |
key = zeros + ones | |
key = list(key) | |
i = 0 | |
while i < len(key): | |
if key[i].isdigit(): | |
for j in range(i+1,len(key)): | |
if key[j].isdigit(): | |
u = int(key[i])^int(key[j]) | |
if u < 10: | |
key[i] = str(u) | |
i = j | |
break | |
i+=1 | |
key = ''.join(key) | |
url = base64.b64decode(key)[16:-16].decode('utf-8') | |
return url | |
def _decrypt(url): | |
adfly = requests.get(url).text | |
ysmm = re.findall(r"var ysmm = '(.*?)';", adfly)[0] | |
decrypted_url = _crack(ysmm) | |
return decrypted_url | |
def main(): | |
with open('links2.txt', 'r') as target, open('output.txt', 'w') as output: | |
soup = BeautifulSoup(target, 'html.parser') | |
items = soup.select('a') | |
links = [] | |
for item in items: | |
url = item.get('href') | |
try: | |
output.write("{} \n".format(_decrypt(url))) | |
except Exception as e: | |
print("Ocurrió un error: {}".format(e)) | |
print("¡Finalizado! Resultados guardados en output/output.txt") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment