OS targeting added to modules. Also, some modules have been updated to prompt status.
git-svn-id: https://beef.googlecode.com/svn/trunk@620 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -23,13 +23,14 @@ module Constants
|
||||
|
||||
module Browsers
|
||||
|
||||
FF = 'FF' # Firefox
|
||||
M = 'M' # Mozila
|
||||
IE = 'IE' # Internet Explorer
|
||||
S = 'S' # Safari
|
||||
K = 'K' # Konqueror
|
||||
C = 'C' # Chrome
|
||||
ALL = 'ALL' # ALL
|
||||
FF = 'FF' # Firefox
|
||||
M = 'M' # Mozila
|
||||
IE = 'IE' # Internet Explorer
|
||||
S = 'S' # Safari
|
||||
K = 'K' # Konqueror
|
||||
C = 'C' # Chrome
|
||||
ALL = 'ALL' # ALL
|
||||
UNKNOWN = 'UNKNOWN' # Unknown
|
||||
|
||||
FRIENDLY_FF_NAME = 'Firefox'
|
||||
FRIENDLY_M_NAME = 'Mozila'
|
||||
@@ -51,7 +52,6 @@ module Constants
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# The User Agent strings for browser detection
|
||||
@@ -83,8 +83,8 @@ module Constants
|
||||
OS_LINUX_IMG = 'linux.png'
|
||||
OS_MAC_UA_STR = 'Mac'
|
||||
OS_MAC_IMG = 'mac.png'
|
||||
OS_IPHONE_UA_STR = 'iPhone'
|
||||
OS_IPHONE_IMG = 'iphone.png'
|
||||
OS_IPHONE_UA_STR = 'iPhone'
|
||||
OS_IPHONE_IMG = 'iphone.png'
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -39,11 +39,12 @@ module BeEF
|
||||
|
||||
BD = BeEF::Models::BrowserDetails
|
||||
|
||||
ALL = BeEF::Constants::Browsers::ALL
|
||||
IE = BeEF::Constants::Browsers::IE
|
||||
S = BeEF::Constants::Browsers::S
|
||||
FF = BeEF::Constants::Browsers::FF
|
||||
C = BeEF::Constants::Browsers::C
|
||||
UNKNOWN = BeEF::Constants::Browsers::UNKNOWN
|
||||
ALL = BeEF::Constants::Browsers::ALL
|
||||
IE = BeEF::Constants::Browsers::IE
|
||||
S = BeEF::Constants::Browsers::S
|
||||
FF = BeEF::Constants::Browsers::FF
|
||||
C = BeEF::Constants::Browsers::C
|
||||
|
||||
VERIFIED_WORKING = BeEF::Constants::CommandModule::MODULE_TARGET_VERIFIED_WORKING
|
||||
VERIFIED_NOT_WORKING = BeEF::Constants::CommandModule::MODULE_TARGET_VERIFIED_NOT_WORKING
|
||||
@@ -136,6 +137,7 @@ module BeEF
|
||||
|
||||
return VERIFIED_UNKNOWN if not @target # no target specified in the module
|
||||
|
||||
# loop through each definition and check it
|
||||
@target.each {|definition|
|
||||
return definition['verified_status'] if test_target(definition)
|
||||
}
|
||||
@@ -146,37 +148,59 @@ module BeEF
|
||||
|
||||
# test if the target definition matches the hooked browser
|
||||
# this function is used when determining the code of the node icon
|
||||
def test_target(target_definition)
|
||||
# if the target is not set in the module return unknown
|
||||
return false if target_definition.nil?
|
||||
# return false if not target_definition[0]['browser_name']
|
||||
return false if target_definition['browser_name'].nil?
|
||||
def test_target_attribute(hb_attr_name, hb_attr_ver, target_attr_name, target_attr_max_ver, target_attr_min_ver)
|
||||
|
||||
# retrieve the target browser name
|
||||
browser_name = get_browser_detail('BrowserName')
|
||||
return false if browser_name.eql? 'UNKNOWN' or browser_name.nil?
|
||||
# check if wild cards are set
|
||||
return true if not target_attr_name
|
||||
return true if target_attr_name.nil?
|
||||
return true if target_attr_name.eql? ALL
|
||||
|
||||
# can't answer based on hb_attr_name
|
||||
return false if not hb_attr_name
|
||||
return false if hb_attr_name.nil?
|
||||
return false if hb_attr_name.eql? UNKNOWN
|
||||
|
||||
# check if the browser is targeted
|
||||
all_browsers_targeted = target_definition['browser_name'].eql? BeEF::Constants::Browsers::ALL
|
||||
target_browser_matches = browser_name.eql? target_definition['browser_name']
|
||||
return false if not (target_browser_matches || all_browsers_targeted)
|
||||
# check if the attribute is targeted
|
||||
return false if not target_attr_name.eql? hb_attr_name
|
||||
|
||||
# assume that the browser_maxver and browser_minver were excluded
|
||||
return true if target_definition['browser_maxver'].nil? && target_definition['browser_minver'].nil?
|
||||
# assume that the max version and min version were purposefully excluded
|
||||
return true if target_attr_max_ver.nil? && target_attr_min_ver.nil?
|
||||
|
||||
# check if the browser version is targeted
|
||||
browser_version = get_browser_detail('BrowserVersion')
|
||||
browser_version = 'UNKNOWN' if browser_version.nil?
|
||||
return false if browser_version.eql? 'UNKNOWN'
|
||||
# check if the framework can detect hb version
|
||||
return false if hb_attr_ver.eql? 'UNKNOWN'
|
||||
|
||||
# check the browser version number is within range
|
||||
return false if browser_version.to_f > target_definition['browser_maxver'].to_f
|
||||
return false if browser_version.to_f < target_definition['browser_minver'].to_f
|
||||
# check the version number is within range
|
||||
return false if hb_attr_ver.to_f > target_attr_max_ver.to_f
|
||||
return false if hb_attr_ver.to_f < target_attr_min_ver.to_f
|
||||
|
||||
# all the checks passed and this module targets the user agent
|
||||
# all the checks passed
|
||||
true
|
||||
end
|
||||
|
||||
# test if the target definition matches the hooked browser
|
||||
# this function is used when determining the code of the node icon
|
||||
def test_target(target_definition)
|
||||
|
||||
# if the definition is nill we don't know
|
||||
return false if target_definition.nil?
|
||||
|
||||
# check if the browser is a target
|
||||
hb_browser_name = get_browser_detail('BrowserName')
|
||||
hb_browser_version = get_browser_detail('BrowserVersion')
|
||||
target_browser_name = target_definition['browser_name']
|
||||
target_browser_max_ver = target_definition['browser_maxver']
|
||||
target_browser_min_ver = target_definition['browser_minver']
|
||||
browser_match = test_target_attribute(hb_browser_name, hb_browser_version, target_browser_name, target_browser_max_ver, target_browser_min_ver)
|
||||
|
||||
# check if the operating system is a target
|
||||
hb_os_name = get_browser_detail('OSName')
|
||||
target_os_name = target_definition['os_name']
|
||||
os_match = test_target_attribute(hb_os_name, nil, target_os_name, nil, nil)
|
||||
|
||||
return browser_match && os_match
|
||||
|
||||
end
|
||||
|
||||
# Store the browser detail in the database.
|
||||
def set_browser_detail(key, value)
|
||||
raise WEBrick::HTTPStatus::BadRequest, "@session_id is invalid" if not BeEF::Filter.is_valid_hook_session_id?(@session_id)
|
||||
|
||||
@@ -17,9 +17,9 @@ class Site_redirect < BeEF::Command
|
||||
})
|
||||
|
||||
set_target({
|
||||
'verified_status' => VERIFIED_WORKING,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
'verified_status' => VERIFIED_USER_NOTIFY,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
|
||||
use_template!
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class Site_redirect_iframe < BeEF::Command
|
||||
})
|
||||
|
||||
set_target({
|
||||
'verified_status' => VERIFIED_WORKING,
|
||||
'verified_status' => VERIFIED_USER_NOTIFY,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ class Alert_dialog < BeEF::Command
|
||||
})
|
||||
|
||||
set_target({
|
||||
'verified_status' => VERIFIED_WORKING,
|
||||
'browser_name' => ALL
|
||||
'verified_status' => VERIFIED_USER_NOTIFY,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
|
||||
# This tells the framework to use the file 'alert.js' as the command module instructions.
|
||||
|
||||
@@ -28,7 +28,7 @@ class Deface_web_page < BeEF::Command
|
||||
})
|
||||
|
||||
set_target({
|
||||
'verified_status' => VERIFIED_WORKING,
|
||||
'verified_status' => VERIFIED_USER_NOTIFY,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ class Prompt_dialog < BeEF::Command
|
||||
})
|
||||
|
||||
set_target({
|
||||
'verified_status' => VERIFIED_WORKING,
|
||||
'browser_name' => ALL
|
||||
'verified_status' => VERIFIED_USER_NOTIFY,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
|
||||
use_template!
|
||||
|
||||
@@ -18,7 +18,7 @@ class Popunder_window < BeEF::Command
|
||||
})
|
||||
|
||||
set_target({
|
||||
'verified_status' => VERIFIED_WORKING,
|
||||
'verified_status' => VERIFIED_USER_NOTIFY,
|
||||
'browser_name' => ALL
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user