Last active
July 8, 2020 11:42
-
-
Save noobsdt/7bed56c0d91ac8009c4de3b7f1318791 to your computer and use it in GitHub Desktop.
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/python3 | |
#Very simple script for grabbing parameters from js | |
#Need a file contains js url | |
import sys | |
import requests | |
import subprocess | |
fileinput = sys.argv[1] | |
if fileinput: | |
with open(fileinput, 'r') as file: | |
lines = file.readlines() | |
for line in lines: | |
l = line.strip() | |
try: | |
header = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1)\ | |
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'} | |
req = requests.get(l, headers=header, timeout=1) | |
cod = req.status_code | |
print(l, cod) | |
if cod == 200: | |
curl = subprocess.Popen(['curl', '-s', l], stdout=subprocess.PIPE,) | |
grep = subprocess.Popen(['grep', '-ioE', 'var [a-zA-Z0-9_]+'], stdin=curl.stdout, stdout=subprocess.PIPE,) | |
sed = subprocess.Popen(['sed', 's/var //'], stdin=grep.stdout, stdout=subprocess.PIPE,) | |
sort = subprocess.Popen(['sort', '-u'], stdin=sed.stdout, stdout=subprocess.PIPE,) | |
for i in sort.stdout: | |
val= i.decode('ascii') | |
param = val.strip() | |
print(param) | |
with open('paramjs.txt', 'a') as file: | |
file.write(param + '\n') | |
except requests.ConnectionError: | |
print(l +'\033[0;31m ==> Connection Failed 😮️\033[0m') | |
except: | |
print('Something Went Wrong 😣️') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment