|
14 | 14 | mod
|
15 | 15 | end
|
16 | 16 |
|
| 17 | + let(:mlet_name) do |
| 18 | + 'DefaultDomain:type=MLet' |
| 19 | + end |
| 20 | + |
17 | 21 | let(:default_get_object_instance) do
|
18 | 22 | "\x50\xac\xed\x00\x05\x77\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
|
19 | 23 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff" +
|
20 | 24 | "\xff\xf0\xe0\x74\xea\xad\x0c\xae\xa8\x70"
|
21 | 25 | end
|
22 | 26 |
|
23 |
| - let(:mlet_name) do |
24 |
| - 'DefaultDomain:type=MLet' |
25 |
| - end |
26 |
| - |
27 | 27 | let(:mlet_get_object_instance) do
|
28 | 28 | "\x50\xac\xed\x00\x05\x77\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
|
29 | 29 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff" +
|
30 | 30 | "\xff\xf0\xe0\x74\xea\xad\x0c\xae\xa8\x70"
|
31 | 31 | end
|
32 | 32 |
|
| 33 | + let(:mbean_name) do |
| 34 | + 'javax.management.loading.MLet' |
| 35 | + end |
| 36 | + |
| 37 | + let(:default_create_mbean) do |
| 38 | + "\x50\xac\xed\x00\x05\x77\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00" + |
| 39 | + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff" + |
| 40 | + "\xff\x22\xd7\xfd\x4a\x90\x6a\xc8\xe6\x74\x00\x00\x70\x70" |
| 41 | + end |
| 42 | + |
| 43 | + let(:mlet_create_mbean) do |
| 44 | + "\x50\xac\xed\x00\x05\x77\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00" + |
| 45 | + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff" + |
| 46 | + "\xff\x22\xd7\xfd\x4a\x90\x6a\xc8\xe6\x74\x00\x1d\x6a\x61\x76\x61" + |
| 47 | + "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6c\x6f\x61" + |
| 48 | + "\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x70\x70" |
| 49 | + end |
| 50 | + |
| 51 | + let(:invoke_opts) do |
| 52 | + { |
| 53 | + object: 'DefaultDomain:type=MLet', |
| 54 | + method: 'getMBeansFromURL', |
| 55 | + args: { 'java.lang.String' => "http://127.0.0.1/mlet" } |
| 56 | + } |
| 57 | + end |
| 58 | + |
| 59 | + let(:default_invoke) do |
| 60 | + "\x50\xac\xed\x00\x05\x77\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00" + |
| 61 | + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff" + |
| 62 | + "\xff\x13\xe7\xd6\x94\x17\xe5\xda\x20\x73\x72\x00\x1b\x6a\x61\x76" + |
| 63 | + "\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62" + |
| 64 | + "\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf" + |
| 65 | + "\x03\x00\x00\x70\x78\x70\x74\x00\x00\x78\x74\x00\x00\x73\x72\x00" + |
| 66 | + "\x19\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x4d\x61\x72\x73\x68\x61" + |
| 67 | + "\x6c\x6c\x65\x64\x4f\x62\x6a\x65\x63\x74\x7c\xbd\x1e\x97\xed\x63" + |
| 68 | + "\xfc\x3e\x02\x00\x03\x49\x00\x04\x68\x61\x73\x68\x5b\x00\x08\x6c" + |
| 69 | + "\x6f\x63\x42\x79\x74\x65\x73\x74\x00\x02\x5b\x42\x5b\x00\x08\x6f" + |
| 70 | + "\x62\x6a\x42\x79\x74\x65\x73\x74\x00\x02\x5b\x42\x70\x78\x70\x72" + |
| 71 | + "\x69\x21\xc6\x70\x75\x72\x00\x02\x5b\x42\xac\xf3\x17\xf8\x06\x08" + |
| 72 | + "\x54\xe0\x02\x00\x00\x70\x78\x70\x00\x00\x00\x2c\xac\xed\x00\x05" + |
| 73 | + "\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e" + |
| 74 | + "\x4f\x62\x6a\x65\x63\x74\x3b\x90\xce\x58\x9f\x10\x73\x29\x6c\x02" + |
| 75 | + "\x00\x00\x78\x70\x00\x00\x00\x00\x75\x72\x00\x13\x5b\x4c\x6a\x61" + |
| 76 | + "\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad" + |
| 77 | + "\xd2\x56\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00" + |
| 78 | + "\x00\x70" |
| 79 | + end |
| 80 | + |
| 81 | + let(:invoke_with_data) do |
| 82 | + "\x50\xac\xed\x00\x05\x77\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00" + |
| 83 | + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff" + |
| 84 | + "\xff\x22\xd7\xfd\x4a\x90\x6a\xc8\xe6\x74\x00\x00\x70\x70" |
| 85 | + end |
| 86 | + |
33 | 87 | describe "#build_jmx_get_object_instance" do
|
34 | 88 | context "when no opts" do
|
35 | 89 | it "creates a Rex::Proto::Rmi::Model::Call" do
|
|
46 | 100 | expect(mod.build_jmx_new_client(name: mlet_name)).to be_a(Rex::Proto::Rmi::Model::Call)
|
47 | 101 | end
|
48 | 102 |
|
49 |
| - it "creates a newClient Call with credentials" do |
| 103 | + it "creates a getObjectInstance Call with credentials" do |
50 | 104 | expect(mod.build_jmx_new_client(name: mlet_name).encode).to eq(mlet_get_object_instance)
|
51 | 105 | end
|
52 | 106 | end
|
|
65 | 119 | expect(mod.build_jmx_get_object_instance_args(mlet_name)[1].contents).to eq(mlet_name)
|
66 | 120 | end
|
67 | 121 | end
|
| 122 | + |
| 123 | + describe "#build_jmx_create_mbean" do |
| 124 | + context "when no opts" do |
| 125 | + it "creates a Rex::Proto::Rmi::Model::Call" do |
| 126 | + expect(mod.build_jmx_create_mbean).to be_a(Rex::Proto::Rmi::Model::Call) |
| 127 | + end |
| 128 | + |
| 129 | + it "creates a createMBean call for an empty object name" do |
| 130 | + expect(mod.build_jmx_create_mbean.encode).to eq(default_create_mbean) |
| 131 | + end |
| 132 | + end |
| 133 | + |
| 134 | + context "when opts with class name" do |
| 135 | + it "creates a Rex::Proto::Rmi::Model::Call" do |
| 136 | + expect(mod.build_jmx_create_mbean(name: mbean_name)).to be_a(Rex::Proto::Rmi::Model::Call) |
| 137 | + end |
| 138 | + |
| 139 | + it "creates a createMBean Call with credentials" do |
| 140 | + expect(mod.build_jmx_create_mbean(name: mbean_name).encode).to eq(mlet_create_mbean) |
| 141 | + end |
| 142 | + end |
| 143 | + end |
| 144 | + |
| 145 | + describe "#build_jmx_create_mbean_args" do |
| 146 | + it "return an Array" do |
| 147 | + expect(mod.build_jmx_create_mbean_args(mbean_name)).to be_an(Array) |
| 148 | + end |
| 149 | + |
| 150 | + it "returns an Array with 3 elements" do |
| 151 | + expect(mod.build_jmx_create_mbean_args(mbean_name).length).to eq(3) |
| 152 | + end |
| 153 | + |
| 154 | + it "returns an Array whose first element is an utf string with the object name" do |
| 155 | + expect(mod.build_jmx_create_mbean_args(mbean_name)[0].contents).to eq(mbean_name) |
| 156 | + end |
| 157 | + end |
| 158 | + |
| 159 | + |
| 160 | + describe "#build_jmx_invoke" do |
| 161 | + context "when no opts" do |
| 162 | + it "creates a Rex::Proto::Rmi::Model::Call" do |
| 163 | + expect(mod.build_jmx_invoke).to be_a(Rex::Proto::Rmi::Model::Call) |
| 164 | + end |
| 165 | + |
| 166 | + it "creates a default invoke" do |
| 167 | + expect(mod.build_jmx_invoke.encode).to eq(default_invoke) |
| 168 | + end |
| 169 | + end |
| 170 | + |
| 171 | + context "when opts with class name" do |
| 172 | + it "creates a Rex::Proto::Rmi::Model::Call" do |
| 173 | + expect(mod.build_jmx_create_mbean(invoke_opts)).to be_a(Rex::Proto::Rmi::Model::Call) |
| 174 | + end |
| 175 | + |
| 176 | + it "creates a invoke call with the opts data" do |
| 177 | + expect(mod.build_jmx_create_mbean(invoke_opts).encode).to eq(invoke_with_data) |
| 178 | + end |
| 179 | + end |
| 180 | + end |
| 181 | + |
| 182 | + describe "#build_jmx_invoke_args" do |
| 183 | + it "return an Array" do |
| 184 | + expect(mod.build_jmx_invoke_args(invoke_opts)).to be_an(Array) |
| 185 | + end |
| 186 | + |
| 187 | + it "returns an Array with 7 elements" do |
| 188 | + expect(mod.build_jmx_invoke_args(invoke_opts).length).to eq(7) |
| 189 | + end |
| 190 | + |
| 191 | + it "returns an Array whose second element is an utf string with the object name" do |
| 192 | + expect(mod.build_jmx_invoke_args(invoke_opts)[1].contents).to eq(mlet_name) |
| 193 | + end |
| 194 | + |
| 195 | + it "returns an Array whose third element is an utf string with the method name" do |
| 196 | + expect(mod.build_jmx_invoke_args(invoke_opts)[3].contents).to eq('getMBeansFromURL') |
| 197 | + end |
| 198 | + end |
| 199 | + |
| 200 | + describe "#build_invoke_arguments_obj_bytes" do |
| 201 | + it "return an Rex::Java::Serialization::Model::Stream" do |
| 202 | + expect(mod.build_invoke_arguments_obj_bytes(invoke_opts[:args])).to be_a(Rex::Java::Serialization::Model::Stream) |
| 203 | + end |
| 204 | + |
| 205 | + it "returns an stream with one content" do |
| 206 | + expect(mod.build_invoke_arguments_obj_bytes(invoke_opts[:args]).contents.length).to eq(1) |
| 207 | + end |
| 208 | + |
| 209 | + it "returns an stream with NewArray" do |
| 210 | + expect(mod.build_invoke_arguments_obj_bytes(invoke_opts[:args]).contents[0]).to be_a(Rex::Java::Serialization::Model::NewArray) |
| 211 | + end |
| 212 | + end |
| 213 | + |
| 214 | + |
68 | 215 | end
|
69 | 216 |
|
0 commit comments