Skip to content

Commit 356e8c7

Browse files
committed
Add specs for Msf::Java::Rmi::Client::Jmx::Server
1 parent 464a6df commit 356e8c7

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

modules/exploits/multi/misc/java_jmx_server.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def initialize(info = {})
5151
))
5252

5353
register_options([
54-
Opt::RPORT(1617),
5554
Msf::OptString.new('JMX_ROLE', [false, 'The role to interact with an authenticated JMX endpoint']),
5655
Msf::OptString.new('JMX_PASSWORD', [false, 'The password to interact with an authenticated JMX endpoint']),
5756
Msf::OptString.new('JMXRMI', [true, 'The name where the JMX RMI interface is bound', 'jmxrmi'])
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding:binary -*-
2+
require 'spec_helper'
3+
4+
require 'rex/java/serialization'
5+
require 'rex/proto/rmi'
6+
require 'msf/java/rmi/client'
7+
require 'stringio'
8+
9+
describe Msf::Java::Rmi::Client::Jmx::Server do
10+
11+
let(:new_client_response) do
12+
"\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" +
13+
"\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" +
14+
"\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" +
15+
"\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" +
16+
"\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" +
17+
"\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" +
18+
"\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" +
19+
"\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" +
20+
"\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" +
21+
"\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" +
22+
"\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" +
23+
"\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" +
24+
"\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" +
25+
"\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" +
26+
"\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78"
27+
end
28+
29+
let(:remote_address) do
30+
'172.16.158.132'
31+
end
32+
33+
subject(:mod) do
34+
mod = ::Msf::Exploit.new
35+
mod.extend ::Msf::Java::Rmi::Client
36+
mod.send(:initialize)
37+
mod
38+
end
39+
40+
let(:io) { StringIO.new('', 'w+b') }
41+
42+
describe "#send_new_client" do
43+
context "when there is an RMIServerImpl_Stub interface" do
44+
before(:each) do
45+
allow_any_instance_of(::StringIO).to receive(:put) do |io, data|
46+
io.seek(0)
47+
io.write(new_client_response)
48+
io.seek(0)
49+
end
50+
51+
allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout|
52+
io.read
53+
end
54+
end
55+
56+
it "returns the reference information" do
57+
expect(mod.send_new_client(sock: io)[:address]).to eq(remote_address)
58+
end
59+
end
60+
end
61+
62+
end
63+

0 commit comments

Comments
 (0)