Updated xssrays for AR

This commit is contained in:
Ben Passmore
2019-11-30 15:23:27 +10:00
parent 173d55714a
commit 8ca7e2135c
5 changed files with 15 additions and 41 deletions

View File

@@ -18,10 +18,10 @@ module BeEF
def start_scan(hb, body) def start_scan(hb, body)
@body = body @body = body
config = BeEF::Core::Configuration.instance config = BeEF::Core::Configuration.instance
hb = BeEF::Core::Models::HookedBrowser.first(:id => hb.id) hb = BeEF::Core::Models::HookedBrowser.find(hb.id)
#TODO: we should get the xssrays_scan table with more accuracy, if for some reasons we requested #TODO: we should get the xssrays_scan table with more accuracy, if for some reasons we requested
#TODO: 2 scans on the same hooked browsers, "first" could not get the right result we want #TODO: 2 scans on the same hooked browsers, "first" could not get the right result we want
xs = BeEF::Core::Models::Xssraysscan.first(:hooked_browser_id => hb.id, :is_started => false) xs = BeEF::Core::Models::Xssraysscan.where(:hooked_browser_id => hb.id, :is_started => false).first
# stop here if there are no XssRays scans to be started # stop here if there are no XssRays scans to be started
return if xs == nil || xs.is_started == true return if xs == nil || xs.is_started == true

View File

@@ -18,7 +18,7 @@ module BeEF
# raise an error if it's null or not found in the DB # raise an error if it's null or not found in the DB
beef_hook = params[:hbsess] || nil beef_hook = params[:hbsess] || nil
if beef_hook.nil? || HB.first(:session => beef_hook).nil? if beef_hook.nil? || HB.where(:session => beef_hook).first.nil?
print_error "[XSSRAYS] Invalid beef hook ID: the hooked browser cannot be found in the database" print_error "[XSSRAYS] Invalid beef hook ID: the hooked browser cannot be found in the database"
return return
end end
@@ -53,8 +53,8 @@ module BeEF
# parse incoming rays: rays are verified XSS, as the attack vector is calling back BeEF when executed. # parse incoming rays: rays are verified XSS, as the attack vector is calling back BeEF when executed.
def parse_rays(rays_scan_id) def parse_rays(rays_scan_id)
xssrays_scan = XS.first(:id => rays_scan_id) xssrays_scan = XS.find(rays_scan_id)
hooked_browser = HB.first(:session => params[:hbsess]) hooked_browser = HB.where(:session => params[:hbsess]).first
if xssrays_scan.nil? if xssrays_scan.nil?
print_error "[XSSRAYS] Invalid scan" print_error "[XSSRAYS] Invalid scan"
@@ -76,7 +76,7 @@ module BeEF
# finalize the XssRays scan marking the scan as finished in the db # finalize the XssRays scan marking the scan as finished in the db
def finalize_scan(rays_scan_id) def finalize_scan(rays_scan_id)
xssrays_scan = BeEF::Core::Models::Xssraysscan.first(:id => rays_scan_id) xssrays_scan = BeEF::Core::Models::Xssraysscan.find(rays_scan_id)
if xssrays_scan.nil? if xssrays_scan.nil?
print_error "[XSSRAYS] Invalid scan" print_error "[XSSRAYS] Invalid scan"

View File

@@ -9,21 +9,8 @@ module Models
# #
# Store the rays details, basically verified XSS vulnerabilities # Store the rays details, basically verified XSS vulnerabilities
# #
class Xssraysdetail < ActiveRecord::Base class Xssraysdetail < BeEF::Core::Model
attribute :id, :Serial belongs_to :hooked_browser
# The hooked browser id
attribute :hooked_browser_id, :Text, :lazy => false
# The XssRays vector name for the vulnerability
attribute :vector_name, :Text, :lazy => true
# The XssRays vector method (GET or POST) for the vulnerability
attribute :vector_method, :Text, :lazy => true
# The XssRays Proof of Concept for the vulnerability
attribute :vector_poc, :Text, :lazy => true
belongs_to :xssraysscan belongs_to :xssraysscan
end end

View File

@@ -9,23 +9,10 @@ module Models
# #
# Store the XssRays scans started and finished, with relative ID # Store the XssRays scans started and finished, with relative ID
# #
class Xssraysscan < ActiveRecord::Base class Xssraysscan < BeEF::Core::Model
attribute :id, :Serial has_many :xssrays_details
attribute :hooked_browser_id, :Text, :lazy => false
attribute :scan_start, :DateTime, :lazy => true
attribute :scan_finish, :DateTime, :lazy => true
attribute :domain, :Text, :lazy => true
attribute :cross_domain, :Text, :lazy => true
attribute :clean_timeout, :Integer, :lazy => false
attribute :is_started, :Boolean, :lazy => false, :default => false
attribute :is_finished, :Boolean, :lazy => false, :default => false
belongs_to :extension_xssrays_details
end end
end end

View File

@@ -34,7 +34,7 @@ module BeEF
# Returns the entire list of rays for all zombies # Returns the entire list of rays for all zombies
get '/rays' do get '/rays' do
begin begin
rays = XD.all(:unique => true, :order => [:id.asc]) rays = XD.all.distinct.order(:id)
count = rays.length count = rays.length
result = {} result = {}
@@ -55,7 +55,7 @@ module BeEF
begin begin
id = params[:id] id = params[:id]
rays = XD.all(:hooked_browser_id => id, :unique => true, :order => [:id.asc]) rays = XD.where(:hooked_browser_id => id).distinct.order(:id)
count = rays.length count = rays.length
result = {} result = {}
@@ -77,7 +77,7 @@ module BeEF
# Returns the entire list of scans for all zombies # Returns the entire list of scans for all zombies
get '/scans' do get '/scans' do
begin begin
scans = XS.all(:unique => true, :order => [:id.asc]) scans = XS.distinct.order(:id)
count = scans.length count = scans.length
result = {} result = {}
@@ -98,7 +98,7 @@ module BeEF
begin begin
id = params[:id] id = params[:id]
scans = XS.all(:hooked_browser_id => id, :unique => true, :order => [:id.asc]) scans = XS.where(:hooked_browser_id => id).distinct.order(:id)
count = scans.length count = scans.length
result = {} result = {}
@@ -122,7 +122,7 @@ module BeEF
begin begin
id = params[:id] id = params[:id]
hooked_browser = HB.first(:session => id, :unique => true, :order => [:id.asc]) hooked_browser = HB.where(:session => id).distinct.order(:id)
if hooked_browser.nil? if hooked_browser.nil?
print_error "[XSSRAYS] Invalid hooked browser ID" print_error "[XSSRAYS] Invalid hooked browser ID"