Files
beef/rakefile
2012-01-12 13:59:57 +10:00

69 lines
1.8 KiB
Plaintext

#
# Copyright 2012 Wade Alcorn wade@bindshell.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
@msf_process_id = nil;
desc "Run quick unit tests"
task :quick do
sh "cd test/unit/;ruby -W0 ts_beef.rb no_msf"
end
desc "Run all unit tests"
task :all => ["install", "msf_install"] do
Rake::Task['msf_update'].invoke
Rake::Task['msf_start'].invoke
sh "cd test/unit/;ruby -W0 ts_beef.rb"
Rake::Task['msf_stop'].invoke
end
task :install do
sh "bundle install"
end
task :no_msf_tests do
sh "cd test/unit/;ruby -W0 ts_beef.rb no_msf"
end
task :msf_start => 'test/msf-test/msfconsole' do
printf "Starting MSF (wait 30 seconds)..."
@msf_process_id = IO.popen("test/msf-test/msfconsole -r test/unit/BeEF.rc 2> /dev/null", "w+")
(1..7).each do |i| # delay for 30 seconds
printf '.'
sleep (8-i) # increase the . display rate
end
puts '.'
end
task :msf_stop do
puts "\nShutting down MSF...\n"
@msf_process_id.puts "quit"
end
task :msf_install => 'test/msf-test/msfconsole' do
# Handled by the 'test/msf-test/msfconsole' task.
end
task :msf_update => 'test/msf-test/msfconsole' do
sh "cd test/msf-test;git pull"
end
file 'test/msf-test/msfconsole' do
puts "Installing MSF"
sh "cd test;git clone https://github.com/rapid7/metasploit-framework.git msf-test"
end
task :default => ["quick"]