@@ -13,36 +13,82 @@ def framework
13
13
'DeferModuleLoads' => true
14
14
)
15
15
end
16
+ def active_db?
17
+ true
18
+ end
16
19
def print_good ( str = nil )
17
20
raise StandardError . new ( "This method needs to be stubbed." )
18
21
end
19
22
def store_cred ( hsh = nil )
20
23
raise StandardError . new ( "This method needs to be stubbed." )
21
24
end
22
25
def fullname
23
- "Dummy Class / Dummy Ref "
26
+ "auxiliary/scanner/snmp/cisco_dummy "
24
27
end
25
28
end
26
29
27
30
subject ( :aux_cisco ) { DummyClass . new }
28
31
32
+ context '#create_credential_and_login' do
33
+
34
+ let ( :session ) { FactoryGirl . create ( :mdm_session ) }
35
+
36
+ let ( :task ) { FactoryGirl . create ( :mdm_task , workspace : workspace ) }
37
+
38
+ let ( :user ) { FactoryGirl . create ( :mdm_user ) }
39
+
40
+ let ( :workspace ) { FactoryGirl . create ( :mdm_workspace ) }
41
+
42
+ subject ( :test_object ) { DummyClass . new }
43
+
44
+ let ( :workspace ) { FactoryGirl . create ( :mdm_workspace ) }
45
+ let ( :service ) { FactoryGirl . create ( :mdm_service , host : FactoryGirl . create ( :mdm_host , workspace : workspace ) ) }
46
+ let ( :task ) { FactoryGirl . create ( :mdm_task , workspace : workspace ) }
47
+
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
+ it 'creates a Metasploit::Credential::Login' do
66
+ expect { test_object . create_credential_and_login ( login_data ) } . to change { Metasploit ::Credential ::Login . count } . by ( 1 )
67
+ end
68
+ it "associates the Metasploit::Credential::Core with a task if passed" do
69
+ login = test_object . create_credential_and_login ( login_data . merge ( task_id : task . id ) )
70
+ expect ( login . tasks ) . to include ( task )
71
+ end
72
+ end
73
+
29
74
context '#cisco_ios_config_eater' do
30
75
31
76
it 'deals with udp ports' do
32
77
expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:161 Unencrypted Enable Password: 1511021F0725' )
33
78
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
34
79
"cisco.ios.config" , "text/plain" , "127.0.0.1" , "enable password 1511021F0725" , "config.txt" , "Cisco IOS Configuration"
35
80
)
36
- expect ( aux_cisco ) . to receive ( :store_cred ) . with (
81
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
37
82
{
38
- host : "127.0.0.1" ,
83
+ address : "127.0.0.1" ,
39
84
port : 161 ,
40
- user : "" ,
41
- pass : "1511021F0725" ,
42
- type : "password" ,
43
- collect_type : "password" ,
44
- active : true ,
45
- proto : 'udp'
85
+ protocol : "udp" ,
86
+ workspace_id : nil ,
87
+ origin_type : :service ,
88
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
89
+ private_data : "1511021F0725" ,
90
+ private_type : :password ,
91
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
46
92
}
47
93
)
48
94
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 161 , 'enable password 1511021F0725' )
@@ -58,18 +104,20 @@ def fullname
58
104
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
59
105
"cisco.ios.config" , "text/plain" , "127.0.0.1" , "enable password 0 password0" , "config.txt" , "Cisco IOS Configuration"
60
106
)
61
- expect ( aux_cisco ) . to receive ( :create_credential ) . with (
107
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
62
108
{
63
109
address : "127.0.0.1" ,
64
110
port : 1337 ,
65
111
protocol : "tcp" ,
66
112
workspace_id : nil ,
67
113
origin_type : :service ,
68
- module_fullname : "Dummy Class / Dummy Ref " ,
114
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy " ,
69
115
private_data : "password0" ,
70
- private_type : :password
116
+ private_type : :password ,
117
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
71
118
}
72
119
)
120
+
73
121
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 0 password0' )
74
122
end
75
123
@@ -86,16 +134,17 @@ def fullname
86
134
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
87
135
"cisco.ios.config" , "text/plain" , "127.0.0.1" , "enable password 7 1511021F0725" , "config.txt" , "Cisco IOS Configuration"
88
136
)
89
- expect ( aux_cisco ) . to receive ( :create_credential ) . with (
137
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
90
138
{
91
139
address : "127.0.0.1" ,
92
140
port : 1337 ,
93
141
protocol : "tcp" ,
94
142
workspace_id : nil ,
95
143
origin_type : :service ,
96
- module_fullname : "Dummy Class / Dummy Ref " ,
144
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy " ,
97
145
private_data : "cisco" ,
98
- private_type : :password
146
+ private_type : :password ,
147
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
99
148
}
100
149
)
101
150
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 7 1511021F0725' )
@@ -108,16 +157,17 @@ def fullname
108
157
expect ( aux_cisco ) . to receive ( :store_loot ) . with (
109
158
"cisco.ios.config" , "text/plain" , "127.0.0.1" , "enable password 1511021F0725" , "config.txt" , "Cisco IOS Configuration"
110
159
)
111
- expect ( aux_cisco ) . to receive ( :create_credential ) . with (
160
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
112
161
{
113
162
address : "127.0.0.1" ,
114
163
port : 1337 ,
115
164
protocol : "tcp" ,
116
165
workspace_id : nil ,
117
166
origin_type : :service ,
118
- module_fullname : "Dummy Class / Dummy Ref " ,
167
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy " ,
119
168
private_data : "1511021F0725" ,
120
- private_type : :password
169
+ private_type : :password ,
170
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
121
171
}
122
172
)
123
173
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'enable password 1511021F0725' )
@@ -127,35 +177,37 @@ def fullname
127
177
128
178
it 'with RO' do
129
179
expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:1337 SNMP Community (RO): 1511021F0725' )
130
- expect ( aux_cisco ) . to receive ( :store_cred ) . with (
180
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
131
181
{
132
- :host => "127.0.0.1" ,
133
- :port => 161 ,
134
- :user => "" ,
135
- :pass => "1511021F0725" ,
136
- :type => "password_ro" ,
137
- :collect_type => "password_ro" ,
138
- :sname => "snmp" ,
139
- :proto => "udp" ,
140
- :active => true
182
+ address : "127.0.0.1" ,
183
+ port : 161 ,
184
+ protocol : "udp" ,
185
+ workspace_id : nil ,
186
+ origin_type : :service ,
187
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
188
+ private_data : "1511021F0725" ,
189
+ private_type : :password ,
190
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED ,
191
+ access_level : 'RO'
141
192
}
142
193
)
143
194
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'snmp-server community 1511021F0725 RO' )
144
195
end
145
196
146
197
it 'with RW' do
147
198
expect ( aux_cisco ) . to receive ( :print_good ) . with ( '127.0.0.1:1337 SNMP Community (RW): 1511021F0725' )
148
- expect ( aux_cisco ) . to receive ( :store_cred ) . with (
199
+ expect ( aux_cisco ) . to receive ( :create_credential_and_login ) . with (
149
200
{
150
- :host => "127.0.0.1" ,
151
- :port => 161 ,
152
- :user => "" ,
153
- :pass => "1511021F0725" ,
154
- :type => "password" ,
155
- :collect_type => "password" ,
156
- :sname => "snmp" ,
157
- :proto => "udp" ,
158
- :active => true
201
+ address : "127.0.0.1" ,
202
+ port : 161 ,
203
+ protocol : "udp" ,
204
+ workspace_id : nil ,
205
+ origin_type : :service ,
206
+ module_fullname : "auxiliary/scanner/snmp/cisco_dummy" ,
207
+ private_data : "1511021F0725" ,
208
+ private_type : :password ,
209
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED ,
210
+ access_level : 'RW'
159
211
}
160
212
)
161
213
aux_cisco . cisco_ios_config_eater ( '127.0.0.1' , 1337 , 'snmp-server community 1511021F0725 RW' )
0 commit comments