Corrected Xssrays API class. Added id specification to API Registra. Register function now checks API path
git-svn-id: https://beef.googlecode.com/svn/trunk@1236 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
33
core/api.rb
33
core/api.rb
@@ -24,26 +24,35 @@ module API
|
||||
|
||||
def initialize
|
||||
@registry = []
|
||||
@count = 1
|
||||
end
|
||||
|
||||
# Register owner, c, method and matching params
|
||||
def register(owner, c, method, params = [])
|
||||
if not self.registered?(owner, c, method)
|
||||
@registry << {
|
||||
'owner' => owner,
|
||||
'class' => c,
|
||||
'method' => method,
|
||||
'params' => params
|
||||
}
|
||||
if self.verify_api_path(c, method)
|
||||
if not self.registered?(owner, c, method, params)
|
||||
id = @count
|
||||
@registry << {
|
||||
'id' => id,
|
||||
'owner' => owner,
|
||||
'class' => c,
|
||||
'method' => method,
|
||||
'params' => params
|
||||
}
|
||||
@count += 1
|
||||
return id
|
||||
else
|
||||
print_debug "API Registra: Attempting to re-register API call #{c.to_s} :#{method.to_s}"
|
||||
end
|
||||
else
|
||||
print_debug "API Registra: Attempting to re-register API call #{c.to_s} :#{method.to_s}"
|
||||
print_error "API Registra: Attempted to register non-existant API method #{c.to_s} :#{method.to_s}"
|
||||
end
|
||||
end
|
||||
|
||||
# returns boolean whether or not any owner has registered
|
||||
def registered?(owner, c, method)
|
||||
def registered?(owner, c, method, params = [])
|
||||
@registry.each{|r|
|
||||
if r['owner'] == owner and r['class'] == c and r['method'] == method
|
||||
if r['owner'] == owner and r['class'] == c and r['method'] == method and params == r['params']
|
||||
return true
|
||||
end
|
||||
}
|
||||
@@ -51,9 +60,9 @@ module API
|
||||
end
|
||||
|
||||
# unregister API call from owner, class and method
|
||||
def unregister(owner, c, method)
|
||||
def unregister(id)
|
||||
@registry.delete_if{|r|
|
||||
r['owner'] == owner and r['class'] == c and r['method'] == method
|
||||
r['id'] == id
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ module Xssrays
|
||||
|
||||
module RegisterPreHookCallback
|
||||
|
||||
BeEF::API::Registra.instance.register(BeEF::Extension::Xssrays::RegisterPreHookCallback, BeEF::API::Server, 'pre_hook_send')
|
||||
BeEF::API::Registra.instance.register(BeEF::Extension::Xssrays::RegisterPreHookCallback, BeEF::API::Server::Hook, 'pre_hook_send')
|
||||
|
||||
# checks at every polling if there are new scans to be started
|
||||
def self.pre_hook_send(hooked_browser, body, params, request, response)
|
||||
|
||||
Reference in New Issue
Block a user