-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrossInjector.py
More file actions
178 lines (142 loc) Β· 7.16 KB
/
CrossInjector.py
File metadata and controls
178 lines (142 loc) Β· 7.16 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import os
import sys
import requests
import argparse
import time
import urllib.parse as urlparse
from termcolor import colored
from urllib.parse import parse_qs
try:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
except ImportError:
print("Selenium and webdriver_manager modules not found. Please make sure they are installed.")
sys.exit(1)
def load_animation():
load_str = "preparing the CrossInjector...."
ls_len = len(load_str)
animation = "|/-\\"
anicount = 0
counttime = 0
i = 0
while (counttime != 100):
time.sleep(0.075)
load_str_list = list(load_str)
x = ord(load_str_list[i])
y = 0
if x != 32 and x != 46:
if x>90:
y = x-32
else:
y = x + 32
load_str_list[i]= chr(y)
res =''
for j in range(ls_len):
res = res + load_str_list[j]
sys.stdout.write("\r"+res + animation[anicount])
sys.stdout.flush()
load_str = res
anicount = (anicount + 1)% 4
i =(i + 1)% ls_len
counttime = counttime + 1
if os.name =="nt":
os.system("cls")
else:
os.system("clear")
# Function to check if a given URL is alive
def is_alive(url):
try:
response = requests.head(url, timeout=5)
return response.status_code < 400
except requests.exceptions.RequestException:
return False
# Function to get all the URLs from a given file
def get_urls_from_file(file_path):
with open(file_path, "r") as f:
urls = f.read().splitlines()
return urls
# Function to get all the XSS payloads from a given file
def get_payloads_from_file(file_path):
with open(file_path, "r") as f:
payloads = f.read().splitlines()
return payloads
# Function to check if a given URL has a query string
def has_query_string(url):
return bool(urlparse.urlparse(url).query)
# Function to inject a payload into a given URL
def inject_payload(url, payload):
if has_query_string(url):
url_parts = list(urlparse.urlparse(url))
query = dict(parse_qs(url_parts[4]))
for key in query:
query[key] = f"{query[key]}{payload}"
url_parts[4] = urlparse.urlencode(query)
url = urlparse.urlunparse(url_parts)
else:
url += f"{payload}"
return url
# Function to scan a given URL for XSS vulnerabilities
# Function to scan a given URL for XSS vulnerabilities
def scan_url(url, payloads, driver):
vulnerable_urls = []
for payload in payloads:
payload_url = inject_payload(url, payload)
if payload in requests.get(payload_url).text:
print(colored(f"[VULNERABLE] {payload_url}", "red"))
vulnerable_urls.append(payload_url)
else:
print(colored(f"[NOT VULNERABLE] {payload_url}", "green"))
if vulnerable_urls:
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[-1])
for vulnerable_url in vulnerable_urls:
driver.get(vulnerable_url)
return vulnerable_urls
# Function to write vulnerable URLs to a file
def write_vulnerable_urls_to_file(file_path, urls):
with open(file_path, "w") as f:
f.write("\n".join(urls))
# Main function
def main():
load_animation()
print("""
ββββββ ββββββ ββββββ ββββββ ββββββ βββ ββββ β ββββββββββββββ ββββββ βββββββββββββββ ββββββ
ββββ ββ βββ β βββββββ ββββββ β βββ β ββββ ββ ββ β βββ ββ β βββ β β βββ ββββ β βββ β βββ
βββ β βββ βββ βββββ ββββ ββββ β ββββ βββββββ ββ βββ βββ ββββ β ββββ β ββββ ββββββ βββ βββ β
ββββ βββββββββββ βββ βββ β βββ β βββββββββββ ββββββββββββ βββ β β ββββ ββββ β βββ β βββββββ
β βββββ βββββ βββββ βββββββββββββββββββββββββββββββββ ββββ βββββ ββββββββββββββββ ββββ β βββββββββββ ββββ.
β ββ β ββ ββ βββββ ββββββ β βββ β ββ βββ β βββ β ββ β β βββββ ββ ββ ββ βββ β β β ββ ββ ββ ββ ββ ββββ
β β ββ β ββ β β ββ β ββ β ββ ββ β β β ββ ββ β ββ β βββ β β ββ ββ β β β β β β ββ β ββ
β ββ β β β β β β β β β β β β β β β β β β β β β β β β β ββ β
β β β β β β β β β β β β β β β β β
β
""")
print(colored(' Coded with Love by Anmol K Sachan @Fr13ND0x7f\n','green'))
parser = argparse.ArgumentParser(description="Scan a list of URLs for XSS vulnerabilities")
parser.add_argument("-p", "--payloads", required=True, help="File containing XSS payloads")
parser.add_argument("-u", "--urls", required=True, help="File containing list of URLs")
args = parser.parse_args()
urls = get_urls_from_file(args.urls)
payloads = get_payloads_from_file(args.payloads)
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s)
affected_targets = []
for url in urls:
if not is_alive(url):
print(colored(f"[SKIPPED] {url} (host is down)", "yellow"))
continue
print(colored(f"[SCANNING] {url}", "blue"))
vulnerable_urls = scan_url(url, payloads, driver)
if vulnerable_urls:
affected_targets.append(url)
write_vulnerable_urls_to_file("affected_target_name.txt", vulnerable_urls)
if affected_targets:
print(colored("The following targets are affected:", "red"))
for target in affected_targets:
print(colored(target, "red"))
else:
print(colored("No targets were found to be vulnerable", "green"))
driver.quit()
if __name__ == "__main__":
main()