Make Rubocop less angy

GSoC/Meterpreter_Web_Console
bwatters-r7 2018-03-06 14:54:00 -06:00
parent b13a54ba2b
commit 4694ef6723
No known key found for this signature in database
GPG Key ID: ECC0F0A52E65F268
1 changed files with 27 additions and 30 deletions

View File

@ -1,21 +1,20 @@
require 'rex' require 'rex'
lib = File.join(Msf::Config.install_root, "test", "lib") lib = File.join(Msf::Config.install_root, "test", "lib")
$:.push(lib) unless $:.include?(lib) $LOAD_PATH.push(lib) unless $LOAD_PATH.include?(lib)
require 'module_test' require 'module_test'
class MetasploitModule < Msf::Post class MetasploitModule < Msf::Post
include Msf::ModuleTest::PostTest include Msf::ModuleTest::PostTest
include Msf::Post::File include Msf::Post::File
def initialize(info={}) def initialize(info = {})
super( update_info( info, super(update_info(info,
'Name' => 'Meterpreter cmd_exec test', 'Name' => 'Meterpreter cmd_exec test',
'Description' => %q{ This module will test the meterpreter cmd_exec API }, 'Description' => %q( This module will test the meterpreter cmd_exec API ),
'License' => MSF_LICENSE, 'License' => MSF_LICENSE,
'Platform' => [ 'windows', 'linux', 'unix' ], 'Platform' => ['windows', 'linux', 'unix'],
'SessionTypes' => [ 'meterpreter' ] 'SessionTypes' => ['meterpreter']
)) ))
end end
@ -24,7 +23,7 @@ class MetasploitModule < Msf::Post
it "should return the result of echo" do it "should return the result of echo" do
test_string = Rex::Text.rand_text_alpha(4) test_string = Rex::Text.rand_text_alpha(4)
if session.platform.eql?'windows' if session.platform.eql? 'windows'
output = cmd_exec('cmd.exe', "/c echo #{test_string}") output = cmd_exec('cmd.exe', "/c echo #{test_string}")
else else
output = cmd_exec("echo #{test_string}") output = cmd_exec("echo #{test_string}")
@ -33,29 +32,29 @@ class MetasploitModule < Msf::Post
end end
# trying to do a sleep in windows without trashing stdout is hard # trying to do a sleep in windows without trashing stdout is hard
unless session.platform.eql?'windows' unless session.platform.eql? 'windows'
it "should return the result after sleeping" do it "should return the result after sleeping" do
test_string = Rex::Text.rand_text_alpha(4) test_string = Rex::Text.rand_text_alpha(4)
output = cmd_exec("sleep 1; echo #{test_string}") output = cmd_exec("sleep 1; echo #{test_string}")
output == test_string output == test_string
end end
end
it "should return the full response after sleeping" do it "should return the full response after sleeping" do
test_string = Rex::Text.rand_text_alpha(4) test_string = Rex::Text.rand_text_alpha(4)
test_string2 = Rex::Text.rand_text_alpha(4) test_string2 = Rex::Text.rand_text_alpha(4)
if session.platform.eql?'windows' if session.platform.eql? 'windows'
output = cmd_exec('cmd.exe', "/c echo #{test_string} & timeout 1 > null & echo #{test_string2}") output = cmd_exec('cmd.exe', "/c echo #{test_string} & timeout 1 > null & echo #{test_string2}")
else else
output = cmd_exec("echo #{test_string}; sleep 1; echo #{test_string2}") output = cmd_exec("echo #{test_string}; sleep 1; echo #{test_string2}")
end end
output.delete("\r") == "#{test_string}\n#{test_string2}" output.delete("\r") == "#{test_string}\n#{test_string2}"
end
end end
it "should return the result of echo 10 times" do it "should return the result of echo 10 times" do
10.times do 10.times do
test_string = Rex::Text.rand_text_alpha(4) test_string = Rex::Text.rand_text_alpha(4)
if session.platform.eql?'windows' if session.platform.eql? 'windows'
output = cmd_exec("cmd.exe", "/c echo #{test_string}") output = cmd_exec("cmd.exe", "/c echo #{test_string}")
else else
output = cmd_exec("echo #{test_string}") output = cmd_exec("echo #{test_string}")
@ -64,7 +63,6 @@ class MetasploitModule < Msf::Post
end end
true true
end end
vprint_status("Finished cmd_exec tests") vprint_status("Finished cmd_exec tests")
end end
@ -73,7 +71,7 @@ class MetasploitModule < Msf::Post
it "should return the result of echo with single quotes" do it "should return the result of echo with single quotes" do
test_string = Rex::Text.rand_text_alpha(4) test_string = Rex::Text.rand_text_alpha(4)
if session.platform.eql?'windows' if session.platform.eql? 'windows'
output = cmd_exec("cmd.exe", "/c echo '#{test_string}'") output = cmd_exec("cmd.exe", "/c echo '#{test_string}'")
output == "'" + test_string + "'" output == "'" + test_string + "'"
else else
@ -84,7 +82,7 @@ class MetasploitModule < Msf::Post
it "should return the result of echo with double quotes" do it "should return the result of echo with double quotes" do
test_string = Rex::Text.rand_text_alpha(4) test_string = Rex::Text.rand_text_alpha(4)
if session.platform.eql?'windows' if session.platform.eql? 'windows'
output = cmd_exec("cmd.exe", "/c echo \"#{test_string}\"") output = cmd_exec("cmd.exe", "/c echo \"#{test_string}\"")
output == "\"" + test_string + "\"" output == "\"" + test_string + "\""
else else
@ -93,5 +91,4 @@ class MetasploitModule < Msf::Post
end end
end end
end end
end end