Skip to content

Commit 1835120

Browse files
committed
Update rspec for get_payload in BES
1 parent 8ce1db5 commit 1835120

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
describe Msf::Exploit::Remote::BrowserExploitServer do
55

66
subject(:server) do
7-
mod = Msf::Exploit.allocate
7+
mod = Msf::Exploit::Remote.allocate
88
mod.extend described_class
99
mod.send(:initialize, {})
1010
mod
@@ -17,6 +17,10 @@
1717
service
1818
end
1919

20+
let(:expected_user_agent) do
21+
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'
22+
end
23+
2024
let(:profile_name) do
2125
'random'
2226
end
@@ -25,26 +29,22 @@
2529
'linux'
2630
end
2731

28-
let(:expected_user_agent) do
29-
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'
30-
end
31-
3232
let(:exploit_page) do
3333
server.instance_variable_get(:@exploit_receiver_page)
3434
end
3535

3636
let(:expected_profile) do
3737
{
38-
:source=>'script',
39-
:os_name=>'Windows XP',
40-
:ua_name=>'MSIE',
41-
:ua_ver=>'8.0',
42-
:arch=>'x86',
43-
:office=>'null',
44-
:activex=>'true',
45-
:proxy=>false,
46-
:language=>'en-us',
47-
:tried=>true
38+
:source =>'script',
39+
:os_name =>'Windows XP',
40+
:ua_name =>'MSIE',
41+
:ua_ver =>'8.0',
42+
:arch =>'x86',
43+
:office =>'null',
44+
:activex =>'true',
45+
:proxy =>false,
46+
:language =>'en-us',
47+
:tried => true
4848
}
4949
end
5050

@@ -296,6 +296,43 @@
296296
server.on_request_uri(cli, request)
297297
end
298298
end
299+
300+
301+
describe '#get_payload' do
302+
let(:cli) {
303+
Rex::Socket::Tcp
304+
}
305+
306+
before(:each) do
307+
allow(cli).to receive(:peerhost).and_return('0.0.0.0')
308+
allow(cli).to receive(:peerport).and_return(4444)
309+
end
310+
311+
let(:encoded) { '@EXE@' }
312+
313+
let(:x86_payload) {
314+
double(:encoded => encoded, :arch => ['x86'])
315+
}
316+
317+
let(:x86_64_payload) {
318+
double(:encoded => encoded, :arch => ['x86_64'])
319+
}
320+
321+
context 'when the payload supports the visitor\'s browser architecture' do
322+
it 'returns a payload' do
323+
allow(server).to receive(:regenerate_payload).and_return(x86_payload)
324+
expect(server.get_payload(cli, expected_profile)).to eq(encoded)
325+
end
326+
end
327+
328+
context 'when the payload does not support the visitor\'s browser architecture' do
329+
it 'raises a BESException' do
330+
allow(server).to receive(:regenerate_payload).and_return(x86_64_payload)
331+
expect{server.get_payload(cli, expected_profile)}.to raise_error(Msf::Exploit::Remote::BrowserExploitServer::BESException)
332+
end
333+
end
334+
end
335+
299336
end
300337

301338
end

0 commit comments

Comments
 (0)