@@ -25,10 +25,19 @@ def store_cred(hsh=nil)
25
25
def fullname
26
26
"auxiliary/scanner/snmp/cisco_dummy"
27
27
end
28
+ def myworkspace
29
+ raise StandardError . new ( "This method needs to be stubbed." )
30
+ end
28
31
end
29
32
30
33
subject ( :aux_cisco ) { DummyClass . new }
31
34
35
+ let! ( :workspace ) { FactoryGirl . create ( :mdm_workspace ) }
36
+
37
+ before ( :example ) do
38
+ expect ( aux_cisco ) . to receive ( :myworkspace ) . and_return ( workspace )
39
+ end
40
+
32
41
context '#create_credential_and_login' do
33
42
34
43
let ( :session ) { FactoryGirl . create ( :mdm_session ) }
@@ -37,31 +46,12 @@ def fullname
37
46
38
47
let ( :user ) { FactoryGirl . create ( :mdm_user ) }
39
48
40
- let ( :workspace ) { FactoryGirl . create ( :mdm_workspace ) }
41
-
42
49
subject ( :test_object ) { DummyClass . new }
43
50
44
51
let ( :workspace ) { FactoryGirl . create ( :mdm_workspace ) }
45
52
let ( :service ) { FactoryGirl . create ( :mdm_service , host : FactoryGirl . create ( :mdm_host , workspace : workspace ) ) }
46
53
let ( :task ) { FactoryGirl . create ( :mdm_task , workspace : workspace ) }
47
54
48
- let ( :login_data ) {
49
- {
50
- address : service . host . address ,
51
- port : service . port ,
52
- service_name : service . name ,
53
- protocol : service . proto ,
54
- workspace_id : workspace . id ,
55
- origin_type : :service ,
56
- module_fullname : 'auxiliary/scanner/smb/smb_login' ,
57
- realm_key : 'Active Directory Domain' ,
58
- realm_value : 'contosso' ,
59
- username : 'Username' ,
60
- private_data : 'password' ,
61
- private_type : :password ,
62
- status : Metasploit ::Model ::Login ::Status ::UNTRIED
63
- }
64
- }
65
55
it 'creates a Metasploit::Credential::Login' do
66
56
expect { test_object . create_credential_and_login ( login_data ) } . to change { Metasploit ::Credential ::Login . count } . by ( 1 )
67
57
end
@@ -83,11 +73,12 @@ def fullname
83
73
address : "127.0.0.1" ,
84
74
port : 161 ,
85
75
protocol : "udp" ,
86
- workspace_id : nil ,
76
+ workspace_id : workspace . id ,
87
77
origin_type : :service ,
78
+ service_name : '' ,
88
79
module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
89
80
private_data : "1511021F0725" ,
90
- private_type : :password ,
81
+ private_type : :nonreplayable_hash ,
91
82
status : Metasploit ::Model ::Login ::Status ::UNTRIED
92
83
}
93
84
)
@@ -97,33 +88,34 @@ def fullname
97
88
context 'Enable Password|Secret' do
98
89
99
90
it 'with password type 0' do
100
- expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:1337 Enable Password: password0 ' )
91
+ expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:1337 Enable Password: 1511021F0725 ' )
101
92
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
102
- "cisco.ios.enable_pass" , "text/plain" , "127.0.0.1" , "password0 " , "enable_password.txt" , "Cisco IOS Enable Password"
93
+ "cisco.ios.enable_pass" , "text/plain" , "127.0.0.1" , "1511021F0725 " , "enable_password.txt" , "Cisco IOS Enable Password"
103
94
)
104
95
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
105
- "cisco.ios.config" , "text/plain" , "127.0.0.1" , "enable password 0 password0 " , "config.txt" , "Cisco IOS Configuration"
96
+ "cisco.ios.config" , "text/plain" , "127.0.0.1" , "enable password 0 1511021F0725 " , "config.txt" , "Cisco IOS Configuration"
106
97
)
107
98
expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
108
99
{
109
100
address : "127.0.0.1" ,
110
101
port : 1337 ,
111
102
protocol : "tcp" ,
112
- workspace_id : nil ,
103
+ workspace_id : workspace . id ,
113
104
origin_type : :service ,
105
+ service_name : '' ,
114
106
module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
115
- private_data : "password0 " ,
116
- private_type : :password ,
107
+ private_data : "1511021F0725 " ,
108
+ private_type : :nonreplayable_hash ,
117
109
status : Metasploit ::Model ::Login ::Status ::UNTRIED
118
110
}
119
111
)
120
112
121
- aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 0 password0 ' )
113
+ aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 0 1511021F0725 ' )
122
114
end
123
115
124
116
it 'with password type 5' do
125
- expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:1337 MD5 Encrypted Enable Password: somehashlikestring ' )
126
- aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 5 somehashlikestring ' )
117
+ expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:1337 MD5 Encrypted Enable Password: 1511021F0725 ' )
118
+ aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 5 1511021F0725 ' )
127
119
end
128
120
129
121
it 'with password type 7' do
@@ -139,8 +131,9 @@ def fullname
139
131
address : "127.0.0.1" ,
140
132
port : 1337 ,
141
133
protocol : "tcp" ,
142
- workspace_id : nil ,
134
+ workspace_id : workspace . id ,
143
135
origin_type : :service ,
136
+ service_name : '' ,
144
137
module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
145
138
private_data : "cisco" ,
146
139
private_type : :password ,
@@ -162,7 +155,7 @@ def fullname
162
155
address : "127.0.0.1" ,
163
156
port : 1337 ,
164
157
protocol : "tcp" ,
165
- workspace_id : nil ,
158
+ workspace_id : workspace . id ,
166
159
origin_type : :service ,
167
160
module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
168
161
private_data : "1511021F0725" ,
@@ -182,7 +175,7 @@ def fullname
182
175
address : "127.0.0.1" ,
183
176
port : 161 ,
184
177
protocol : "udp" ,
185
- workspace_id : nil ,
178
+ workspace_id : workspace . id ,
186
179
origin_type : :service ,
187
180
module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
188
181
private_data : "1511021F0725" ,
@@ -201,7 +194,7 @@ def fullname
201
194
address : "127.0.0.1" ,
202
195
port : 161 ,
203
196
protocol : "udp" ,
204
- workspace_id : nil ,
197
+ workspace_id : workspace . id ,
205
198
origin_type : :service ,
206
199
module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
207
200
private_data : "1511021F0725" ,
@@ -220,15 +213,28 @@ def fullname
220
213
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
221
214
"cisco.ios.config" , "text/plain" , "127.0.0.1" , "password 7 1511021F0725" , "config.txt" , "Cisco IOS Configuration"
222
215
)
223
- expect ( aux_cisco ) . to receive ( :store_cred ) . with (
216
+ # expect(aux_cisco).to receive(:store_cred).with(
217
+ # {
218
+ # host: "127.0.0.1",
219
+ # port: 1337,
220
+ # user: "",
221
+ # pass: "cisco",
222
+ # type: "password",
223
+ # collect_type: "password",
224
+ # active: true
225
+ # }
226
+ # )
227
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
224
228
{
225
- host : "127.0.0.1" ,
229
+ address : "127.0.0.1" ,
226
230
port : 1337 ,
227
- user : "" ,
228
- pass : "cisco" ,
229
- type : "password" ,
230
- collect_type : "password" ,
231
- active : true
231
+ protocol : "tcp" ,
232
+ workspace_id : workspace . id ,
233
+ origin_type : :service ,
234
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
235
+ private_data : "1511021F0725" ,
236
+ private_type : :password ,
237
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
232
238
}
233
239
)
234
240
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'password 7 1511021F0725' )
0 commit comments