PHP沙龙 - PHPSalon.com - Justin's Blog - Sofee.cn

世界其实很简单,复杂的是人;生活其实很轻松,沉重的是感情!

用户操作
[即时聊天] [发私信] [加为好友]
JustinID:ezdevelop
271041次访问,排名224好友0人,关注者2
ezdevelop的文章
原创 156 篇
翻译 0 篇
转载 37 篇
评论 819 篇
Justin的公告
-------------------------
点击进入我的新BLOG
-------------------------
作者声明:本人专栏内的所有文章,除注明转载外均为本人原创,未经许可,严禁任何形式转载。
最近评论
muchool:http://cvsproxy.muchool.com/ 专门针对软件开发人员量身定做的CVS代理下载,无需安装任何CVS客户端,轻松而快速的打包下载CVS版本控制服务器上的资源,自动剔除版本控制信息,还原开发者的原始项目目录.
csnxlsh:也发个给我咯
谢谢了!我的邮箱是csnxlsh@sohu.com
ryl:robots.txt只是对好的搜索引擎google ,baidu....等一些好的,才遵守的规则
对垃圾的搜索引擎还是没用啊
所以不用phpmyadmin管理才是主要
ryl:居然有这么活宝的人
怎么把phpmyadmin都传上去
还安全吗
gudai:我等得花儿也谢了。
文章分类
收藏
    相册
    My Photos
    .Personal
    Justin's Tech Blog(RSS)
    My Alumni
    My Website
    Friend's Blog
    PHP/MySQL经验点滴
    大麦英语学习论坛
    速推网
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 PHP版JScript/VBscript脚本解密类库收藏

    新一篇: 即日起恢复CSDN的BLOG! | 旧一篇: PHP解析XML类库 FOR PHP4,即将XML文件解析为数组

    SofeeScriptDecoder.php源代码
    <?php
    /*
      +----------------------------------------------------------------------+
      | SofeeFramework for PHP 4                                             |
      +----------------------------------------------------------------------+
      | Copyright (c) 2004-2005 Sofee Development Team.(http://www.sofee.cn) |
      +----------------------------------------------------------------------+
      | This source file is subject to version 1.00 of the Sofee license,    |
      | that is bundled with this package in the file LICENSE, and is        |
      | available through the world-wide-web at the following url:           |
      | http://www.sofee.cn/license/1_00.txt.                                |
      | If you did not receive a copy of the Sofee license and are unable to |
      | obtain it through the world-wide-web, please send a note to          |
      | license@sofee.cn so we can mail you a copy immediately.              |
      +----------------------------------------------------------------------+
      | Author: Justin Wu <ezdevelop@gmail.com>                              |
      +----------------------------------------------------------------------+
    */
        
    /* $Id: SofeeScriptDecoder.php,v 1.1 2005/06/14 06:30:14 wenlong Exp $ */

    /**
    * Sofee Script Decoder class -    Decodes JScript/VBscript data encoded with the
    *                                MS ScriptEncoder in true crossbrowser manner.
    *
    * This script was influenced by the C version (scrdec1x.c) by Mr.Brownstone,
    * and is distributed under the terms of the BSD License.
    *
    * scrdec1x.c is copyright(c) Mr.Brownstone <mrbrownstone@virtualconspiracy.com>
    * http://www.virtualconspiracy.com/scrdec.html
    *
    * @package        SofeeFramework
    * @access        public
    * @version        $Revision: 1.1 $
    * @author        Justin Wu <wenlong@php.net>
    * @homepage        http://www.sofee.cn
    * @copyright    Copyright (c) 2004-2005 Sofee Development Team.(http://www.sofee.cn)
    * @since        2005-06-14
    */

    define('STATE_COPY_INPUT',        100
    );
    define('STATE_READLEN',            101
    );
    define('STATE_DECODE',            102
    );
    define('STATE_UNESCAPE',        103
    );

    class
    SofeeScriptDecoder
    {
        var
    $rawData
    = 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
    $pick_encoding
    = 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
    $transformed
    = array();

        
    /**
        * 说明
        *
        * @access    private
        * @var        string
        */
        
    var $digits
    ;

        
        
    /**
        * Constructor
        *
        * @access        public
        * @return        void    
        */
        
    function SofeeScriptDecoder
    () {
            
    $this->maketrans
    ();
            
    $this->makedigits
    ();
        }
        
        
    /**
        * unescape a char
        *
        * @access        public
        * @param        string        [$char]
        * @return        string
        */
        
    function unescape($char
    ) {
            
    $escapes = "#&!*$"
    ;
            
    $escaped = "\r\n<>@"
    ;
            
    $i = 0
    ;

            if (
    ord($char) > 126
    ) {
                return
    $char
    ;
            }
            
            while (
    $escapes[$i
    ]) {
                if (
    $escapes[$i] == $char
    )
                    return
    $escaped[$i
    ];
                
    $i
    ++;
            }
            return
    '?'
    ;
        }
        
        
    /**
        * pre-building the char-matrix
        *
        * @access        public
        * @return        void    
        */
        
    function maketrans
    () {
            for (
    $i=0; $i<3; $i
    ++) {
                
    $this->transformed[$i
    ] = array();
            }

            for (
    $i=31; $i<=126; $i
    ++) {
                for (
    $j=0; $j<3; $j
    ++) {
                    
    $this->transformed[$j][$this->rawData[($i-31)*3 + $j]] = ($i==31) ? 9 : $i
    ;
                }
            }
        }
        
        
    /**
        * pre-building the char-matrix
        *
        * @access        public
        * @return        void    
        */
        
    function makedigits
    () {
            for (
    $i=0; $i<26; $i
    ++) {
                
    $this->digits[ord('A')+$i] = $i
    ;
                
    $this->digits[ord('a')+$i] = $i+26
    ;
            }
            for (
    $i=0; $i<10; $i
    ++) {
                
    $this->digits[ord('0')+$i] = $i+52
    ;
            }
            
    $this->digits[0x2b] = 62
    ;
            
    $this->digits[0x2f] = 63
    ;
        }
        
        
    /**
        * decode string length
        *
        * @access        public
        * @param        string        [$str]
        * @return        integer
        */
        
    function decodeBase64($str
    ) {
            
    $val = 0
    ;
            
    $val += ($this->digits[ord($str[0])] << 2
    );
            
    $val += ($this->digits[ord($str[1])] >> 4
    );
            
    $val += ($this->digits[ord($str[1])] & 0xf) << 12
    ;
            
    $val += (($this->digits[ord($str[2])] >> 2) << 8
    );
            
    $val += (($this->digits[ord($str[2])] & 0x3) << 22
    );
            
    $val += ($this->digits[ord($str[3])] << 16
    );
            return
    $val
    ;
        }

        
    /**
        * Decodes JScript/VBscript data encoded with the MS ScriptEncoder in true crossbrowser manner.
        *
        * @access        public
        * @param        string        [$str]
        * @return        string    
        */
        
    function decode($str
    ) {
            
    $marker = "#@~^"
    ;
            
    $strIdx = 0
    ;
            
    $scrIdx = 0
    ;
            
    $decIdx = 0
    ;
            
    $char = null
    ;
            
    $strLen = $scrLen = 0
    ;
            
    $state = STATE_COPY_INPUT
    ;
            
    $ret = ""
    ;

            while (
    $state
    ) {
                switch (
    $state
    ) {
                    case
    STATE_COPY_INPUT
    :
                        
    $scrIdx = strpos($str, $marker, $strIdx
    );
                        if (
    $scrIdx !== false
    ) {
                            
    $ret .= substr($str, $strIdx, $scrIdx
    );
                            
    $scrIdx += strlen($marker
    );
                            
    $state = STATE_READLEN
    ;
                        } else {
                            
    $strIdx = $strIdx==0 ? 0 : $strIdx
    ;
                            
    $ret .= substr($str, $strIdx, strlen($str
    ));
                            
    $state = 0
    ;
                        }
                        break;
                            
                    case
    STATE_READLEN
    :
                        
    $strLen = substr($str, $scrIdx, 6
    );
                        
    $scrLen = $this->decodeBase64($strLen
    );
                        
    $scrIdx += (6 + strlen("=="
    ));
                        
    $state = STATE_DECODE
    ;
                        break;
                    
                    case
    STATE_DECODE
    :
                        if (!
    $scrLen
    ) {
                            
    $strIdx = $scrIdx + strlen("DQgAAA==^#~@"
    );
                            
    $decIdx = 0
    ;
                            
    $state = STATE_COPY_INPUT
    ;
                            break;
                        }
                        
    $char = substr($str, $scrIdx, 1
    );
                        if (
    $char == "@"
    ) {
                            
    $state = STATE_UNESCAPE
    ;
                        } else {
                            if (
    ord($char[0]) < 0x80
    ) {
                                
    $ret .= chr($this->transformed[$this->pick_encoding[$decIdx%64]][ord($char
    )]);
                                
    $decIdx
    ++;
                            } else {
                                
    $ret .= $char
    ;
                                if (
                                    (
    ord($char) > 0xa0) && (ord($char) < 0xff)    
    // 936 - Simplified Chinese GBK    -    0xa1-0xfe
                                    
    || (ord($char) > 0x80) && (ord($char) < 0xff)    
    // 950 - Traditional Chinese Big5    -    0x81-0xfe
                                
    ) {
                                    
    $scrIdx
    ++;
                                    
    $scrLen
    --;
                                    
    $ret .= substr($str, $scrIdx, 1
    );
                                }
                            }
                            
    $scrIdx
    ++;
                            
    $scrLen
    --;
                            break;
                        }
                        
                    case
    STATE_UNESCAPE
    :
                        
    $ret .= $this->unescape(substr($str, ++$scrIdx, 1
    ));
                        
    $scrIdx
    ++;
                        
    $scrLen -= 2
    ;
                        
    $decIdx
    ++;
                        
    $state = STATE_DECODE
    ;
                        break;
                }
            }
            return (
    $ret
    );
        }
    }
    ?>

    调用方法:
    <?php
    require_once('SofeeScriptDecoder.php'
    );

    $scr = new SofeeScriptDecoder
    ();
    $str = file_get_contents('test.txt'
    );

    echo
    $scr->decode($str
    );
    ?>

    test.txt文件内容:
    #@~^8wIAAA==@!4Yh^@*@#@&@!DkDs+@*nunUlsG RmKh@!JYkDsn@*@#@&@!4GNz@*@#@&@!/1.kaY~smxo;CT+xJNC7ld1DbwYr@*@#@&0!x^YbWU~T+YohV}4L^O`*PP@#@&d-CMPG4N~',x;s^i@#@&7DDzPP@#@&d7K4NP',xAPzmOk7+p6(L+1O`rH/Xhs c(tSuKPKr#I@#@&78,mCO1t`nb, @#@&i7DDz, @#@&didK8L,'~xh~)1Yk7n(}4L^O`rHbm.WdG6Y (tJC:KKE*i@#@&7i8~mmO1tcKm*P @#@&i7db0~`DX2nK0Po\S_YYa]n;!+kY~"x~rEUNWk +[E,#P`@#@&d7diG(L~{P +h,(tJCDY2I;;nkY`*I@#@&ddiN@#@&id)@#@&dN@#@&d.+D;D PG8Ni@#@&N@#@&@#@&6; mObW PoY}8LmO`bNb~P@#@&ir0,`NK^;:xDRL+O3^+h+ OAHq[b, @#@&7iDnY!. P[Km!:+ YcL+D2s+s+UO~Xq9ck9#i@#@&78,+^/nPrW,`[W1;:xO mVVb~P@#@&di.Y;Mx,NW1EsnxDRCV^$r[Yi@#@&78,+Vkn~k6PvNGm;hxOR^CXDdb, @#@&7iDnY!. P[Km!:+ YcslH+./]k[Dp@#@&iN@#@&8@#@&@#@&l^+MYcB n^mG:~YKPKuh?lsG R^WsZE#I@#@&@!z/1Db2Y@*@#@&@!J4G[H@*@#@&@!z4Y:^@*Hs8AAA==^#~@


    解密结果:
    <html>
    <title>PHPSalon.com</title>
    <body>
    <script language="javascript">
    function getXmlObject() {
        var obj = null;
        try {
            obj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                obj = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(oc) {
                if (typeof XMLHttpRequest != "undefined" ) {
                    obj = new XMLHttpRequest();
                }
            }
        }
        return obj;
    }

    function getObject(id) {
        if (document.getElementById) {
            return document.getElementById(id);
        } else if (document.all) {
            return document.all[id];
        } else if (document.layers) {
            return document.layers[id];
        }
    }

    alert('Welcome to PHPSalon.com!');
    </script>
    </body>
    </html>

    发表于 @ 2005年06月15日 10:59:00|评论(loading...)|编辑

    新一篇: 即日起恢复CSDN的BLOG! | 旧一篇: PHP解析XML类库 FOR PHP4,即将XML文件解析为数组

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © Justin