Esempio n. 1
0
        public static void NewInit(MMClient mm)
        {
            NewInitRequest.Builder init = new NewInitRequest.Builder();
            byte[] sessionKey           = mm.AESKey.ToByteArray(16, 2);



            SKBuiltinBuffer_t.Builder Bmaxsync = new SKBuiltinBuffer_t.Builder();
            Bmaxsync.SetBuffer(ByteString.CopyFrom(new byte[0]));
            Bmaxsync.SetILen(0);
            SKBuiltinBuffer_t maxsynckey = Bmaxsync.Build();

            SKBuiltinBuffer_t.Builder sync = new SKBuiltinBuffer_t.Builder();
            sync.SetBuffer(ByteString.CopyFrom(new byte[0]));
            sync.SetILen(0);
            SKBuiltinBuffer_t synckey = sync.Build();

            BaseRequest bBase = GetBasePack(sessionKey, mm.uin, 3);

            init.SetBase(bBase);
            init.SetLanguage("zh_CN");
            init.SetUserName(mm.wxid);
            init.SetMaxSynckey(maxsynckey);
            init.SetCurrentSynckey(synckey);
            NewInitRequest initPack = init.Build();

            // byte[] buf = initPack.ToByteArray();
            // Console.WriteLine(initPack.ToString());
            // byte[]senddata =  mm.ShortLinkPack((MMPro.MM.CGI_TYPE)139, buf);
            // IntPtr AESpushstr = IntPtr.Zero;
            // byte[]afterC =  MyFuckSSL.AesEncodeComprese(buf, buf.Length, sessionKey, AESpushstr);
            //   IntPtr pushstr = IntPtr.Zero;
            // byte[]head = MyFuckSSL.AesHeader((int)mm.uin, mm.cookie, mm.cookie.Length, 139, buf.Length, afterC.Length,pushstr);
            //   var senddata = head.Concat(afterC).ToArray();
            byte[] senddata = null;
            senddata = mm.MakeAESHead(initPack.ToByteArray(), (MMPro.MM.CGI_TYPE) 139);
            ChangeType.Add4Bytes(ref senddata, initPack.ToByteArray());
            Console.WriteLine(ChangeType.ToHexString(senddata));
            byte[] retbuf = null;
            WeChatPost(mm.shortLink + "/cgi-bin/micromsg-bin/newinit", senddata, ref retbuf);
            Console.WriteLine("初始化包已发送");
            Console.WriteLine(ChangeType.ToHexString(retbuf));
        }