Updated webrtc for AR

This commit is contained in:
Ben Passmore
2019-11-30 15:22:41 +10:00
parent 502a52452c
commit 173d55714a
6 changed files with 21 additions and 80 deletions

View File

@@ -29,7 +29,7 @@ module BeEF
rtcmanagementoutput = [] rtcmanagementoutput = []
# Get all RTCSignals for this browser # Get all RTCSignals for this browser
BeEF::Core::Models::Rtcsignal.all(:target_hooked_browser_id => hb.id, :has_sent => "waiting").each { |h| BeEF::Core::Models::Rtcsignal.where(:target_hooked_browser_id => hb.id, :has_sent => "waiting").each { |h|
# output << self.requester_parse_db_request(h) # output << self.requester_parse_db_request(h)
rtcsignaloutput << h.signal rtcsignaloutput << h.signal
h.has_sent = "sent" h.has_sent = "sent"
@@ -37,7 +37,7 @@ module BeEF
} }
# Get all RTCManagement messages for this browser # Get all RTCManagement messages for this browser
BeEF::Core::Models::Rtcmanage.all(:hooked_browser_id => hb.id, :has_sent => "waiting").each {|h| BeEF::Core::Models::Rtcmanage.where(:hooked_browser_id => hb.id, :has_sent => "waiting").each {|h|
rtcmanagementoutput << h.message rtcmanagementoutput << h.message
h.has_sent = "sent" h.has_sent = "sent"
h.save h.save

View File

@@ -9,18 +9,8 @@ module Models
# #
# Table stores the queued up JS commands for managing the client-side webrtc logic. # Table stores the queued up JS commands for managing the client-side webrtc logic.
# #
class Rtcmanage < ActiveRecord::Base class Rtcmanage < BeEF::Core::Model
attribute :id, :Serial
# The hooked browser id
attribute :hooked_browser_id, :Text, :lazy => false
# The message
attribute :message, :Text, :lazy => true
# Boolean value to say if the signal has been sent to the target peer
attribute :has_sent, :Text, :lazy => false, :default => "waiting"
# Starts the RTCPeerConnection process, establishing a WebRTC connection between the caller and the receiver # Starts the RTCPeerConnection process, establishing a WebRTC connection between the caller and the receiver
def self.initiate(caller, receiver, verbosity = false) def self.initiate(caller, receiver, verbosity = false)
stunservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.stunservers") stunservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.stunservers")
@@ -29,25 +19,25 @@ module Models
# Add the beef.webrtc.start() JavaScript call into the Rtcmanage table - this will be picked up by the browser on next hook.js poll # Add the beef.webrtc.start() JavaScript call into the Rtcmanage table - this will be picked up by the browser on next hook.js poll
# This is for the Receiver # This is for the Receiver
r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => receiver, :message => "beef.webrtc.start(0,#{caller},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});") r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => receiver, :message => "beef.webrtc.start(0,#{caller},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});")
r.save r.save!
# This is the same beef.webrtc.start() JS call, but for the Caller # This is the same beef.webrtc.start() JS call, but for the Caller
r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => caller, :message => "beef.webrtc.start(1,#{receiver},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});") r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => caller, :message => "beef.webrtc.start(1,#{receiver},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});")
r.save r.save!
end end
# Advises a browser to send an RTCDataChannel message to its peer # Advises a browser to send an RTCDataChannel message to its peer
# Similar to the initiate method, this loads up a JavaScript call to the beefrtcs[peerid].sendPeerMsg() function call # Similar to the initiate method, this loads up a JavaScript call to the beefrtcs[peerid].sendPeerMsg() function call
def self.sendmsg(from, to, message) def self.sendmsg(from, to, message)
r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => from, :message => "beefrtcs[#{to}].sendPeerMsg('#{message}');") r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => from, :message => "beefrtcs[#{to}].sendPeerMsg('#{message}');")
r.save r.save!
end end
# Gets the browser to run the beef.webrtc.status() JavaScript function # Gets the browser to run the beef.webrtc.status() JavaScript function
# This JS function will return it's values to the /rtcmessage handler # This JS function will return it's values to the /rtcmessage handler
def self.status(id) def self.status(id)
r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => id, :message => "beef.webrtc.status(#{id});") r = BeEF::Core::Models::Rtcmanage.new(:hooked_browser_id => id, :message => "beef.webrtc.status(#{id});")
r.save r.save!
end end
end end

View File

@@ -13,27 +13,10 @@ module Models
# #
class Rtcmodulestatus < ActiveRecord::Base class Rtcmodulestatus < BeEF::Core::Model
attribute :id, :Serial
belongs_to :hooked_browser
# The hooked browser id belongs_to :command_module
attribute :hooked_browser_id, :Text, :lazy => false
# The hooked browser's IP
attribute :hooked_browser_ip, :Text, :lazy => false
# The target hooked browser id
attribute :target_hooked_browser_id, :Text, :lazy => false
# The command module ID
attribute :command_module_id, :Text, :lazy => false
# The status field
attribute :status, :Text, :lazy => true
# Timestamps
attribute :created_at, DateTime
attribute :updated_at, DateTime
end end

View File

@@ -9,21 +9,9 @@ module Models
# #
# Table stores the webrtc signals from a hooked_browser, directed to a target_hooked_browser # Table stores the webrtc signals from a hooked_browser, directed to a target_hooked_browser
# #
class Rtcsignal < ActiveRecord::Base class Rtcsignal < BeEF::Core::Model
attribute :id, :Serial
# The hooked browser id belongs_to :hooked_browser
attribute :hooked_browser_id, :Text, :lazy => false
# The target hooked browser id
attribute :target_hooked_browser_id, :Text, :lazy => false
# The WebRTC signal to submit. In clear text.
attribute :signal , :Text, :lazy => true
# Boolean value to say if the signal has been sent to the target peer
attribute :has_sent, :Text, :lazy => false, :default => "waiting"
end end

View File

@@ -13,28 +13,9 @@ module Models
# #
class Rtcstatus < ActiveRecord::Base class Rtcstatus < BeEF::Core::Model
attribute :id, :Serial
# The hooked browser id
attribute :hooked_browser_id, :Text, :lazy => false
# The hooked browser's IP
# property :hooked_browser_ip, Text, :lazy => false
# The target hooked browser id
attribute :target_hooked_browser_id, :Text, :lazy => false
# The target hooked browser's IP
# property :target_hooked_browser_ip, Text, :lazy => false
# The status field
attribute :status, :Text, :lazy => true
# Timestamps
attribute :created_at, DateTime
attribute :updated_at, DateTime
belongs_to :hooked_browser
end end

View File

@@ -177,7 +177,7 @@ module BeEF
begin begin
id = params[:id] id = params[:id]
events = BeEF::Core::Models::Rtcstatus.all(:hooked_browser_id => id) events = BeEF::Core::Models::Rtcstatus.where(:hooked_browser_id => id)
events_json = [] events_json = []
count = events.length count = events.length
@@ -227,7 +227,7 @@ module BeEF
begin begin
id = params[:id] id = params[:id]
events = BeEF::Core::Models::Rtcmodulestatus.all(:hooked_browser_id => id) events = BeEF::Core::Models::Rtcmodulestatus.where(:hooked_browser_id => id)
events_json = [] events_json = []
count = events.length count = events.length
@@ -301,13 +301,13 @@ module BeEF
raise InvalidParamError, 'message' if message.nil? raise InvalidParamError, 'message' if message.nil?
if message === "!gostealth" if message === "!gostealth"
stat = BeEF::Core::Models::Rtcstatus.first(:hooked_browser_id => fromhb.to_i, :target_hooked_browser_id => tohb.to_i) || nil stat = BeEF::Core::Models::Rtcstatus.where(:hooked_browser_id => fromhb.to_i, :target_hooked_browser_id => tohb.to_i).first || nil
unless stat.nil? unless stat.nil?
stat.status = "Selected browser has commanded peer to enter stealth" stat.status = "Selected browser has commanded peer to enter stealth"
stat.updated_at = Time.now stat.updated_at = Time.now
stat.save stat.save
end end
stat2 = BeEF::Core::Models::Rtcstatus.first(:hooked_browser_id => tohb.to_i, :target_hooked_browser_id => fromhb.to_i) || nil stat2 = BeEF::Core::Models::Rtcstatus.where(:hooked_browser_id => tohb.to_i, :target_hooked_browser_id => fromhb.to_i).first || nil
unless stat2.nil? unless stat2.nil?
stat2.status = "Peer has commanded selected browser to enter stealth" stat2.status = "Peer has commanded selected browser to enter stealth"
stat2.updated_at = Time.now stat2.updated_at = Time.now
@@ -382,8 +382,7 @@ module BeEF
# Find the module, modify it, send it to be executed on the tohb # Find the module, modify it, send it to be executed on the tohb
# Validate the command module by ID # Validate the command module by ID
command_module = BeEF::Core::Models::CommandModule.first( command_module = BeEF::Core::Models::CommandModule.find(cmdid)
:id => cmdid)
error 404 if command_module.nil? error 404 if command_module.nil?
error 404 if command_module.path.nil? error 404 if command_module.path.nil?