Skip to content

Commit c2a6923

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents a5eb61c + d1e1968 commit c2a6923

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
# Exploit mixins should be called first
11+
include Msf::Exploit::Remote::SMB
12+
include Msf::Exploit::Remote::SMB::Authenticated
13+
include Msf::Auxiliary::Report
14+
15+
# Aliases for common classes
16+
SIMPLE = Rex::Proto::SMB::SimpleClient
17+
XCEPT = Rex::Proto::SMB::Exceptions
18+
CONST = Rex::Proto::SMB::Constants
19+
20+
21+
def initialize
22+
super(
23+
'Name' => 'SMB File Delete Utility',
24+
'Description' => %Q{
25+
This module deletes a file from a target share and path. The only reason
26+
to use this module is if your existing SMB client is not able to support the features
27+
of the Metasploit Framework that you need, like pass-the-hash authentication.
28+
},
29+
'Author' =>
30+
[
31+
'mubix' # copied from hdm upload_file module
32+
],
33+
'References' =>
34+
[
35+
],
36+
'License' => MSF_LICENSE
37+
)
38+
39+
register_options([
40+
OptString.new('SMBSHARE', [true, 'The name of a share on the RHOST', 'C$']),
41+
OptString.new('RPATH', [true, 'The name of the remote file relative to the share'])
42+
], self.class)
43+
end
44+
45+
def smb_delete_file
46+
print_status("Connecting to the server...")
47+
connect()
48+
smb_login()
49+
50+
print_status("Mounting the remote share \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}'...")
51+
self.simple.connect("\\\\#{rhost}\\#{datastore['SMBSHARE']}")
52+
53+
simple.delete("\\#{datastore['RPATH']}")
54+
55+
# If there's no exception raised at this point, we assume the file has been removed.
56+
print_status("File deleted: #{datastore['RPATH']}...")
57+
end
58+
59+
def run
60+
begin
61+
smb_delete_file
62+
rescue Rex::Proto::SMB::Exceptions::LoginError => e
63+
print_error("Unable to login: #{e.message}")
64+
rescue Rex::Proto::SMB::Exceptions::ErrorCode => e
65+
print_error("Cannot delete the file: #{e.message}")
66+
end
67+
end
68+
69+
end
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
# Exploit mixins should be called first
11+
include Msf::Exploit::Remote::SMB
12+
include Msf::Exploit::Remote::SMB::Authenticated
13+
include Msf::Auxiliary::Report
14+
15+
# Aliases for common classes
16+
SIMPLE = Rex::Proto::SMB::SimpleClient
17+
XCEPT = Rex::Proto::SMB::Exceptions
18+
CONST = Rex::Proto::SMB::Constants
19+
20+
21+
def initialize
22+
super(
23+
'Name' => 'SMB File Download Utility',
24+
'Description' => %Q{
25+
This module downloads a file from a target share and path. The only reason
26+
to use this module is if your existing SMB client is not able to support the features
27+
of the Metasploit Framework that you need, like pass-the-hash authentication.
28+
},
29+
'Author' =>
30+
[
31+
'mubix' # copied from hdm upload_file module
32+
],
33+
'References' =>
34+
[
35+
],
36+
'License' => MSF_LICENSE
37+
)
38+
39+
register_options([
40+
OptString.new('SMBSHARE', [true, 'The name of a share on the RHOST', 'C$']),
41+
OptString.new('RPATH', [true, 'The name of the remote file relative to the share'])
42+
], self.class)
43+
44+
end
45+
46+
def smb_download
47+
print_status("Connecting to the #{rhost}:#{rport}...")
48+
connect()
49+
smb_login()
50+
51+
print_status("Mounting the remote share \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}'...")
52+
self.simple.connect("\\\\#{rhost}\\#{datastore['SMBSHARE']}")
53+
54+
print_status("Trying to download #{datastore['RPATH']}...")
55+
56+
data = ''
57+
fd = simple.open("\\#{datastore['RPATH']}", 'ro')
58+
begin
59+
data = fd.read
60+
ensure
61+
fd.close
62+
end
63+
64+
fname = datastore['RPATH'].split("\\")[-1]
65+
path = store_loot("smb.shares.file", "application/octet-stream", rhost, data, fname)
66+
print_good("#{fname} saved as: #{path}")
67+
end
68+
69+
def run
70+
begin
71+
smb_download
72+
rescue Rex::Proto::SMB::Exceptions::LoginError => e
73+
print_error("Unable to login: #{e.message}")
74+
rescue Rex::Proto::SMB::Exceptions::ErrorCode => e
75+
print_error("Unable to download the file: #{e.message}")
76+
end
77+
end
78+
79+
end

0 commit comments

Comments
 (0)