Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 197 lines (160 sloc) 5.23 kb
06899ca Wade Alcorn Year updated from 2011 to 2012
wadealcorn authored
1 #
2 # Copyright 2012 Wade Alcorn wade@bindshell.net
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
16
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
17 task :default => ["quick"]
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
18
7bdfcb3 Wade Alcorn Tidy up the Rakefile
wadealcorn authored
19 desc "Run quick tests"
cd99ea5 Wade Alcorn By default quick test are now run
wadealcorn authored
20 task :quick do
7bdfcb3 Wade Alcorn Tidy up the Rakefile
wadealcorn authored
21 Rake::Task['unit'].invoke # run unit tests
6132b2a The first basic unit tests added to the framework. To exec simply run 'r...
wade@bindshell.net authored
22 end
23
2a4e95f Wade Alcorn Attempted git confict fix
wadealcorn authored
24 desc "Run all tests"
5cf11d2 Wade Alcorn Removed redundant dependencies
wadealcorn authored
25 task :all do
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
26 Rake::Task['integration'].invoke # run integration tests
27 Rake::Task['unit'].invoke # run unit tests
d103d2a Wade Alcorn MSF start wait time increased to 45 secs from 30 secs
wadealcorn authored
28 Rake::Task['msf'].invoke # run msf tests
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
29 end
30
567087c Wade Alcorn Added automated testing task
wadealcorn authored
31 desc "Run automated tests (for Jenkins)"
32 task :automated do
ee24d44 Wade Alcorn Added xserver start and stop task for use in automated testing
wadealcorn authored
33 Rake::Task['xserver_start'].invoke
7bdfcb3 Wade Alcorn Tidy up the Rakefile
wadealcorn authored
34 Rake::Task['all'].invoke
ee24d44 Wade Alcorn Added xserver start and stop task for use in automated testing
wadealcorn authored
35 Rake::Task['xserver_stop'].invoke
567087c Wade Alcorn Added automated testing task
wadealcorn authored
36 end
37
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
38 desc "Run integration unit tests"
39 task :integration => ["install"] do
5a83e1f Wade Alcorn Added start and stop beef tasks to the rake tests
wadealcorn authored
40 Rake::Task['beef_start'].invoke
66a3c77 Wade Alcorn Added export display for headless testing
wadealcorn authored
41 sh "export DISPLAY=:0; cd test/integration;ruby -W0 ts_integration.rb"
5a83e1f Wade Alcorn Added start and stop beef tasks to the rake tests
wadealcorn authored
42 Rake::Task['beef_stop'].invoke
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
43 end
44
45 desc "Run integration unit tests"
46 task :unit => ["install"] do
47 sh "cd test/unit;ruby -W0 ts_unit.rb"
ae02fcf Wade Alcorn Added bundle install task.
wadealcorn authored
48 end
49
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
50 desc "Run MSF unit tests"
51 task :msf => ["install", "msf_install"] do
52 Rake::Task['msf_update'].invoke
53 Rake::Task['msf_start'].invoke
54 sh "cd test/thirdparty/msf/unit/;ruby -W0 ts_metasploit.rb"
55 Rake::Task['msf_stop'].invoke
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
56 end
57
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
58 task :install do
52d06e4 Removed the dev/null output in the Rake Install task Issue #629
Christian Frichot authored
59 sh "export BEEF_TEST=true;bundle install"
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
60 end
61
62 ################################
ee24d44 Wade Alcorn Added xserver start and stop task for use in automated testing
wadealcorn authored
63 # X11 set up
64
65 @xserver_process_id = nil;
66
67 task :xserver_start do
68 printf "Starting X11 Server (wait 10 seconds)..."
69 @xserver_process_id = IO.popen("/usr/bin/Xvfb :0 -screen 0 1024x768x24 2> /dev/null", "w+")
70 delays = [2, 2, 1, 1, 1, 0.5, 0.5 , 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05]
71 delays.each do |i| # delay for 10 seconds
72 printf '.'
73 sleep (i) # increase the . display rate
74 end
75 puts '.'
76 end
77
78 task :xserver_stop do
79 puts "\nShutting down X11 Server...\n"
7bdfcb3 Wade Alcorn Tidy up the Rakefile
wadealcorn authored
80 sh "ps -ef|grep Xvfb|grep -v grep|awk '{print $2}'|xargs kill"
ee24d44 Wade Alcorn Added xserver start and stop task for use in automated testing
wadealcorn authored
81 end
82
83 ################################
5a83e1f Wade Alcorn Added start and stop beef tasks to the rake tests
wadealcorn authored
84 # BeEF environment set up
85
86 @beef_process_id = nil;
87
88 task :beef_start => 'beef' do
89 printf "Starting BeEF (wait 10 seconds)..."
1f3638e Wade Alcorn Added workaround for debian 'env' issues
wadealcorn authored
90 @beef_process_id = IO.popen("ruby ./beef -x 2> /dev/null", "w+")
5a83e1f Wade Alcorn Added start and stop beef tasks to the rake tests
wadealcorn authored
91 delays = [2, 2, 1, 1, 1, 0.5, 0.5 , 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05]
92 delays.each do |i| # delay for 10 seconds
93 printf '.'
ee24d44 Wade Alcorn Added xserver start and stop task for use in automated testing
wadealcorn authored
94 sleep (i)
5a83e1f Wade Alcorn Added start and stop beef tasks to the rake tests
wadealcorn authored
95 end
96 puts '.'
97 end
98
99 task :beef_stop do
100 puts "\nShutting down BeEF...\n"
7bdfcb3 Wade Alcorn Tidy up the Rakefile
wadealcorn authored
101 sh "ps -ef|grep beef|grep -v grep|awk '{print $2}'|xargs kill"
5a83e1f Wade Alcorn Added start and stop beef tasks to the rake tests
wadealcorn authored
102 end
103
104 ################################
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
105 # MSF environment set up
106
107 @msf_process_id = nil;
108
109 task :msf_start => '/tmp/msf-test/msfconsole' do
d103d2a Wade Alcorn MSF start wait time increased to 45 secs from 30 secs
wadealcorn authored
110 printf "Starting MSF (wait 45 seconds)..."
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
111 @msf_process_id = IO.popen("/tmp/msf-test/msfconsole -r test/thirdparty/msf/unit/BeEF.rc 2> /dev/null", "w+")
d103d2a Wade Alcorn MSF start wait time increased to 45 secs from 30 secs
wadealcorn authored
112 delays = [10, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0.5, 0.5 , 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05]
113 delays.each do |i| # delay for 45 seconds
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
114 printf '.'
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
115 sleep (i) # increase the . display rate
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
116 end
117 puts '.'
118 end
119
120 task :msf_stop do
121 puts "\nShutting down MSF...\n"
122 @msf_process_id.puts "quit"
123 end
124
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
125 task :msf_install => '/tmp/msf-test/msfconsole' do
93b2f62 Wade Alcorn Update MSF install unit test helper.
wadealcorn authored
126 # Handled by the 'test/msf-test/msfconsole' task.
67edd9b rake options added
wade@bindshell.net authored
127 end
128
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
129 task :msf_update => '/tmp/msf-test/msfconsole' do
d103d2a Wade Alcorn MSF start wait time increased to 45 secs from 30 secs
wadealcorn authored
130 sh "cd /tmp/msf-test;git pull"
ffe20c8 BWZ included MSF install in rakefile
bw-z authored
131 end
132
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
133 file '/tmp/msf-test/msfconsole' do
04f14df Wade Alcorn Fixed MSF Tests
wadealcorn authored
134 puts "Installing MSF"
9cb0e12 Wade Alcorn Reordered the rake tasks and made the default quick tests
wadealcorn authored
135 sh "cd test;git clone https://github.com/rapid7/metasploit-framework.git /tmp/msf-test"
ffe20c8 BWZ included MSF install in rakefile
bw-z authored
136 end
137
02bed66 Rake task to generate DMG image
Ben authored
138
139 ################################
140 # Create Mac DMG File
141
142 task :dmg do
143 puts "\nCreating Working Directory\n";
144 sh "mkdir dmg";
145 sh "mkdir dmg/BeEF";
146 sh "rsync * dmg/BeEF --exclude=dmg -r";
147 sh "ln -s /Applications dmg/";
148 puts "\nCreating DMG File\n"
149 sh "hdiutil create ./BeEF.dmg -srcfolder dmg -volname BeEF -ov";
150 puts "\nCleaning Up\n"
151 sh "rm -r dmg";
152 puts "\nBeEF.dmg created\n"
153 end
154
1cf980f BWZ Added CDE Task to Rakefile
bw-z authored
155
156 ################################
157 # Create CDE Package
158 # This will download and make the CDE Executable and
159 # gnereate a CDE Package in cde-package
160
161 task :cde do
162 puts "\nCloning and Making CDE...";
163 sh "git clone git://github.com/pgbovine/CDE.git";
164 Dir.chdir "CDE";
165 sh "make";
166 Dir.chdir "..";
167 puts "\nCreating CDE Package...\n";
f0b1d6d BWZ Updated CDE Generator
bw-z authored
168 sh "bundle install"
169 Rake::Task['cde_beef_start'].invoke
170 Rake::Task['beef_stop'].invoke
1cf980f BWZ Added CDE Task to Rakefile
bw-z authored
171 puts "\nCleaning Up...\n";
f0b1d6d BWZ Updated CDE Generator
bw-z authored
172 sleep (2);
173 sh "rm -rf CDE";
f566a00 BWZ fix to cde script
bw-z authored
174 puts "\nCDE Package Created...\n";
e3e4a44 BWZ Bug Fixes for CDE Task
bw-z authored
175 end
1cf980f BWZ Added CDE Task to Rakefile
bw-z authored
176
f0b1d6d BWZ Updated CDE Generator
bw-z authored
177 ################################
178 # CDE/BeEF environment set up
179
180 @beef_process_id = nil;
181
182 task :cde_beef_start => 'beef' do
183 printf "Starting CDE BeEF (wait 10 seconds)..."
184 @beef_process_id = IO.popen("./CDE/cde ruby beef -x 2> /dev/null", "w+")
185 delays = [2, 2, 1, 1, 1, 0.5, 0.5 , 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05]
186 delays.each do |i| # delay for 10 seconds
187 printf '.'
188 sleep (i)
189 end
190 puts '.'
191 end
192
193
194 ################################
195
196
Something went wrong with that request. Please try again.