/
framework.rb
44 lines (36 loc) · 1.12 KB
/
framework.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding:binary -*-
require 'msf/base/simple/framework'
require 'metasploit/framework'
shared_context 'Msf::Simple::Framework' do
let(:dummy_pathname) do
Metasploit::Framework.root.join('spec', 'dummy')
end
let(:framework) do
Msf::Simple::Framework.create(
'ConfigDirectory' => framework_config_pathname.to_s,
# don't load any module paths so we can just load the module under test and save time
'DeferModuleLoads' => true
)
end
let(:framework_config_pathname) do
dummy_pathname.join('framework', 'config')
end
before(:each) do
framework_config_pathname.mkpath
end
after(:each) do
dummy_pathname.rmtree
end
after(:each) do
# explicitly kill threads so that they don't exhaust connection pool
thread_manager = framework.threads
thread_manager.each do |thread|
thread.kill
# join after kill to ensure kill completed and thread is removed form Thread.list
thread.join
end
thread_manager.monitor.kill
# join after kill to ensure kill completed and thread is removed form Thread.list
thread_manager.monitor.join
end
end