Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/ipec/s2c_dns_tunnel/module.rb
1873 views
1
#
2
# Copyright (c) 2006-2026 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
class S2c_dns_tunnel < BeEF::Core::Command
7
def self.options
8
@configuration = BeEF::Core::Configuration.instance
9
zone = @configuration.get('beef.extension.s2c_dns_tunnel.zone')
10
[
11
{ 'name' => 'payload_name', 'ui_label' => 'Payload Name', 'type' => 'text', 'width' => '400px', 'value' => 'dnsTunnelPayload' },
12
{ 'name' => 'zone', 'ui_label' => 'Zone', 'type' => 'hidden', 'width' => '400px', 'value' => zone },
13
{ 'name' => 'data', 'ui_label' => 'Message', 'type' => 'textarea',
14
'value' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ' \
15
'ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco ' \
16
'laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in ' \
17
'voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat ' \
18
'non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
19
'width' => '400px', 'height' => '100px' }
20
]
21
end
22
23
def pre_send
24
@configuration = BeEF::Core::Configuration.instance
25
enable = @configuration.get('beef.extension.s2c_dns_tunnel.enable')
26
raise ArgumentError, 's2c_dns_tunnel extension is disabled' if enable != true
27
28
# gets the value configured in the module configuration by the user
29
@datastore.each do |input|
30
@data = input['value'] if input['name'] == 'data'
31
end
32
33
BeEF::Extension::ServerClientDnsTunnel::Server.instance.messages.store(@command_id.to_i, @data.unpack1('B*'))
34
end
35
36
def post_execute
37
# gets the value of command_id from BeEF database and delete the message from DNS "database"
38
cid = @datastore['cid'].to_i
39
BeEF::Extension::ServerClientDnsTunnel::Server.instance.messages.delete(cid)
40
end
41
end
42
43