<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 1  文章 - 37  trackbacks - 0
    <2008年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    留言簿(16)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    test

    搜索

    •  

    最新評論

     

    解密

    目前可用的加密版本有Delphi, VB, C++, C#,比較簡單,直接移植為JAVA語法就可以了

    C#移植過來的版本:
    public static byte[] Base64Decode(byte[] source) {

            
    byte[] a1, a2;
            a1 
    = source;
            a2 
    = new byte[a1.length * 3 / 4];

            
    for (int i = 0; i < a1.length; i++{
                a1[i] 
    = (byte) (a1[i] - 0x3c);
            }


            
    for (int i = 0, k = a1.length / 4; i < k; i++{
                a2[i 
    * 3= (byte) ((byte) (a1[i * 4<< 2+ (byte) (a1[i * 4 + 1>> 4));
                a2[i 
    * 3 + 1= (byte) ((byte) (a1[i * 4 + 1<< 4+ (byte) (a1[i * 4 + 2>> 2));
                a2[i 
    * 3 + 2= (byte) ((byte) (a1[i * 4 + 2<< 6+ a1[i * 4 + 3]);
            }

            
    if (a2.length % 3 == 2{
                a2[a2.length 
    - 2= (byte) ((byte) (a1[a1.length - 3<< 2+ (byte) (a1[a1.length - 2>> 4));
                a2[a2.length 
    - 1= (byte) ((byte) (a1[a1.length - 2<< 4+ (byte) (a1[a1.length - 1>> 2));
            }
     else if (a2.length % 3 == 1)
                a2[a2.length 
    - 1= (byte) ((byte) (a1[a1.length - 2<< 2+ (byte) (a1[a1.length - 1>> 4));

            
    return a2;
        }

    C++移植過來的代碼:
    public static byte[] fnDecode6BitBuf(byte[] source) {
            
    byte[] pszSrc = source;
            
    byte[] pszDest = new byte[pszSrc.length * 3 / 4];
            
    int nDestLen = pszDest.length;
            
    int nLen = pszSrc.length;
            
    int nDestPos = 0;
            
    int nBitPos = 2;
            
    int nMadeBit = 0;
            
    byte ch;
            
    byte chCode;
            
    byte tmp = 0;

            
    for (int i = 0; i < nLen; i++{
                
    if ((pszSrc[i] - 0x3c>= 0)
                    ch 
    = (byte) (pszSrc[i] - 0x3c);
                
    else {
                    nDestPos 
    = 0;
                    
    break;
                }


                
    if (nDestPos >= nDestLen)
                    
    break;

                
    if ((nMadeBit + 6>= 8{
                    chCode 
    = (byte) (tmp | ((ch & 0x3f>> (6 - nBitPos)));
                    pszDest[nDestPos
    ++= (byte) chCode;

                    nMadeBit 
    = 0;

                    
    if (nBitPos < 6)
                        nBitPos 
    += 2;
                    
    else {
                        nBitPos 
    = 2;
                        
    continue;
                    }

                }


                tmp 
    = (byte) ((ch << nBitPos) & decode6BitMask[nBitPos - 2]);

                nMadeBit 
    += (8 - nBitPos);
            }

            
    return pszDest;
        }


    解密

    解密的版本也是眾多,但是均不可直接移植,java的byte范圍最大只支持到128,超過128則取反(負),位移運算時需要考慮到補碼,C#或C++的版本中的位運算將不能正確解密
    以下是JAVA的解密方法
    public static byte[] Base64Encode(byte[] source) {
            
    byte[] a1, a2;
            a1 
    = source;
            
    if (a1.length % 3 == 0)
                a2 
    = new byte[a1.length * 4 / 3];
            
    else
                a2 
    = new byte[a1.length * 4 / 3 + 1];

            
    for (int i = 0, k = a1.length / 3; i < k; i++{
                a2[i 
    * 4= (byte) (((a1[i * 3>> 2& 0x3F+ 0x3c);
                a2[i 
    * 4 + 1= (byte) (((((a1[i * 3<< 4& 0x3f)) | ((a1[i * 3 + 1>> 4& 0x0f)) + 0x3c);
                a2[i 
    * 4 + 2= (byte) ((((a1[i * 3 + 1<< 2& 0x3f| ((a1[i * 3 + 2>> 6& 0x03)) + 0x3c);
                a2[i 
    * 4 + 3= (byte) ((a1[i * 3 + 2& 0x3f+ 0x3c);
            }


            
    if (a1.length % 3 == 1){
                a2[a2.length 
    - 2= (byte) (((a1[a1.length - 1>> 2& 0x3F+ 0x3c);
                a2[a2.length 
    - 1= (byte) (((a1[a1.length - 1<< 4& 0x3F+ 0x3c);
            }

            
    else if (a1.length % 3 == 2)
                a2[a2.length 
    - 1= (byte) ((byte) (a1[a1.length - 1<< 4>> 2);
            
            
    for (int i = 0; i < a2.length; i++{
                System.out.println(
    "a2["+i+"] - "+a2[i]);
            }

            
    return a2;
        }



    數據結構

    typedef struct tag_TDEFAULTMESSAGE
    {
        
    int        nRecog;
        WORD    wIdent;
        WORD    wParam;
        WORD    wTag;
        WORD    wSeries;
    }
     _TDEFAULTMESSAGE, *_LPTDEFAULTMESSAGE;

    這是前12個字節的結構定義,字節數分別為 4,2,2,2,2,分別對應封包的前12個字節
    從后往前的順序重排字節組成對應數據,例如下面代碼獲得 nRecog

    nRecogBuffer.append(PacketEncode.byte2Hex(commandByte[3]));
            nRecogBuffer.append(PacketEncode.byte2Hex(commandByte[
    2]));
            nRecogBuffer.append(PacketEncode.byte2Hex(commandByte[
    1]));
            nRecogBuffer.append(PacketEncode.byte2Hex(commandByte[
    0]));




     

    posted on 2008-05-19 20:44 Phrancol Yang 閱讀(468) 評論(0)  編輯  收藏 所屬分類: 反匯編

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲AV永久青草无码精品| 全亚洲最新黄色特级网站| 亚洲美女视频一区| 香港a毛片免费观看| 亚洲国产精品乱码一区二区 | 亚洲综合精品一二三区在线| 岛国精品一区免费视频在线观看 | 亚洲视频免费在线观看| 久久久久亚洲Av片无码v| 少妇人妻偷人精品免费视频| 亚洲第一成年网站大全亚洲| 日韩av无码成人无码免费| 亚洲欧洲无码AV不卡在线| 免费一级国产生活片| 国产成人高清精品免费观看| 亚洲AV无码乱码在线观看裸奔| 无码国产精品一区二区免费模式 | 亚洲高清日韩精品第一区| 国产成人精品免费视频网页大全| 国产成人精品日本亚洲18图 | 亚洲乱色熟女一区二区三区丝袜 | 亚洲人成在线免费观看| 免费无码看av的网站| www成人免费观看网站| 亚洲成人午夜在线| 四虎www成人影院免费观看| yy一级毛片免费视频| 91亚洲一区二区在线观看不卡| 国产一精品一AV一免费孕妇| 曰批免费视频播放免费 | 亚洲国产精品成人AV在线| 亚洲精品国产精品国自产观看| 四虎国产成人永久精品免费| 亚洲丰满熟女一区二区哦| 亚洲国产精品无码AAA片| 大学生a级毛片免费观看| 中文字幕无码日韩专区免费| 亚洲精品久久无码| 亚洲国产精品lv| 亚洲国产精品成人| 2020久久精品国产免费|