-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-leach.py
138 lines (97 loc) · 2.67 KB
/
script-leach.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import requests
import os
import time
import re
import warnings
warnings.simplefilter("ignore")
class Leach:
def __init__(self,data):
self.data = data
self.temp_file = "temp.txt"
self.split_file = "split.txt"
self.link_file = "links.txt"
self.regex = re.compile(r"(?<=src=)[^=].*$")
self.wmode = "w"
self.rmode = "r"
self.amode = "a"
self.downloader = requests
def attach(self) -> bool:
try:
with open(self.temp_file,self.wmode) as temp:
temp.write(self.data)
return True
except:
return False
def sip(self, target) -> set:
with open(self.temp_file, self.rmode) as tempfile:
data = tempfile.readlines()
try:
for chunk in data:
with open(self.link_file, self.amode) as linkfile:
if chunk.startswith("<script") and target.split("//")[1] in chunk:
link = re.findall(self.regex,str(chunk))
try:
link = link[0].split(" ")[0]
print(" * Link 🔗:",link)
linkfile.write(link+"\n")
except:
continue
print(" * Done...")
return [True, self.link_file]
except Exception as error:
print(error)
return [False, None]
def suck_script(self,file):
with open(file, self.rmode) as linkfile:
link_file = linkfile.readlines()
for link in link_file:
try:
file_name = link.split("/")[-1].strip("\s\n\r").replace("'","")
data = self.downloader.get(link.strip("\n\s\r").replace("'",""))
if data.status_code == 200:
with open(f"{file_name}", self.wmode) as file:
file.write(str(data.text))
except Exception as error:
print(error)
return False
return True
v =f'''
{'+'*48}
Script-Leach
by: TaqsBlaze
leach all urls leading to scripts from any website
{'+'*48}
'''
print(v)
url = str(input(" * Url:"))
print("* Connecting...💫")
data =requests.get(url,
headers={"User-Agent":"Android"}
)
#print(data.text)
if data.status_code == 200:
leach = Leach(data.text)
if leach.attach():
sip = leach.sip(url)
if sip[0]:
print(" * Got all links...😎")
print(" * Would you like to download found js scripts")
download = str(input(" * y/n:"))
if download.lower() == "y":
get_files = leach.suck_script(sip[1])
if get_files:
print(" * Script files downloaded..📑")
else:
print(" * Failed to download scripts..🚫")
elif download.lower() == "n":
print(" * We are done...")
exit()
else:
print(" * Out of bound⚠️")
exit()
else:
print(" * Failed to attach...😢")
else:
print(" * Failed to attach...😢")
else:
exit()