Added pre_execute, execute and post_execute to modules.

git-svn-id: https://beef.googlecode.com/svn/trunk@1197 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
passbe
2011-08-17 04:04:32 +00:00
parent 8fe714881a
commit 2e70f86866
37 changed files with 50 additions and 36 deletions

View File

@@ -170,6 +170,9 @@ module Core
JSON.parse(command['data']).each{|v|
cc[v['name']] = v['value']
}
if self.respond_to?(:execute)
self.execute
end
@output = @eruby.evaluate(cc)
@output

View File

@@ -51,7 +51,9 @@ module Handlers
command = @kclass.new(BeEF::Module.get_key_by_class(@kclass)) # create the commamd module
command.build_callback_datastore(@http_params, @http_header) # build datastore from the response
command.session_id = beefhook
command.callback # call the command module's callback function - it will parse and save the results
if command.respond_to?(:post_execute)
command.post_execute
end
# get/set details for datastore and log entry
command_friendly_name = command.friendlyname

View File

@@ -31,6 +31,11 @@ module Module
return (self.is_enabled(mod) and BeEF::Core::Configuration.instance.get('beef.module.'+mod.to_s+'.loaded') == true)
end
# Returns module class definition
def self.get_definition(mod)
return BeEF::Core::Command.const_get(BeEF::Core::Configuration.instance.get("beef.module.#{mod.to_s}.class"))
end
# Gets all module options
def self.get_options(mod)
if self.check_hard_load(mod)
@@ -346,6 +351,10 @@ module Module
print_error "Could not find hooked browser when attempting to execute module '#{mod}'"
return false
end
command_module = self.get_definition(mod).new(mod)
if command_module.respond_to?(:pre_execute)
command_module.pre_execute
end
c = BeEF::Core::Models::Command.new(:data => self.merge_options(mod, opts).to_json,
:hooked_browser_id => hb.id,
:command_module_id => BeEF::Core::Configuration.instance.get("beef.module.#{mod}.db.id"),

View File

@@ -21,7 +21,7 @@ class Detect_visited_urls < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -47,7 +47,7 @@ class Hook_ie < BeEF::Core::Command
end
def callback
def post_execute
content = {}
content['result'] = @datastore['result']

View File

@@ -22,7 +22,7 @@ class Link_rewrite < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -21,7 +21,7 @@ class Site_redirect < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -26,7 +26,7 @@ class Site_redirect_iframe < BeEF::Core::Command
# This method is being called when a hooked browser sends some
# data back to the framework.
#
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -15,7 +15,7 @@
#
class Test_return_ascii_chars < BeEF::Core::Command
def callback
def post_execute
content = {}
content['Result String'] = @datastore['result_string']
save content

View File

@@ -23,7 +23,7 @@ class Test_return_long_string < BeEF::Core::Command
end
def callback
def post_execute
content = {}
content['Result String'] = @datastore['result_string']
save content

View File

@@ -19,7 +19,7 @@ class Insecure_url_skype < BeEF::Core::Command
{ 'name' => 'tel_num', 'description' => 'The telephone number to dial', 'ui_label'=>'Number', 'value' =>'5551234', 'width' => '200px' }
end
def callback
def post_execute
content = {}
content['Result'] = @datastore['result']
save content

View File

@@ -21,7 +21,7 @@ class Iphone_tel < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['Result'] = @datastore['result']
save content

View File

@@ -15,7 +15,7 @@
#
class Physical_location < BeEF::Core::Command
def callback
def post_execute
content = {}
content['Geolocation Enabled'] = @datastore['geoLocEnabled']
content['Latitude'] = @datastore['latitude']

View File

@@ -33,7 +33,7 @@ class Browser_autopwn < BeEF::Core::Command
# This method is being called when a hooked browser sends some
# data back to the framework.
#
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -26,8 +26,8 @@ class Alert_dialog < BeEF::Core::Command
'width' => '400px'
}]
end
def callback
def post_execute
content = {}
content['User Response'] = "The user clicked the 'OK' button when presented with an alert box."
save content

View File

@@ -15,7 +15,7 @@
#
class Clipboard_theft < BeEF::Core::Command
def callback
def post_execute
content = {}
content['clipboard'] = @datastore['clipboard']
save content

View File

@@ -21,7 +21,7 @@ class Deface_web_page < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['Result'] = @datastore['result']
save content

View File

@@ -20,7 +20,7 @@ class Extract_local_storage < BeEF::Core::Command
# http://diveintohtml5.org/storage.html
#
def callback
def post_execute
content = {}
content['localStorage'] = @datastore['localStorage']
save content

View File

@@ -25,7 +25,7 @@ class Prompt_dialog < BeEF::Core::Command
# This method is being called when a zombie sends some
# data back to the framework.
#
def callback
def post_execute
# return if @datastore['answer']==''

View File

@@ -25,7 +25,7 @@ class Raw_javascript < BeEF::Core::Command
# This method is being called when a zombie sends some
# data back to the framework.
#
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -22,7 +22,7 @@ class Replace_video < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['Result'] = @datastore['result']
save content

View File

@@ -15,7 +15,7 @@
#
class Rickroll < BeEF::Core::Command
def callback
def post_execute
content = {}
content['Result'] = @datastore['result']
save content

View File

@@ -29,7 +29,7 @@ class Coldfusion_dir_traversal_exploit < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -21,7 +21,7 @@ class Detect_local_settings < BeEF::Core::Command
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/detect_local_settings/Beeffeine.class','/Beeffeine','class')
end
def callback
def post_execute
content = {}
content['internal ip'] = @datastore['internal_ip'] if not @datastore['internal_ip'].nil?
content['internal hostname'] = @datastore['internal_hostname'] if not @datastore['internal_hostname'].nil?

View File

@@ -68,7 +68,7 @@ class Inter_protocol_win_bindshell < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['result'] = @datastore['result'] if not @datastore['result'].nil?
content['fail'] = @datastore['fail'] if not @datastore['fail'].nil?

View File

@@ -30,7 +30,7 @@ class Jboss_jmx_upload_exploit < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -37,7 +37,7 @@ class Vtiger_crm_upload_exploit < BeEF::Core::Command
]
end
def callback
def post_execute
return if @datastore['result'].nil?
save({'result' => @datastore['result']})

View File

@@ -18,7 +18,7 @@ class Iframe_above < BeEF::Core::Command
# This method is being called when a hooked browser sends some
# data back to the framework.
#
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -22,7 +22,7 @@ class Iframe_keylogger < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['keystrokes'] = @datastore['keystrokes']
save content

View File

@@ -18,7 +18,7 @@ class Popunder_window < BeEF::Core::Command
# This method is being called when a hooked browser sends some
# data back to the framework.
#
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -15,7 +15,7 @@
#
class Collect_links < BeEF::Core::Command
def callback
def post_execute
content = {}
content['Links'] = @datastore['links']

View File

@@ -21,7 +21,7 @@ class Detect_soc_nets < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['GMail'] = @datastore['gmail']
content['Facebook'] = @datastore['facebook']

View File

@@ -21,7 +21,7 @@ class Detect_tor < BeEF::Core::Command
]
end
def callback
def post_execute
return if @datastore['result'].nil?
save({'result' => @datastore['result']})

View File

@@ -43,7 +43,7 @@ class Internal_network_fingerprinting < BeEF::Core::Command
]
end
def callback
def post_execute
content = {}
content['device'] =@datastore['device'] if not @datastore['device'].nil?
content['url'] = @datastore['url'] if not @datastore['url'].nil?

View File

@@ -23,7 +23,7 @@ class Linksys_befsr41_csrf < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -23,7 +23,7 @@ class Linksys_wrt54g2_csrf < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end

View File

@@ -23,7 +23,7 @@ class Linksys_wrt54g_csrf < BeEF::Core::Command
]
end
def callback
def post_execute
save({'result' => @datastore['result']})
end