5
5
require 'rex/proto/rmi'
6
6
require 'msf/java/rmi/client'
7
7
8
- class RmiStringIO < StringIO
9
-
10
- def put ( data )
11
- write ( data )
12
- end
13
-
14
- def get_once ( length = -1 , timeout = 10 )
15
- read
16
- end
17
- end
18
-
19
8
describe Msf ::Java ::Rmi ::Client do
20
9
subject ( :mod ) do
21
10
mod = ::Msf ::Exploit . new
@@ -24,11 +13,11 @@ def get_once(length = -1, timeout = 10)
24
13
mod
25
14
end
26
15
27
- let ( :io ) { RmiStringIO . new ( '' , 'w+b' ) }
16
+ let ( :io ) { StringIO . new ( '' , 'w+b' ) }
28
17
let ( :protocol_not_supported ) { "\x4f " }
29
- let ( :protocol_not_supported_io ) { RmiStringIO . new ( protocol_not_supported ) }
18
+ let ( :protocol_not_supported_io ) { StringIO . new ( protocol_not_supported ) }
30
19
let ( :protocol_ack ) { "\x4e \x00 \x0e \x31 \x37 \x32 \x2e \x31 \x36 \x2e \x31 \x35 \x38 \x2e \x31 \x33 \x32 \x00 \x00 \x06 \xea " }
31
- let ( :protocol_ack_io ) { RmiStringIO . new ( protocol_ack ) }
20
+ let ( :protocol_ack_io ) { StringIO . new ( protocol_ack ) }
32
21
let ( :return_data ) do
33
22
"\x51 \xac \xed \x00 \x05 \x77 \x0f \x01 \xd2 \x4f \xdf \x47 \x00 \x00 \x01 \x49 " +
34
23
"\xb5 \xe4 \x92 \x78 \x80 \x15 \x73 \x72 \x00 \x12 \x6a \x61 \x76 \x61 \x2e \x72 " +
@@ -49,7 +38,17 @@ def get_once(length = -1, timeout = 10)
49
38
"\x04 \x74 \x69 \x6d \x65 \x49 \x00 \x06 \x75 \x6e \x69 \x71 \x75 \x65 \x70 \x78 " +
50
39
"\x70 \x80 \x01 \x00 \x00 \x01 \x49 \xb5 \xf8 \x00 \xea \xe9 \x62 \xc1 \xc0 "
51
40
end
52
- let ( :return_io ) { RmiStringIO . new ( return_data ) }
41
+ let ( :return_io ) { StringIO . new ( return_data ) }
42
+
43
+ before ( :each ) do
44
+ allow_any_instance_of ( ::StringIO ) . to receive ( :put ) do |io , data |
45
+ io . write ( data )
46
+ end
47
+
48
+ allow_any_instance_of ( ::StringIO ) . to receive ( :get_once ) do |io , length , timeout |
49
+ io . read
50
+ end
51
+ end
53
52
54
53
describe "#send_header" do
55
54
it "returns the number of bytes sent" do
0 commit comments