2011-01-29 21:40:53 +00:00
|
|
|
$:.unshift(File.join((File.dirname(__FILE__))))
|
|
|
|
require 'regexr'
|
|
|
|
|
|
|
|
module MsfMatchers
|
|
|
|
|
2011-02-11 00:48:34 +00:00
|
|
|
class ContainACompleteTest
|
|
|
|
|
|
|
|
def initialize()
|
|
|
|
@r = Regexr.new(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def matches?(data)
|
|
|
|
@data = data
|
|
|
|
return @r.verify_start_and_end(@data,"meterpreter_functional_test_start", "meterpreter_functional_test_end")
|
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message
|
|
|
|
"Beginning or end was incorrect."
|
|
|
|
end
|
|
|
|
|
|
|
|
def negative_failure_message
|
|
|
|
"Expected to find a no beginning or end, but it matched."
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def contain_a_complete_test
|
|
|
|
ContainACompleteTest.new
|
|
|
|
end
|
|
|
|
|
2011-01-29 21:40:53 +00:00
|
|
|
class ContainAllSuccesses
|
|
|
|
|
|
|
|
def initialize(successes)
|
|
|
|
@successes = successes
|
|
|
|
@r = Regexr.new(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def matches?(data)
|
|
|
|
@data = data
|
2011-01-31 17:48:03 +00:00
|
|
|
@string = @r.find_strings_that_dont_exist_in_data(@data,@successes)
|
|
|
|
return true if !@string
|
|
|
|
nil
|
2011-01-29 21:40:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message
|
2011-01-31 17:48:03 +00:00
|
|
|
"expected all successes, but didn't find '#{@string}'"
|
2011-01-29 21:40:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def negative_failure_message
|
|
|
|
"expected to miss successes but found'm all :("
|
|
|
|
end
|
|
|
|
|
|
|
|
#alias :have_all_successes :contain_all_successes
|
|
|
|
end
|
|
|
|
|
|
|
|
def contain_all_successes(successes)
|
|
|
|
ContainAllSuccesses.new(successes)
|
|
|
|
end
|
|
|
|
|
|
|
|
class ContainNoFailuresExcept
|
|
|
|
|
|
|
|
def initialize(failures,exceptions)
|
|
|
|
@failures = failures
|
|
|
|
@exceptions = exceptions
|
|
|
|
@r = Regexr.new(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def matches?(data)
|
|
|
|
@data = data
|
2011-01-31 17:48:03 +00:00
|
|
|
@string = @r.find_strings_that_exist_in_data_except(@data,@failures,@exceptions)
|
|
|
|
return true if !@string
|
|
|
|
nil
|
2011-01-29 21:40:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message
|
2011-01-31 17:48:03 +00:00
|
|
|
"expected no failure to be found, but found this: '#{@string}'"
|
2011-01-29 21:40:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def negative_falure_message
|
|
|
|
"expected to find failures, but didn't find any :("
|
|
|
|
end
|
|
|
|
|
|
|
|
#alias :have_no_failures :contain_no_failures
|
|
|
|
end
|
|
|
|
|
|
|
|
def contain_no_failures_except(failures,exceptions)
|
|
|
|
ContainNoFailuresExcept.new(failures,exceptions)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|