void ManualAuthCallBack(mm.command.NewAuthResponse message) { if (message.Base.Ret == -301) { var dns = message.Server.NewHostList; if (dns.ListList.Count > 0) { string ip = dns.ListList[0].Substitute; mMClient.shortLink = "http://" + dns.ListList[1].Substitute; Console.WriteLine("shortLink:" + mMClient.shortLink + "\n"); mMClient.ReConnect(ip); mMClient.CheckLoginQRCode(uuid, CheckLoginQRCodeCallBack); } } else if (message.Base.Ret == 0) { byte[] strECServrPubKey = message.Auth.SvrPubECDHKey.Key.Buffer.ToByteArray(); var aesKey = MyFuckSSL.SharkEcdhKey(strECServrPubKey, mMClient.pri_key_buf); mMClient.CheckEcdh = aesKey.ToString(16, 2); mMClient.AESKey = AES.AESDecrypt(message.Auth.SessionKey.Buffer.ToByteArray(), aesKey).ToString(16, 2); mMClient.wxid = message.User.UserName; Console.WriteLine("当前微信号:" + mMClient.wxid + "\n"); mMClient.uin = message.Auth.Uin; Console.WriteLine("uin:" + mMClient.uin + "\n"); mMClient.cookie = mMClient.getcookie(); mMClient.deviceID = "49aa7db2f4a3ffe0e96218f6b92cde32".ToByteArray(16, 2); Console.WriteLine(ChangeType.ToHexString(mMClient.deviceID)); mMClient.devicetype = "iPad iPhone OS8.4"; ShortChanle.NewInit(mMClient); } }
public void threadqrcode() { var bProtobuf = ShortChanle.GetLoginQRCode(mMClient); Console.WriteLine(ChangeType.ToHexString(bProtobuf)); MMPro.MM.GetLoginQRCodeResponse getLoginQRCodeResponse = mMClient.Deserialize <GetLoginQRCodeResponse>(bProtobuf); //mm.command.GetLoginQRCodeResponse pb = mm.command.GetLoginQRCodeResponse.ParseFrom(bProtobuf); Bitmap bitmap = new Bitmap(new MemoryStream(getLoginQRCodeResponse.qRCode.src)); ShortQRcode.Image = bitmap; }
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)); }
public static byte[] GetLoginQRCode(MMClient mm) { mm.AESKey = (new Random()).NextBytes(16).ToString(16, 2); Console.WriteLine("随机AESKEY:" + ChangeType.ToHexString(mm.AESKey.ToByteArray(16, 2))); GetLoginQRCodeRequest.Builder qrcode = new GetLoginQRCodeRequest.Builder(); SKBuiltinBuffer_t.Builder aes = new SKBuiltinBuffer_t.Builder(); //GetLoginQRCodeRequest getLoginQRCodeRequest = new GetLoginQRCodeRequest() aes.SetBuffer(ByteString.CopyFrom(mm.AESKey.ToByteArray(16, 2))); aes.SetILen(16); SKBuiltinBuffer_t randomAes = aes.Build(); byte[] session = new byte[0]; qrcode.SetBase(GetBasePack(session, 0, 0)); qrcode.SetOpcode(0); qrcode.SetDeviceName("daivis.IPAD"); qrcode.SetRandomEncryKey(randomAes); GetLoginQRCodeRequest pack = qrcode.Build(); Console.WriteLine(pack.ToString()); var src = pack.ToByteArray(); int bufferlen = src.Length; var senddata = mm.ShortLinkPack(MMPro.MM.CGI_TYPE.CGI_TYPE_GETLOGINQRCODE, src, 1); byte[] retbuf = null; WeChatPost(mm.shortLink + "/cgi-bin/micromsg-bin/getloginqrcode", senddata, ref retbuf); Console.WriteLine(ChangeType.ToHexString(retbuf)); return(mm.shortUnPack(retbuf)); }
private void Form1_Load(object sender, EventArgs e) { mMClient = new MMClient(); mMClient.deviceID = "49aa7db2f4a3ffe0e96218f6b92cde32".ToByteArray(16, 2); Console.WriteLine(ChangeType.ToHexString(mMClient.deviceID)); }