欢迎光临
我们一直在努力

批量对加密的asp代码解密的asp程序-ASP教程,ASP技巧

建站超值云服务器,限时71元/月

<% @language=”javascript” %>
<%

/*
 *————— decode.asp —————–
 * 功能:遍历某个目录下的所有文件,对加密过的.asp文件
 *      进行解密,并写入源文件中.
 * 实例:单个文件解密
 * response.write(dncodefile(server.mappath(“conn.asp”)));
 * 实例:目录下所有文件解密.
 * dncodefolderfiles(server.mappath(“xml”))
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-17 11:31
 *————— decode.asp —————–
 */

function dncodefile(sfilepath)
{
/*
 *————— dncodefile(sfilepath) —————–
 * dncodefile(sfilepath)
 * 功能:打开文件sfilepath,encode解密,重写该文件.
 * 参数:sfilepath,字符串,文件的路径.
 * 返回:sfilepath,文件的路径.
 * 实例:response.write(dncodefile(server.mappath(“conn.asp”)));
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-17 0:58
 *————— dncodefile(sfilepath) —————–
 */
    var forreading = 1, forwriting =2, forappending =8;
    var fso = server.createobject(“scripting.filesystemobject”);
    var f = fso.opentextfile(sfilepath,forreading,true);
    sfiletext = f.readall();
    f.close();
    sdncodetext = strdec(sfiletext)
    var f = fso.opentextfile(sfilepath,forwriting,true);
    f.write(sdncodetext);
    f.close();
    //return sdncodetext;
    return sfilepath;
}

function getfilespath(sfolderpath)
{
/*
 *————— getfilespath(sfolderpath) —————–
 * getfilespath(sfolderpath)
 * 功能:遍历sfolderpath目录下的所有文件.返回数组.存储文件路径.
 * 参数:sfolderpath,字符串,目录绝对路径.
 * 实例:response.write(getfilespath(server.mappath(“xml”)))
 * update:2004-5-12 8:33
 * author:wanghr100(灰豆宝宝.net)
 *————— getfilespath(sfolderpath) —————–
 */
    var sfilepath = new array();
    var fso = server.createobject(“scripting.filesystemobject”);
    var ofolder = fso.getfolder(sfolderpath);
    var osubfolders = ofolder.subfolders;
    var ofiles = ofolder.files;
    icount = ofiles.count;

    var enmfiles = new enumerator(ofiles);
    for(;!enmfiles.atend();enmfiles.movenext())
    {
        sfilepath[sfilepath.length] = enmfiles.item().path
    }

    var enmfolders = new enumerator(osubfolders);
    for(;!enmfolders.atend();enmfolders.movenext())
    {
        /* old 数组成了多维. */
        //sfilepath[sfilepath.length]=getfilespath(enmfolders.item().path);
        /* add 2004-5-17 11:09 只为一维数组 */
        sfilepath=sfilepath.concat(getfilespath(enmfolders.item().path));
    }

    return sfilepath;

}

function getfiletype(sfilename)
{
/*
 *————— getfiletype(sfilename) —————–
 * getfiletype(sfilename)
 * 功能:通过后缀,取得sfilename的文件类型.
 * 参数:sfilename,字符串,文件名.
 * 实例:response.write(getfiletype(“decode.asp”))
 * update:2004-5-13 8:33
 * author:wanghr100(灰豆宝宝.net)
 *————— getfiletype(sfilename) —————–
 */
    sfilename = string(sfilename);
    return sfilename.split(“.”)[sfilename.split(“.”).length-1];
}

/* start 解密实现:李辉煌 start*/
function screncode(s,l)
{enc=new activexobject(“scripting.encoder”);
return enc.encodescriptfile(“.”+l,s,0,l+”cript”);
}

    var state_copy_input        = 100
    var state_readlen       = 101
    var state_decode        = 102
    var state_unescape      = 103

    var pick_encoding = new array(
        1, 2, 0, 1, 2, 0, 2, 0, 0, 2, 0, 2, 1, 0, 2, 0,
        1, 0, 2, 0, 1, 1, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2,
        1, 1, 0, 2, 0, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 2,
        1, 0, 2, 0, 1, 1, 2, 0, 0, 1, 1, 2, 0, 1, 0, 2
    )

    var rawdata = new array(
        0x64,0x37,0x69, 0x50,0x7e,0x2c, 0x22,0x5a,0x65, 0x4a,0x45,0x72,
        0x61,0x3a,0x5b, 0x5e,0x79,0x66, 0x5d,0x59,0x75, 0x5b,0x27,0x4c,
        0x42,0x76,0x45, 0x60,0x63,0x76, 0x23,0x62,0x2a, 0x65,0x4d,0x43,
        0x5f,0x51,0x33, 0x7e,0x53,0x42, 0x4f,0x52,0x20, 0x52,0x20,0x63,
        0x7a,0x26,0x4a, 0x21,0x54,0x5a, 0x46,0x71,0x38, 0x20,0x2b,0x79,
        0x26,0x66,0x32, 0x63,0x2a,0x57, 0x2a,0x58,0x6c, 0x76,0x7f,0x2b,
        0x47,0x7b,0x46, 0x25,0x30,0x52, 0x2c,0x31,0x4f, 0x29,0x6c,0x3d,
        0x69,0x49,0x70, 0x3f,0x3f,0x3f, 0x27,0x78,0x7b, 0x3f,0x3f,0x3f,
        0x67,0x5f,0x51, 0x3f,0x3f,0x3f, 0x62,0x29,0x7a, 0x41,0x24,0x7e,
        0x5a,0x2f,0x3b, 0x66,0x39,0x47, 0x32,0x33,0x41, 0x73,0x6f,0x77,
        0x4d,0x21,0x56, 0x43,0x75,0x5f, 0x71,0x28,0x26, 0x39,0x42,0x78,
        0x7c,0x46,0x6e, 0x53,0x4a,0x64, 0x48,0x5c,0x74, 0x31,0x48,0x67,
        0x72,0x36,0x7d, 0x6e,0x4b,0x68, 0x70,0x7d,0x35, 0x49,0x5d,0x22,
        0x3f,0x6a,0x55, 0x4b,0x50,0x3a, 0x6a,0x69,0x60, 0x2e,0x23,0x6a,
        0x7f,0x09,0x71, 0x28,0x70,0x6f, 0x35,0x65,0x49, 0x7d,0x74,0x5c,
        0x24,0x2c,0x5d, 0x2d,0x77,0x27, 0x54,0x44,0x59, 0x37,0x3f,0x25,
        0x7b,0x6d,0x7c, 0x3d,0x7c,0x23, 0x6c,0x43,0x6d, 0x34,0x38,0x28,
        0x6d,0x5e,0x31, 0x4e,0x5b,0x39, 0x2b,0x6e,0x7f, 0x30,0x57,0x36,
        0x6f,0x4c,0x54, 0x74,0x34,0x34, 0x6b,0x72,0x62, 0x4c,0x25,0x4e,
        0x33,0x56,0x30, 0x56,0x73,0x5e, 0x3a,0x68,0x73, 0x78,0x55,0x09,
        0x57,0x47,0x4b, 0x77,0x32,0x61, 0x3b,0x35,0x24, 0x44,0x2e,0x4d,
        0x2f,0x64,0x6b, 0x59,0x4f,0x44, 0x45,0x3b,0x21, 0x5c,0x2d,0x37,
        0x68,0x41,0x53, 0x36,0x61,0x58, 0x58,0x7a,0x48, 0x79,0x22,0x2e,
        0x09,0x60,0x50, 0x75,0x6b,0x2d, 0x38,0x4e,0x29, 0x55,0x3d,0x3f
    )

    var transformed = new array()
    for (var i=0; i<3; i++) transformed[i] = new array()
    for (var i=31; i<=126; i++) for (var j=0; j<3; j++) transformed[j][rawdata[(i-31) * 3 + j]] = (i==31) ? 9 : i
   
    var digits = new array()
    for (var i=0; i<26; i++)
    {
        digits[“a”.charcodeat(0)+i] = i
        digits[“a”.charcodeat(0)+i] = i+26
    }
    for (var i=0; i<10; i++)    digits[“0”.charcodeat(0)+i] = i+52
    digits[0x2b] = 62
    digits[0x2f] = 63

    function unescape(char)
    {
        var escapes = “#&!*$”
        var escaped = “\r\n<>@”

        if (char.charcodeat(0) > 126)   return char
        if (escapes.indexof(char) != -1)    return escaped.substr(escapes.indexof(char), 1)
        return “?”
    }
   
    function decodebase64(string)
    {
        var val = 0
        val +=  (digits[string.substr(0,1).charcodeat(0)] << 2)
        val +=  (digits[string.substr(1,1).charcodeat(0)] >> 4)
        val +=  (digits[string.substr(1,1).charcodeat(0)] & 0xf) << 12
        val += ((digits[string.substr(2,1).charcodeat(0)] >> 2) << 8)
        val += ((digits[string.substr(2,1).charcodeat(0)] & 0x3) << 22)
        val +=  (digits[string.substr(3,1).charcodeat(0)] << 16)
        return val
    }

    function strdec(encodingstring)
    {
       
        var marker = “#@~^”
        var stringindex = 0
        var scriptindex = -1
        var unencodingindex = 0
        var char = null
        var encodinglength = unencodinglength = 0
        var state = state_copy_input
        var unencodingstring = “”
        var re, arr
       
        while(state)
        {
            switch (state)
            {
                case (state_copy_input) :
                    scriptindex = encodingstring.indexof(marker, stringindex)
                    if (scriptindex != -1)
                    {
                        unencodingstring += encodingstring.substring(stringindex, scriptindex)
                        scriptindex += marker.length
                        state = state_readlen
                    }
                    else
                    {
                        stringindex = stringindex==0 ? 0 : stringindex
                        unencodingstring += encodingstring.substr(stringindex, encodingstring.length)
                        state = 0
                    }
                    break
               
                case (state_readlen)    :
                    encodinglength = encodingstring.substr(scriptindex, 6)
                    unencodinglength = decodebase64(encodinglength)
                    scriptindex += (6 + “==”.length)
                    state = state_decode
                    break
                   
                case (state_decode) :
                    if (!unencodinglength)
                    {
                        stringindex = scriptindex + “dqgaaa==^#~@”.length
                        unencodingindex = 0
                        state = state_copy_input
                        break
                    }
                    char = encodingstring.substr(scriptindex, 1)
                    if (char == “@”)    state = state_unescape
                    else
                    {
                        if (char.charcodeat(0) < 0xff)
                        {
                            unencodingstring += string.fromcharcode(transformed[pick_encoding[unencodingindex%64]][char.charcodeat(0)])
                            unencodingindex++
                        }
                        else
                        {
                            unencodingstring += char
                        }                      
                        scriptindex++
                        unencodinglength–
                        break
                    }
                   
                case state_unescape:
                    unencodingstring += unescape(encodingstring.substr(++scriptindex, 1))
                    scriptindex++;  unencodinglength -=2
                    unencodingindex++
                    state = state_decode
                    break
            }
        }
       
        re  = new regexp(“(jscript|vbscript).encode”, “gmi”)
        while(arr = re.exec(unencodingstring))  unencodingstring = regexp.leftcontext + regexp.$1 + regexp.rightcontext
        return unencodingstring
    }

/* end 解密实现:李辉煌 end*/

function dncodefolderfiles(sfolderpath)
{
/*
 *————— dncodefolderfiles(sfolderpath) —————–
 * dncodefolderfiles(sfolderpath)
 * 功能:遍历sfolderpath目录下的所有文件,对加密过的.asp文件
 *      进行解密,并写入源文件中.
 * 实例:dncodefolderfiles(server.mappath(“xml”));
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-17 8:07
 *————— dncodefolderfiles(sfolderpath) —————–
 */
    var arrfiles = getfilespath(sfolderpath)
    for(var i=0;i<arrfiles.length;i++)
    {
        if(getfiletype(arrfiles[i])==”asp”)
        {
            response.write(dncodefile(arrfiles[i]))
            response.write(“ok.<br>”)
        }
    }
}

//取得xml目录下的所有文件.解密.
dncodefolderfiles(server.mappath(“xml”))
//取得t.asp.解密.
//response.write(dncodefile(server.mappath(“t.asp”)))
%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 批量对加密的asp代码解密的asp程序-ASP教程,ASP技巧
分享到: 更多 (0)