Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/webrtc/models/rtcmanage.rb
1154 views
1
#
2
# Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
module BeEF
7
module Core
8
module Models
9
#
10
# Table stores the queued up JS commands for managing the client-side webrtc logic.
11
#
12
class RtcManage < BeEF::Core::Model
13
14
# Starts the RTCPeerConnection process, establishing a WebRTC connection between the caller and the receiver
15
def self.initiate(caller, receiver, verbosity = false)
16
stunservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.stunservers")
17
turnservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.turnservers")
18
19
# Add the beef.webrtc.start() JavaScript call into the RtcManage table - this will be picked up by the browser on next hook.js poll
20
# This is for the Receiver
21
r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => receiver, :message => "beef.webrtc.start(0,#{caller},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});")
22
r.save!
23
24
# This is the same beef.webrtc.start() JS call, but for the Caller
25
r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => caller, :message => "beef.webrtc.start(1,#{receiver},JSON.stringify(#{turnservers}),JSON.stringify(#{stunservers}),#{verbosity});")
26
r.save!
27
end
28
29
# Advises a browser to send an RTCDataChannel message to its peer
30
# Similar to the initiate method, this loads up a JavaScript call to the beefrtcs[peerid].sendPeerMsg() function call
31
def self.sendmsg(from, to, message)
32
r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => from, :message => "beefrtcs[#{to}].sendPeerMsg('#{message}');")
33
r.save!
34
end
35
36
# Gets the browser to run the beef.webrtc.status() JavaScript function
37
# This JS function will return it's values to the /rtcmessage handler
38
def self.status(id)
39
r = BeEF::Core::Models::RtcManage.new(:hooked_browser_id => id, :message => "beef.webrtc.status(#{id});")
40
r.save!
41
end
42
43
end
44
45
end
46
end
47
end
48
49