Skip to content

Commit b66621a

Browse files
committed
adding in a blank service_name
fixing myworkspace
1 parent 219f9d5 commit b66621a

File tree

2 files changed

+66
-55
lines changed

2 files changed

+66
-55
lines changed

lib/msf/core/auxiliary/cisco.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ def cisco_ios_config_eater(thost, tport, config)
7676
address: thost,
7777
port: tport,
7878
protocol: 'tcp',
79-
workspace_id: myworkspace_id,
79+
workspace_id: myworkspace.id,
8080
origin_type: :service,
81+
service_name: '',
8182
module_fullname: self.fullname,
8283
status: Metasploit::Model::Login::Status::UNTRIED
8384
}
@@ -103,6 +104,10 @@ def cisco_ios_config_eater(thost, tport, config)
103104
if stype == 5
104105
print_good("#{thost}:#{tport} MD5 Encrypted Enable Password: #{shash}")
105106
store_loot("cisco.ios.enable_hash", "text/plain", thost, shash, "enable_password_hash.txt", "Cisco IOS Enable Password Hash (MD5)")
107+
cred = credential_data.dup
108+
cred[:private_data] = shash
109+
cred[:private_type] = :nonreplayable_hash
110+
create_credential_and_login(cred)
106111
end
107112

108113
if stype == 0
@@ -111,7 +116,7 @@ def cisco_ios_config_eater(thost, tport, config)
111116

112117
cred = credential_data.dup
113118
cred[:private_data] = shash
114-
cred[:private_type] = :password
119+
cred[:private_type] = :nonreplayable_hash
115120
create_credential_and_login(cred)
116121

117122
end
@@ -133,7 +138,7 @@ def cisco_ios_config_eater(thost, tport, config)
133138

134139
cred = credential_data.dup
135140
cred[:private_data] = spass
136-
cred[:private_type] = :password
141+
cred[:private_type] = :nonreplayable_hash
137142
create_credential_and_login(cred)
138143

139144
#
@@ -163,12 +168,12 @@ def cisco_ios_config_eater(thost, tport, config)
163168
spass = cisco_ios_decrypt7(spass) rescue spass
164169

165170
print_good("#{thost}:#{tport} Decrypted VTY Password: #{spass}")
166-
cred = cred_info.dup
167-
168-
cred[:pass] = spass
169-
cred[:type] = "password"
170-
cred[:collect_type] = "password"
171-
store_cred(cred)
171+
172+
cred = credential_data.dup
173+
cred[:private_data] = spass
174+
cred[:private_type] = :password
175+
create_credential_and_login(cred)
176+
172177

173178
when /^\s*(password|secret) 5 (.*)/i
174179
shash = $1.strip
@@ -178,11 +183,11 @@ def cisco_ios_config_eater(thost, tport, config)
178183
when /^\s*password (0 |)([^\s]+)/i
179184
spass = $2.strip
180185
print_good("#{thost}:#{tport} Unencrypted VTY Password: #{spass}")
181-
cred = cred_info.dup
182-
cred[:pass] = spass
183-
cred[:type] = "password"
184-
cred[:collect_type] = "password"
185-
store_cred(cred)
186+
187+
cred = credential_data.dup
188+
cred[:private_data] = spass
189+
cred[:private_type] = :nonreplayable_hash
190+
create_credential_and_login(cred)
186191

187192
#
188193
# WiFi Passwords

spec/lib/msf/core/auxiliary/cisco_spec.rb

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,19 @@ def store_cred(hsh=nil)
2525
def fullname
2626
"auxiliary/scanner/snmp/cisco_dummy"
2727
end
28+
def myworkspace
29+
raise StandardError.new("This method needs to be stubbed.")
30+
end
2831
end
2932

3033
subject(:aux_cisco) { DummyClass.new }
3134

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+
3241
context '#create_credential_and_login' do
3342

3443
let(:session) { FactoryGirl.create(:mdm_session) }
@@ -37,31 +46,12 @@ def fullname
3746

3847
let(:user) { FactoryGirl.create(:mdm_user)}
3948

40-
let(:workspace) { FactoryGirl.create(:mdm_workspace) }
41-
4249
subject(:test_object) { DummyClass.new }
4350

4451
let(:workspace) { FactoryGirl.create(:mdm_workspace) }
4552
let(:service) { FactoryGirl.create(:mdm_service, host: FactoryGirl.create(:mdm_host, workspace: workspace)) }
4653
let(:task) { FactoryGirl.create(:mdm_task, workspace: workspace) }
4754

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-
}
6555
it 'creates a Metasploit::Credential::Login' do
6656
expect{test_object.create_credential_and_login(login_data)}.to change{Metasploit::Credential::Login.count}.by(1)
6757
end
@@ -83,11 +73,12 @@ def fullname
8373
address: "127.0.0.1",
8474
port: 161,
8575
protocol: "udp",
86-
workspace_id: nil,
76+
workspace_id: workspace.id,
8777
origin_type: :service,
78+
service_name: '',
8879
module_fullname: "auxiliary/scanner/snmp/cisco_dummy",
8980
private_data: "1511021F0725",
90-
private_type: :password,
81+
private_type: :nonreplayable_hash,
9182
status: Metasploit::Model::Login::Status::UNTRIED
9283
}
9384
)
@@ -97,33 +88,34 @@ def fullname
9788
context 'Enable Password|Secret' do
9889

9990
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')
10192
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"
10394
)
10495
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"
10697
)
10798
expect(aux_cisco).to receive(:create_credential_and_login).with(
10899
{
109100
address: "127.0.0.1",
110101
port: 1337,
111102
protocol: "tcp",
112-
workspace_id: nil,
103+
workspace_id: workspace.id,
113104
origin_type: :service,
105+
service_name: '',
114106
module_fullname: "auxiliary/scanner/snmp/cisco_dummy",
115-
private_data: "password0",
116-
private_type: :password,
107+
private_data: "1511021F0725",
108+
private_type: :nonreplayable_hash,
117109
status: Metasploit::Model::Login::Status::UNTRIED
118110
}
119111
)
120112

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')
122114
end
123115

124116
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')
127119
end
128120

129121
it 'with password type 7' do
@@ -139,8 +131,9 @@ def fullname
139131
address: "127.0.0.1",
140132
port: 1337,
141133
protocol: "tcp",
142-
workspace_id: nil,
134+
workspace_id: workspace.id,
143135
origin_type: :service,
136+
service_name: '',
144137
module_fullname: "auxiliary/scanner/snmp/cisco_dummy",
145138
private_data: "cisco",
146139
private_type: :password,
@@ -162,7 +155,7 @@ def fullname
162155
address: "127.0.0.1",
163156
port: 1337,
164157
protocol: "tcp",
165-
workspace_id: nil,
158+
workspace_id: workspace.id,
166159
origin_type: :service,
167160
module_fullname: "auxiliary/scanner/snmp/cisco_dummy",
168161
private_data: "1511021F0725",
@@ -182,7 +175,7 @@ def fullname
182175
address: "127.0.0.1",
183176
port: 161,
184177
protocol: "udp",
185-
workspace_id: nil,
178+
workspace_id: workspace.id,
186179
origin_type: :service,
187180
module_fullname: "auxiliary/scanner/snmp/cisco_dummy",
188181
private_data: "1511021F0725",
@@ -201,7 +194,7 @@ def fullname
201194
address: "127.0.0.1",
202195
port: 161,
203196
protocol: "udp",
204-
workspace_id: nil,
197+
workspace_id: workspace.id,
205198
origin_type: :service,
206199
module_fullname: "auxiliary/scanner/snmp/cisco_dummy",
207200
private_data: "1511021F0725",
@@ -220,15 +213,28 @@ def fullname
220213
expect(aux_cisco).to receive(:store_loot).with(
221214
"cisco.ios.config", "text/plain", "127.0.0.1", "password 7 1511021F0725", "config.txt", "Cisco IOS Configuration"
222215
)
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(
224228
{
225-
host: "127.0.0.1",
229+
address: "127.0.0.1",
226230
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
232238
}
233239
)
234240
aux_cisco.cisco_ios_config_eater('127.0.0.1',1337,'password 7 1511021F0725')

0 commit comments

Comments
 (0)