Đặt bẫy khi Modem/Router bị dò mật khẩu

Mấy tháng nay tôi phát hiện modem/router bị dò mật khẩu.

Người ta dùng username/password mặc định của một số modem/router để thử đăng nhập, hết lần này sang lần khác…

Đặt bẫy

Tôi muốn tạo một trang có giao diện giống hệt modem/router đang dùng và dùng nó như một cái bẫy để có thể ghi chép những gì xảy ra. Ngoài ra, việc chuyển hướng trang giao diện modem cũng giúp modem an toàn hơn.


A. Trước hết, mở trang quản lý modem/router, giao diện đầu tiên là nhập username/password. Lưu source của trang này (Save Page -> Web page, complete). Tôi dùng FireFox và modem HG8045A của VNPT, kết quả thu được như sau:

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/login.css?201512090012241330295553184798"  media="all" rel="stylesheet" />
<link href="css/Style.css?201512090012241330295553184798" type='text/css' rel="stylesheet">
<style type="text/css">
#first{
background-color:white;
height:25px;
text-align: center;
color: red;
position:absolute;
width: 380px;
top: 312px;
}
</style>
<script language="JavaScript" src="../resource/common/md5.js?201512090012241330295553184798"></script>
<script language="JavaScript" src="../resource/common/RndSecurityFormat.js?201512090012241330295553184798"></script>
<script language="JavaScript" src="../resource/common/jquery.min.js?201512090012241330295553184798"></script>
<script language="JavaScript" src="../../resource/common/safelogin.js?201512090012241330295553184798"></script>
<script language="JavaScript" type="text/javascript">

function MD5(str) { return hex_md5(str); }

var FailStat ='0';
var CfgMode ='VNPT';
var LoginTimes = 0;
var ProductName = 'HG8045A';
var Var_DefaultLang = 'english';
var Var_LastLoginLang = 'english';
var LockTime = '60';
var LockLeftTime = '0';
var errloginlockNum = '3';
var errVerificationCode = '0';
var Language = '';
var locklefttimerhandle;
var SonetFlag = '0';
LoginTimes = Number(/^(?:.+;)?\s*retry=1(?:.+)?$/m.test(document.cookie));
if(Var_LastLoginLang == '')
{
Language = Var_DefaultLang;
}
else
{
Language = Var_LastLoginLang;
}

document.title = ProductName;

function getValue(sId)
{
var item;
if (null == (item = getElement(sId)))
{
debug(sId + " is not existed" );
return -1;
}

return item.value;
}

function showlefttime()
{
if(LockLeftTime <= 0)
{
window.location="/login.asp";
return;
}

if(LockLeftTime == 1)
{
if(Language == 'portuguese')
{
if('PTVDF' == CfgMode.toUpperCase())
{
var errhtml = 'Demasiadas tentativas, volte a tentar daqui a ' +  LockLeftTime + ' segundo';
}
else
{
var errhtml = 'Demasiadas tentativas, tente ' +  LockLeftTime + ' segundos mais tarde';
}
}
else if(Language == 'japanese')
{
var errhtml = '再試行回数が多すぎます。' +  LockLeftTime + '秒後に再試行してください。';
}
else if(Language == 'spanish')
{
var errhtml = 'Ha intentado muchas veces. Vuelva a intentarlo dentro de ' +  LockLeftTime + ' segundo/s.';
}
else if(Language == 'russian')
{
var errhtml = 'Слишком много попыток. Попробуйте снова через ' +  LockLeftTime + ' с.';
}
else
{
if('PTVDF' == CfgMode.toUpperCase())
{
var errhtml = 'Too many retries, please retry in ' +  LockLeftTime + ' second.';
}
else
{
var errhtml = 'Too many retrials, please retry ' +  LockLeftTime + ' second later.';
}
}
}
else
{
if(Language == 'portuguese')
{
if('PTVDF' == CfgMode.toUpperCase())
{
var errhtml = 'Demasiadas tentativas, volte a tentar daqui a ' +  LockLeftTime + ' segundos';
}
else
{
var errhtml = 'Demasiadas tentativas, tente ' +  LockLeftTime + ' segundos mais tarde.';
}
}
else if(Language == 'japanese')
{
var errhtml = '再試行回数が多すぎます。' +  LockLeftTime + '秒後に再試行してください。';
}
else if(Language == 'spanish')
{
var errhtml = 'Ha intentado muchas veces. Vuelva a intentarlo dentro de ' +  LockLeftTime + ' segundos.';
}
else if(Language == 'russian')
{
var errhtml = 'Слишком много попыток. Попробуйте снова через ' +  LockLeftTime + ' с.';
}
else
{
if('PTVDF' == CfgMode.toUpperCase())
{
var errhtml = 'Too many retries, please retry in ' +  LockLeftTime + ' seconds.';
}
else
{
var errhtml = 'Too many retrials, please retry ' +  LockLeftTime + ' seconds later.';
}
}
}

SetDivValue("DivErrPage", errhtml);
LockLeftTime = LockLeftTime - 1;
}

function setErrorStatus()
{
clearInterval(locklefttimerhandle); 
    if('1' == FailStat)
{
   
if(Language == 'portuguese')
{
var errhtml = "Demasiadas tentativas.";
}
else if(Language == 'japanese')
{
var errhtml = "再試行回数が多すぎます。";
}
else if(Language == 'spanish')
{
var errhtml = "Ha intentado muchas veces.";
}
else if(Language == 'russian')
{
var errhtml = 'Слишком много попыток.';
}
else
{
var errhtml = 'Too many retrials.';
}
SetDivValue("DivErrPage", errhtml);
setDisable('txt_Username',1);
setDisable('txt_Password',1);
if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
setDisable('VerificationCode',1);
setDisable('tripletbtn',1);
}
setDisable('button',1);
}
else if(LoginTimes >= errloginlockNum && parseInt(LockLeftTime) > 0)
{
if(Language == 'portuguese')
{
if('PTVDF' == CfgMode.toUpperCase())
{
var errhtml = 'Demasiadas tentativas, volte a tentar daqui a ' +  LockLeftTime + ' segundos';
}
else
{
var errhtml = 'Demasiadas tentativas, tente ' +  LockLeftTime + ' segundos mais tarde.';
}
}
else if(Language == 'japanese')
{
var errhtml = '再試行回数が多すぎます。' +  LockLeftTime + ' 秒後に再試行してください。';
}
else if(Language == 'spanish')
{
var errhtml = 'Ha intentado muchas veces. Vuelva a intentarlo dentro de ' +  LockLeftTime + ' segundos.';
}
else if(Language == 'russian')
{
var errhtml = 'Слишком много попыток. Попробуйте снова через ' +  LockLeftTime + ' с.';
}
else
{
if('PTVDF' == CfgMode.toUpperCase())
{
var errhtml = 'Too many retries, please retry in ' +  LockLeftTime + ' seconds.';
}
else
{
var errhtml = 'Too many retrials, please retry ' +  LockLeftTime + ' seconds later.';
}
}

SetDivValue("DivErrPage", errhtml); 
setDisable('txt_Username',1);
setDisable('txt_Password',1);
if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
setDisable('VerificationCode',1);
setDisable('tripletbtn',1);
}
setDisable('button',1);
locklefttimerhandle = setInterval('showlefttime()', 1000);
}
else if( 1== errVerificationCode)
{
SetDivValue("DivErrPage", "Incorrect validate code.");
}
else if( 2== errVerificationCode)
{
SetDivValue("DivErrPage", "Login failure.");
}
else if((LoginTimes > 0) && (LoginTimes < errloginlockNum)) 
{
if(Language == 'portuguese')
{
var errhtml = "Nome de conta ou palavra-passe inválidos. Tente novamente.";
}
else if(Language == 'japanese')
{
var errhtml = "アカウントとパスワードの組み合わせが不正確です。 もう一度やり直してください。";
}
else if(Language == 'spanish')
{
var errhtml = "La combinación de la usuario/contraseña es incorrecta. Favor de volver a intentarlo.";
}
else if(Language == 'russian')
{
var errhtml = 'Неверное имя аккаунта или пароль. Повторите попытку.';
}
else if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
var errhtml = 'Login failure.';
}
else
{
var errhtml = 'Incorrect account/password combination. Please try again.';
}

SetDivValue("DivErrPage", errhtml);
}
else
{
document.getElementById('loginfail').style.display = 'none';
}
}


function SubmitForm() {
    var Username = document.getElementById('txt_Username');
    var Password = document.getElementById('txt_Password');
var appName = navigator.appName;
var version = navigator.appVersion;
  
if(Language == "portuguese")
{
if (appName == "Microsoft Internet Explorer")
{
var versionNumber = version.split(" ")[3];
if (parseInt(versionNumber.split(";")[0]) < 6)
{
alert("Versões IE inferiores a 6.0 não são compatíveis.");
return false;
}
}

if (Username.value == "") {
alert("Conta não pode ficar em branco.");
Username.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("Nome de conta inválido.");
Username.focus();
return false;
}

if (Password.value == "") {
alert("Palavra-passe não pode ficar em branco.");
Password.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("Palavra-passe inválida.");
Password.focus();
return false;
}
}
else if(Language == "japanese")
{
if (appName == "Microsoft Internet Explorer")
{
var versionNumber = version.split(" ")[3];
if (parseInt(versionNumber.split(";")[0]) < 6)
{
alert("6.0以前のIEバージョンには対応していません。");
return false;
}
}

if (Username.value == "") {
alert("アカウントは必須項目です。");
Username.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("アカウントは無効です。");
Username.focus();
return false;
}

if (Password.value == "") {
alert("パスワードは必須項目です。");
Password.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("パスワードは無効です。");
Password.focus();
return false;
}
}
else if(Language == "spanish")
{
if (appName == "Microsoft Internet Explorer")
{
var versionNumber = version.split(" ")[3];
if (parseInt(versionNumber.split(";")[0]) < 6)
{
alert("No se puede soportar la versión de IE inferior a la 6.0.");
return false;
}
}

if (Username.value == "") {
alert("La usuario es un campo obligatorio.");
Username.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("La usuario es invalida.");
Username.focus();
return false;
}

if (Password.value == "") 
{
alert("La contraseña es un campo requerido.");
Password.focus();
        return false;
}

if (!isValidAscii(Password.value))
{
alert("La contraseña es invalida.");
Password.focus();
return false;
}
}
else if(Language == "russian")
{
if (appName == "Microsoft Internet Explorer")
{
var versionNumber = version.split(" ")[3];
if (parseInt(versionNumber.split(";")[0]) < 6)
{
alert("Версии браузера IE меньше 6.0 не поддерживаются.");
return false;
}
}

if (Username.value == "") {
alert("Введите имя аккаунта.");
Username.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("Недействительный аккаунт.");
Username.focus();
return false;
}

if (Password.value == "") {
alert("Введите пароль.");
Password.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("Недействительный пароль.");
Password.focus();
return false;
}

}
else
{
if (appName == "Microsoft Internet Explorer")
{
var versionNumber = version.split(" ")[3];
if (parseInt(versionNumber.split(";")[0]) < 6)
{
alert("We cannot support the IE version which is lower than 6.0.");
return false;
}
}

if (Username.value == "") {
    if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
alert("User Name is a required field.");
}
else
{
alert("Account is a required field.");
}

Username.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
    alert("User Name is invalid.");
}
else
{
alert("Account is invalid.");
}

Username.focus();
return false;
}

if (Password.value == "") {
alert("Password is a required field.");
Password.focus();
        return false;
}

if (!isValidAscii(Username.value))
{
alert("Password is invalid.");
Password.focus();
return false;
}

}

    var cookie = document.cookie;
    if ("" != cookie)
    {
     var date=new Date();
     date.setTime(date.getTime()-10000);
     var cookie22 = cookie + ";expires=" + date.toGMTString();
     document.cookie=cookie22;
    }

var cnt;

$.ajax({
type : "POST",
async : false,
cache : false,
url : 'login.cgi.php',
success : function(data) {
cnt = data;
}
});

var Form = new webSubmitForm();
if('DT' == CfgMode.toUpperCase())
{
var cookie2 = "Cookie=" + "rid=" + RndSecurityFormat("" + cnt) + RndSecurityFormat(Username.value + cnt ) + RndSecurityFormat(RndSecurityFormat(MD5(Password.value)) + cnt) + ":" + "Language:" + Language + ":" +"id=-1;path=/";
}
else
{
var cookie2 = "Cookie=" + "UserName:" + Username.value + ":" + "PassWord:" + base64encode(Password.value) + ":" + "Language:" + Language + ":" + "id=-1;path=/";
}
    document.cookie = cookie2;

    Username.disabled = true;
    Password.disabled = true;

if('TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
Form.addParameter('CheckCode', getValue('VerificationCode'));
Form.setAction('login.cgi.php?' +'&CheckCodeErrFile=login.asp');
}
else
{
Form.setAction('login.cgi.php');
}
Form.addParameter('x.X_HW_Token', cnt);
Form.submit();
    return true;
}

function LoadFrame() {

    document.getElementById('txt_Username').focus();
clearInterval(locklefttimerhandle);

    var UserLeveladmin = '1';
    
    if(Language == "portuguese")
{
        document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'Conta';
document.getElementById('Password').innerHTML = 'Palavra-passe';
document.getElementById('button').innerHTML = 'Iniciar sessão';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. Todos os direitos reservados.';
    }
else if(Language == "japanese")
{
        document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'アカウント';
document.getElementById('Password').innerHTML = 'パスワード';
document.getElementById('button').innerHTML = 'ログイン';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. All rights reserved.';
    }
else if(Language == "spanish")
{
        document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'Usuario';
document.getElementById('Password').innerHTML = 'Contraseña';
document.getElementById('button').innerHTML = 'Iniciar sesión';
document.getElementById('footer').innerHTML = 'Copyright © Tecnologias Huawei Co., Ltd 2009-2015. Todos los derechos reservados.';
    }
else if(Language == "russian")
{
document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'Аккаунт';
document.getElementById('Password').innerHTML = 'Пароль';
document.getElementById('button').innerHTML = 'Вход';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. Все права защищены.';
    }
    else 
{
document.getElementById('Specical_language').style.color = '#434343';
        document.getElementById('English').style.color = '#9b0000';
if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
   document.getElementById('account').innerHTML = 'User Name';
}
else
{
document.getElementById('account').innerHTML = 'Account';
}

document.getElementById('Password').innerHTML = 'Password';
document.getElementById('button').innerHTML = 'Login';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. All rights reserved';
    }

    if ((LoginTimes != null) && (LoginTimes != '') && (LoginTimes > 0)) {
        document.getElementById('loginfail').style.display = '';
setErrorStatus();
    }
if( "1" == FailStat)
{
document.getElementById('loginfail').style.display = '';
setErrorStatus();
}
    init();

if((UserLeveladmin == '0')) 
{
if(Language == "portuguese")
{
alert("O administrador não tem autorização para abrir esta página de Internet.");
return false;
}
else if(Language == "japanese")
{
alert("管理者はこのウェブページの閲覧を許可されていません。");
return false;
}
else if (Language == "spanish") 
{
alert("El administrador no puede abrir esta página.");
return false;
}
else if (Language == "russian")
{
alert("У текущего пользователя нет права входа.");
return false;
}
else
{
alert("The current user is not allowed to log in.");
return false;
}
    } 
 }

function init() {
    if (document.addEventListener) {
        document.addEventListener("keypress", onHandleKeyDown, false);
    } else {
        document.onkeypress = onHandleKeyDown;
    }
}
function onHandleKeyDown(event) {
    var e = event || window.event;
    var code = e.charCode || e.keyCode;

    if (code == 13) {
        SubmitForm();
    }
}
function onChangeLanguage(language) {
    Language = language;
if(language == "portuguese")
{
        document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'Conta';
document.getElementById('Password').innerHTML = 'Palavra-passe';
document.getElementById('button').innerHTML = 'Iniciar sessão';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. Todos os direitos reservados.';
    }
else if(language == "japanese")
{
        document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'アカウント';
document.getElementById('Password').innerHTML = 'パスワード';
document.getElementById('button').innerHTML = 'ログイン';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. All rights reserved.';
    }
    else if (language == "spanish") 
    {
        document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'Usuario';
document.getElementById('Password').innerHTML = 'Contraseña';
document.getElementById('button').innerHTML = 'Iniciar sesión';
document.getElementById('footer').innerHTML = 'Copyright © Tecnologias Huawei Co., Ltd 2009-2015. Todos los derechos reservados.';
    }
else if (language == "russian") 
{
document.getElementById('Specical_language').style.color = '#9b0000';
        document.getElementById('English').style.color = '#434343';
document.getElementById('account').innerHTML = 'Аккаунт';
document.getElementById('Password').innerHTML = 'Пароль';
document.getElementById('button').innerHTML = 'Вход';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. Все права защищены.';
    }
else 
{
document.getElementById('Specical_language').style.color = '#434343';
        document.getElementById('English').style.color = '#9b0000';
document.getElementById('account').innerHTML = 'Account';
document.getElementById('Password').innerHTML = 'Password';
document.getElementById('button').innerHTML = 'Login';
document.getElementById('footer').innerHTML = 'Copyright © Huawei Technologies Co., Ltd 2009-2015. All rights reserved.';
    }

if (((LoginTimes != null) && (LoginTimes != '') && (LoginTimes > 0))
   ||( "1" == FailStat) ) 
{
document.getElementById('loginfail').style.display = '';
setErrorStatus();
    }
}

function BthRefresh()
{
document.getElementById("imgcode").src = 'getCheckCode.cgi?&rand=' + new Date().getTime();
}
</script>
</head>
<body onLoad="LoadFrame();"> 
<div id="main_wrapper"> 
<div style="position:absolute; top:300px;margin-left:250px;height:300px; width:490px;background: url('images/pic.jpg') no-repeat center;">
<table id="tablecheckcode" border="0" cellpadding="0" cellspacing="0" width="100%" style="display: none">
<tr>
<td height="8"></td>
</tr> 
<tr> 
        <td>
<img id="imgcode" style="margin-left:111px;height:30px;width:100px;" onClick="BthRefresh();">
<input type="button" id="changecode" style="margin-left:20px;width:58px;" class="submit" value="Refresh" onClick="BthRefresh();"/>
</td> 
</tr>

<tr>
<td height="8"></td>
</tr> 
<tr align="center"> 
<td> 
 <button style="font-size:12px;font-family:Tahoma,Arial;margin-left:-70px;" id="tripletbtn" class="submit" name="tripletbtn" onClick="SubmitForm();" type="button">Login</button>
</td> 
  </tr>
    <tr> 
      <td class="info_text" height="25" id="tipletfooter"><span style="margin-left:-55px;">Copyright © Huawei Technologies Co., Ltd 2009-2015. All rights reserved.</span></td> 
    </tr> 
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr id="Copyrightfooter" style="position:absolute; margin-left:20px;top:-25px;display: none;color:#9d9d9d;">
<td height="25" id="footer" style="font-size:11px;"></td>
</tr>
<tr> 
<td valign="top" style="padding-top: 20px;"> <div id="loginfail" style="display: none"> 
<table border="0" cellpadding="0" cellspacing="5" height="33" width="99%"> 
  <tr> 
<td align="center" bgcolor="#FFFFFF" height="21"> <span style="color:red;font-size:12px;font-family:Arial;"> 
  <div id="DivErrPage"></div> 
  </span> </td> 
  </tr> 
</table> 
  </div>
  </td> 
  </tr> 
</table>
</div> 
  <table border="0" cellpadding="0" cellspacing="0" width="100%"> 
    <tr> 
    <script language="JavaScript" type="text/javascript">
if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
document.write('<td align="center" height="210" valign="bottom"> <table border="0" cellpadding="0" cellspacing="0" width="44%"> ');
}
else if (( 'DIGICEL' == CfgMode.toUpperCase()) || ( 'DIGICEL2' == CfgMode.toUpperCase()))
{
  document.write('<td align="center" height="210" valign="bottom"> <table border="0" cellpadding="0" cellspacing="0" width="36%"> ');
}
else
{
document.write('<td align="center" height="210" valign="bottom"> <table border="0" cellpadding="0" cellspacing="0" width="36%"> ');
}
</script> 
          <tr> 
            
            <script language="JavaScript" type="text/javascript">

 if (( 'DIGICEL' == CfgMode.toUpperCase()) || ( 'DIGICEL2' == CfgMode.toUpperCase()))
                {
                    document.write('<td align="center" width="70%"> ');                        
                }
                else
                {
                    document.write('<td align="center" width="29%"> ');         
                }

if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
document.write('<img height="70" src="images/logo3bb.gif" width="144" alt="">');
}
else if ('ORANGEMT' == CfgMode.toUpperCase())
{
document.write('<img height="118" src="images/logo_MA.gif" width="118" alt="">');
}
else if('NOS' == CfgMode.toUpperCase())
{
document.write('<img height="72" src="images/logo_nos.gif" width="136" alt="">');
}
else if('ANTEL' == CfgMode.toUpperCase())
{
document.write('<img height="36" src="images/logo_antel.gif" width="100" alt="">');
}
else if (1 == SonetFlag)
{
    document.write('<img height="0" src="images/logo.gif" width="0" alt="">');
}
else if (( 'DIGICEL' == CfgMode.toUpperCase()) || ( 'DIGICEL2' == CfgMode.toUpperCase()))
{
document.write('<img height="72" src="images/logo_digicel.jpg" width="127" alt="">');
}
else
{
document.write('<img height="75" src="images/logo.gif" width="70" alt="">');
}
</script> 
            </td> 
<script language="JavaScript" type="text/javascript">
if (( 'DIGICEL' == CfgMode.toUpperCase()) || ( 'DIGICEL2' == CfgMode.toUpperCase()))
                {
                    document.write('<td class="hg_logo" width="11%" id="hg_logo" nowrap>');
                }
                else
                {
                    document.write('<td class="hg_logo" width="21%" id="hg_logo" nowrap>');  
                }

if (( 'DIGICEL' != CfgMode.toUpperCase()) && ( 'DIGICEL2' != CfgMode.toUpperCase()))
                    {
   document.write(ProductName);
                    }    
</script> </td> 
            
<script language="JavaScript" type="text/javascript"> 
                    if (( 'DIGICEL' == CfgMode.toUpperCase()) || ( 'DIGICEL2' == CfgMode.toUpperCase()))
                    {
                        document.write('<td valign="bottom" width="19%">');
                    }
                    else
                    {
                        document.write('<td valign="bottom" width="50%">');
                    }
                   </script>
<table border="0" cellpadding="0" cellspacing="0" class="text_copyright" width="100%"> 
                <tr> 
                  <script language="JavaScript" type="text/javascript">
                  if (1 == SonetFlag)
                  {
                  document.write('<td width="47%" nowrap> <a id="English" href="#" name="English" onClick="onChangeLanguage(' + "'english'" + ');" style="font-size:12px;font-family:Arial;">[English]</a> </td>');
                  document.write('<td width="53%" nowrap> <a id="Specical_language" href="#" name="Specical_language" onClick="onChangeLanguage(' + "'japanese'" + ');" style="font-size:12px;font-family:Arial;">[日本語]</a> </td>');
                  }
                  else if ('PTVDF' == CfgMode.toUpperCase())
                  {
                  document.write('<td width="47%" nowrap> <a id="English" href="#" name="English" onClick="onChangeLanguage(' + "'english'" + ');" style="font-size:12px;font-family:Arial;">[English]</a> </td>');
                  document.write('<td width="53%" nowrap> <a id="Specical_language" href="#" name="Specical_language" onClick="onChangeLanguage(' + "'portuguese'" + ');" style="font-size:12px;font-family:Arial;">[Portuguese]</a> </td>');
                  }
                  else if ('ANTEL' == CfgMode.toUpperCase())
                  {
                  document.write('<td width="47%" nowrap> <a id="English" href="#" name="English" onClick="onChangeLanguage(' + "'english'" + ');" style="font-size:12px;font-family:Arial;">[English]</a> </td>');
                  document.write('<td width="53%" nowrap> <a id="Specical_language" href="#" name="Specical_language" onClick="onChangeLanguage(' + "'spanish'" + ');" style="font-size:12px;font-family:Arial;">[Spanish]</a> </td>');
                  }
else if ('UZBEKISTAN' == CfgMode.toUpperCase() || 'ROSTELECOM' == CfgMode.toUpperCase()
  || 'ROSCNT' == CfgMode.toUpperCase() || 'NWT' == CfgMode.toUpperCase())
                  {
                  document.write('<td width="47%" nowrap> <a id="English" href="#" name="English" onClick="onChangeLanguage(' + "'english'" + ');" style="font-size:12px;font-family:Arial;">[English]</a> </td>');
                  document.write('<td width="53%" nowrap> <a id="Specical_language" href="#" name="Specical_language" onClick="onChangeLanguage(' + "'russian'" + ');" style="font-size:12px;font-family:Arial;">[Русский]</a> </td>');
                  }
                  else
                  {
                  document.write('<td width="47%" nowrap> <a id="English" href="#" name="English" style="font-size:12px;font-family:Arial;"></a> </td>');
                  document.write('<td width="53%" nowrap> <a id="Specical_language" href="#" name="Specical_language"  style="font-size:12px;font-family:Arial;"></a> </td>');
                  }
                  </script>
                </tr> 
              </table></td> 
          </tr> 
        </table></td> 
    </tr> 
    <tr> 
      <td align="center" height="65"> <table border="0" cellpadding="0" cellspacing="0" class="tblcalss" height="65" width="55%" style="margin-left:60px; font-size:16px;"> 
          <tr> 
            <td class="whitebold" height="37" align="right" width="20%" id="account"></td> 
            <td class="whitebold" height="37" align="center" width="2%">:</td> 
            <td width="78%"> <input style="font-size:12px;font-family:Tahoma,Arial;" id="txt_Username" class="input_login" name="txt_Username" type="text" maxlength="31"> </td> 
          </tr> 
          <tr> 
            <td class="whitebold" height="28" align="right" id="Password"></td> 
            <td class="whitebold" height="28" align="center" >:</td> 
            <td> <input style="font-size:12px;font-family:Tahoma,Arial;" id="txt_Password" class="input_login" name="txt_Password" type="password" maxlength="127"> 
&nbsp; 
<button style="font-size:12px;font-family:Tahoma,Arial;display: none;" id="button" class="submit" name="Submit" onClick="SubmitForm();" type="button"></button>
            </td> 
          </tr>

          <tr id="txtVerificationCode" style="display: none"> 
            <td class="whitebold" height="28" align="right" id="Validate">Validate code</td> 
            <td class="whitebold" height="32" align="center" >:</td> 
            <td> 
<input style="font-size:12px;font-family:Tahoma,Arial;height:21px;" id="VerificationCode" class="input_login" name="VerificationCode" type="text" maxlength="127"></td> 
          </tr>
  
        </table></td> 
    </tr> 
  </table> 
</div> 
<script language="JavaScript" type="text/javascript">
if ( 'TRIPLET' == CfgMode.toUpperCase() || 'TRIPLETVOICE' == CfgMode.toUpperCase())
{
document.getElementById('tablecheckcode').style.display = '';
document.getElementById('txtVerificationCode').style.display = '';
document.getElementById("imgcode").src = 'getCheckCode.cgi?&rand=' + new Date().getTime();
}
else
{
document.getElementById('Copyrightfooter').style.display = '';
document.getElementById('button').style.display = '';
}
</script>
</body>
</html>

Quá dài và phức tạp! Thậm chí là quá nhiều lỗi lập trình. Tuy nhiên chúng ta chỉ cần sao chép giao diện mà không quan tâm đến các vấn đề khác.

Nếu chúng ta ghi file với tên là HG8045A.html thì chúng ta có các file thành phần nằm trong thư mục HG8045A, vì vậy cần phải chỉnh sửa các đường dẫn:

  • Tìm và thay thế resource/common/ thành HG8045A/
  • Tìm và thay thế css/ thành HG8045A/
  • Tìm và thay thế images/ thành HG8045A/ (ngay cả ở file login.css)

B. Thêm vào/Sửa như ở 3 vị trí được đánh dấu đỏ trong đoạn code trên.

C. Như vậy ta đã giả mạo được giao diện của modem HG8045A. Tiếp theo là tạo file login.cgi.php để ghi chép những thông tin cần thiết khi bị ai đó dò mật khẩu.

<?php
$tmp = $_COOKIE['Cookie'];
$s1 = strpos($tmp, 'UserName:', 0);
if ($s1 !== false){
    $s1 += strlen('UserName:');
    $e1 = strpos($tmp, ':', $s1);
    $s2 = strpos($tmp, 'PassWord:', 0) + strlen('PassWord:');
    $e2 = strpos($tmp, ':', $s2);
    $data = 'user=' . substr($tmp, $s1, $e1-$s1) . ', password=' . base64_decode(substr($tmp, $s2, $e2-$s2)) ;
    $tmp = date('Ymd-His O').", ip=$_SERVER[REMOTE_ADDR], $data\n";
    file_put_contents('honey_bot.log', $tmp, FILE_APPEND);
    if (!isset($_COOKIE['retry'])) setcookie('retry', '1');
    header('Location: index.html');
}
exit();
?>

D. Cuối cùng chép tất cả file vào thư mục www,  đổi tên file HG8045A.html thành index.html và chuyển hướng Internet_IP:80 vào web server (thí dụ RPi_IP:80).

Kết quả

Khi tôi đang viết những dòng này thì người ta vẫn đang dò mật khẩu của modem. Tôi đã điện thoại báo cho kỹ thuật VNPT nhưng không hy vọng họ giúp được gì, vì tôi gởi tư liệu theo yêu cầu qua email nhưng họ không trả lời gì cả.

screenshot-2016-11-18-19-51-47

Phần lớn các IP thu thập được thuộc Nga, China, … Tuy nhiên, theo thống kê của AbuseIPDB.com (11/20/2016), Việt Nam chiếm thứ hạng cao về quốc gia có IP bị phàn nàn

screenshot-2016-11-20-11-11-55Báo cáo về AbuseIPDB.com nếu bạn bị làm phiền.

Download source code

 

Leave a Comment

Filed under Software

Leave a Reply

Your email address will not be published. Required fields are marked *