Path: blob/master/extensions/webrtc/models/rtcmanage.rb
1154 views
#1# Copyright (c) 2006-2025 Wade Alcorn - [email protected]2# Browser Exploitation Framework (BeEF) - https://beefproject.com3# See the file 'doc/COPYING' for copying permission4#5module BeEF6module Core7module Models8#9# Table stores the queued up JS commands for managing the client-side webrtc logic.10#11class RtcManage < BeEF::Core::Model1213# Starts the RTCPeerConnection process, establishing a WebRTC connection between the caller and the receiver14def self.initiate(caller, receiver, verbosity = false)15stunservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.stunservers")16turnservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.turnservers")1718# Add the beef.webrtc.start() JavaScript call into the RtcManage table - this will be picked up by the browser on next hook.js poll19# This is for the Receiver20r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => receiver, :message => "beef.webrtc.start(0,#{caller},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});")21r.save!2223# This is the same beef.webrtc.start() JS call, but for the Caller24r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => caller, :message => "beef.webrtc.start(1,#{receiver},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});")25r.save!26end2728# Advises a browser to send an RTCDataChannel message to its peer29# Similar to the initiate method, this loads up a JavaScript call to the beefrtcs[peerid].sendPeerMsg() function call30def self.sendmsg(from, to, message)31r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => from, :message => "beefrtcs[#{to}].sendPeerMsg('#{message}');")32r.save!33end3435# Gets the browser to run the beef.webrtc.status() JavaScript function36# This JS function will return it's values to the /rtcmessage handler37def self.status(id)38r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => id, :message => "beef.webrtc.status(#{id});")39r.save!40end4142end4344end45end46end474849