Преглед изворни кода

修复登录提示盗号的问题

修复登录提示盗号的问题
changtuiqie пре 7 година
родитељ
комит
eff764ec40

+ 3 - 2
IPADDemo/FormDemo.cs

@@ -14,6 +14,7 @@ using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using Xzy.IPAD.Core;
 
 namespace IPADDemo
 {
@@ -263,7 +264,7 @@ namespace IPADDemo
         {
             string str= weChatThread.Wx_GenerateWxDat();
             WxDat wxDat = JsonConvert.DeserializeObject<WxDat>(str);
-            txt_login62.Text = EUtils.EStrToHex( wxDat.data);
+            txt_login62.Text = Convert62.eStrToHex( wxDat.data);
         }
 
         private void button18_Click(object sender, EventArgs e)
@@ -290,7 +291,7 @@ namespace IPADDemo
 
         private void button13_Click(object sender, EventArgs e)
         {
-            weChatThread = new XzyWeChatThread(EUtils.EHexToStr(txt_login62.Text),txt_loginName.Text,txt_loginPassword.Text);
+            weChatThread = new XzyWeChatThread(Convert62.eHexToStr(txt_login62.Text),txt_loginName.Text,txt_loginPassword.Text);
         }
 
         private void button15_Click(object sender, EventArgs e)

+ 5 - 4
IPADDemo/IPADDemo.csproj

@@ -50,6 +50,9 @@
   <PropertyGroup>
     <ApplicationManifest>app.manifest</ApplicationManifest>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationIcon>bitbug_favicon.ico</ApplicationIcon>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
       <HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
@@ -107,9 +110,6 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\dll\Xzy.IPAD.Core.dll</HintPath>
     </Reference>
-    <Reference Include="Xzy.WebWx.Model">
-      <HintPath>..\..\..\WebWx.Core\dll\Xzy.WebWx.Model.dll</HintPath>
-    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AppData\App.cs" />
@@ -152,8 +152,8 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Util\Base64.cs" />
     <Compile Include="Util\BaseClass.cs" />
+    <Compile Include="Util\Convert62.cs" />
     <Compile Include="Util\Cover.cs" />
-    <Compile Include="Util\EUtils.cs" />
     <Compile Include="Util\HttpUtil.cs" />
     <Compile Include="Util\MyUtils.cs" />
     <Compile Include="Util\ffmpegUtils.cs" />
@@ -193,6 +193,7 @@
     </None>
   </ItemGroup>
   <ItemGroup>
+    <Content Include="bitbug_favicon.ico" />
     <Content Include="ffmpeg\ffmpeg.exe" />
     <Content Include="ffmpeg\silk_v3_decoder.exe" />
     <Content Include="ffmpeg\silk_v3_encoder.exe" />

+ 3 - 1
IPADDemo/Program.cs

@@ -1,4 +1,5 @@
-using System;
+using IPADDemo.Util;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -17,6 +18,7 @@ namespace IPADDemo
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             Application.Run(new FormDemo());
+         
         }
     }
 }

+ 41 - 0
IPADDemo/Util/Convert62.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace IPADDemo.Util
+{
+    public class Convert62
+    {
+        [DllImport("EUtils.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
+        private static extern IntPtr EStrToHex(string context);
+
+        [DllImport("EUtils.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
+        private static extern IntPtr EHexToStr(string context);
+
+        /// <summary>
+        /// 16进制转字符串
+        /// </summary>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        public static string eStrToHex(string context) {
+            IntPtr intptr = EStrToHex(context);
+            string str = "" + Marshal.PtrToStringAnsi(intptr).Substring(0,344);
+            return str;
+        }
+
+        /// <summary>
+        /// 字符串转16进制
+        /// </summary>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        public static string eHexToStr(string context)
+        {
+            IntPtr intptr = EHexToStr(context);
+            string str = "" + Marshal.PtrToStringAnsi(intptr).Substring(0,232);
+            return str;
+        }
+    }
+}

+ 0 - 133
IPADDemo/Util/EUtils.cs

@@ -1,133 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace IPADDemo.Util
-{
-    public static class EUtils
-    {
-        #region 易语言 Utils 处理中文乱码
-        /// <summary>
-        /// 发送文字朋友圈
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="str"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESendSNS(int wxuser, string str);
-
-        /// <summary>
-        /// 发送朋友圈图片
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="xml"></param>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESendSNSImage(int wxuser, string xml, string context);
-
-        /// <summary>
-        /// 设置群公告
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="wxid"></param>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESetChatroomAnnouncement(int wxuser, string wxid, string context);
-
-        /// <summary>
-        /// 设置群名称
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="wxid"></param>
-        /// <param name="name"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESetChatroomName(int wxuser, string wxid, string name);
-
-        /// <summary>
-        /// 发送名片
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="wxid"></param>
-        /// <param name="fromwxid"></param>
-        /// <param name="caption"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int EShareCarde(int wxuser, string wxid, string fromwxid, string caption);
-
-        /// <summary>
-        /// 朋友圈评论
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="wxid"></param>
-        /// <param name="snsid"></param>
-        /// <param name="context"></param>
-        /// <param name="replyid"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESnsComment(int wxuser, string wxid, string snsid, string context, int replyid);
-
-        /// <summary>
-        /// 添加用户
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="v1"></param>
-        /// <param name="v2"></param>
-        /// <param name="type"></param>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int EAddUser(int wxuser, string v1, string v2, int type, string context);
-
-        /// <summary>
-        /// 设置备注
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="wxid"></param>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESetUserRemark(int wxuser, string wxid, string context);
-
-        /// <summary>
-        /// 打招呼
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="v1"></param>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int ESayHello(int wxuser, string v1, string context);
-
-        /// <summary>
-        /// 添加标签
-        /// </summary>
-        /// <param name="wxuser"></param>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern int EAddContactLabel(int wxuser, string context);
-
-        /// <summary>
-        /// 16进制转字符串
-        /// </summary>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern string EStrToHex(string context);
-
-        /// <summary>
-        /// 字符串转16进制
-        /// </summary>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        [DllImport("EUtils.dll")]
-        public static extern string EHexToStr(string context);
-        #endregion
-    }
-}

+ 45 - 52
IPADDemo/WeChat/XzyWeChatThread.cs

@@ -374,21 +374,13 @@ namespace IPADDemo.WeChat
         {
             fixed (int* WxUser1 = &pointerWxUser, pushStr1 = &pushStr)
             {
-                //string version = System.Reflection.Assembly.LoadFrom("wxipadapi.dll").GetName().Version.ToString();
-                //WxDelegate.show("版本信息:" + version);
                 string uid = UUID;
                 var mac = Mac;
-
-                //var ret = XzyAuth.Init();
-                //if (ret == 1)
-                //{
+                string name = "xzy-ipad";
                 var ret = XzyAuth.Init(ConfigurationSettings.AppSettings["AuthKey"].ToString());
-                //}
-
                 WxDelegate.show("授权结果:" + ret);
-                var key = string.Format(@"<softtype><k3>11.0.1</k3><k9>iPad</k9><k10>2</k10><k19>58BF17B5-2D8E-4BFB-A97E-38F1226F13F8</k19><k20>{0}</k20><k21>neihe_5GHz</k21><k22>(null)</k22><k24>{1}</k24><k33>\345\276\256\344\277\241</k33><k47>1</k47><k50>1</k50><k51>com.tencent.xin</k51><k54>iPad4,4</k54></softtype>", UUID, Mac);
-
-                XzyWxApis.WXInitialize((int)WxUser1, "张三的IPAD", key, UUID);
+                var key = string.Format(@"<softtype><k3>9.0.2</k3><k9>iPad</k9><k10>2</k10><k19>58BF17B5-2D8E-4BFB-A97E-38F1226F13F8</k19><k20>{0}</k20><k21>neihe_5GHz</k21><k22>(null)</k22><k24>{1}</k24><k33>\345\276\256\344\277\241</k33><k47>1</k47><k50>1</k50><k51>com.tencent.xin</k51><k54>iPad4,4</k54></softtype>", UUID, Mac);
+                XzyWxApis.WXInitialize((int)WxUser1, name, key, UUID);
 
                 XzyWxApis.WXSetRecvMsgCallBack(pointerWxUser, msgCallBack);
                 XzyWxApis.WXGetQRCode(pointerWxUser, (int)pushStr1);
@@ -397,7 +389,6 @@ namespace IPADDemo.WeChat
 
                 WxQrCode qr_code = JsonConvert.DeserializeObject<WxQrCode>(msg);//反序列化
 
-                //var img = MyUtils.Base64StringToImage(qr_code.QrCodeStr);
                 WxDelegate.qrCode(qr_code.QrCodeStr);
 
                 Wx_ReleaseEX(ref pushStr);
@@ -428,59 +419,44 @@ namespace IPADDemo.WeChat
                 if (QRCodejson.Status == 2)
                 {
                     var username = QRCodejson.UserName;
-
-                    this.wxUser.wxid = QRCodejson.UserName;
-                    this.wxUser.name = QRCodejson.NickName;
-                    this.wxUser.headurl = QRCodejson.HeadUrl;
-                    this.wxUser.status = QRCodejson.Status;
-                    var pass = QRCodejson.Password;
-                    XzyWxApis.WXQRCodeLogin(pointerWxUser, username, pass, (int)pushStr1);
-                    var datas = MarshalNativeToManaged((IntPtr)pushStr);
-                    string sstr = datas.ToString();
-                    Wx_ReleaseEX(ref pushStr);
-                    UserData userdata = Newtonsoft.Json.JsonConvert.DeserializeObject<UserData>(sstr);//反序列化
+                    var password = QRCodejson.Password;
+                    string s62 = Wx_GenerateWxDat();
+                    WxDat wxDat = JsonConvert.DeserializeObject<WxDat>(s62);
+                    var str62 = Convert62.eStrToHex(wxDat.data);
+                    EUtils.AuthApi(username, password, UUID, Mac, name, str62);
+                    Thread.Sleep(3000);
+                    var strlogin=Wx_QRCodeLogin(username, password);
+                    UserData userdata = Newtonsoft.Json.JsonConvert.DeserializeObject<UserData>(strlogin);//反序列化
                     if (userdata.Status == -301)
                     {
-                        XzyWxApis.WXQRCodeLogin(pointerWxUser, username, pass, (int)pushStr1);
-                        datas = MarshalNativeToManaged((IntPtr)pushStr);
-                        sstr = datas.ToString();
-                        Wx_ReleaseEX(ref pushStr);
-                        WxDelegate.show("微信重定向");
-                        userdata = Newtonsoft.Json.JsonConvert.DeserializeObject<UserData>(sstr);//反序列化
-
-                        if (userdata.Status == 0)
-                        {
+                        var Str= Wx_QRCodeLogin(username, password);
+                        userdata = Newtonsoft.Json.JsonConvert.DeserializeObject<UserData>(Str);//反序列化
+                        if (userdata.Status == 0) {
                             WxDelegate.show("登录成功");
                             XzyWxApis.WXHeartBeat(pointerWxUser, (int)pushStr1);
-                            datas = MarshalNativeToManaged((IntPtr)pushStr);
-                            sstr = datas.ToString();
+                            var datas = MarshalNativeToManaged((IntPtr)pushStr);
+                            var sstr = datas.ToString();
                             Wx_ReleaseEX(ref pushStr);
-
+                            this.wxUser.wxid = userdata.UserName;
+                            this.wxUser.name = userdata.NickName;
                             this.TcpSendMsg(TcpMsg.OL, this.wxUser);
-
                             Task.Factory.StartNew(delegate { this.Wx_GetContacts(); });
-
+                            Wx_ReleaseEX(ref pushStr);
                             return;
                         }
-                        else
-                        {
-                            WxDelegate.show("登录失败");
-
-                        }
                     }
                     if (userdata.Status == 0)
                     {
                         WxDelegate.show("登录成功");
                         XzyWxApis.WXHeartBeat(pointerWxUser, (int)pushStr1);
-                        datas = MarshalNativeToManaged((IntPtr)pushStr);
-
-                        sstr = datas.ToString();
+                        var datas = MarshalNativeToManaged((IntPtr)pushStr);
+                        var sstr = datas.ToString();
                         Wx_ReleaseEX(ref pushStr);
-
+                        this.wxUser.wxid = userdata.UserName;
+                        this.wxUser.name = userdata.NickName;
                         this.TcpSendMsg(TcpMsg.OL, this.wxUser);
-
                         Task.Factory.StartNew(delegate { this.Wx_GetContacts(); });
-
+                        Wx_ReleaseEX(ref pushStr);
                         return;
                     }
                     else
@@ -501,11 +477,8 @@ namespace IPADDemo.WeChat
         {
             fixed (int* WxUser1 = &pointerWxUser, pushStr1 = &pushStr)
             {
-                //var ret = XzyAuth.Init();
-                //if (ret == 1)
-                //{
+
                 var ret = XzyAuth.Init(ConfigurationSettings.AppSettings["AuthKey"].ToString());
-                //}
                 string uid = UUID;
                 var mac = Mac;
 
@@ -625,6 +598,8 @@ namespace IPADDemo.WeChat
             }
         }
 
+        
+
         /// <summary>
         /// 图片转byte
         /// </summary>
@@ -1591,6 +1566,24 @@ namespace IPADDemo.WeChat
             return result;
         }
 
+        /// <summary>
+        /// 二维码登录
+        /// </summary>
+        /// <param name="username"></param>
+        /// <param name="password"></param>
+        /// <returns></returns>
+        public unsafe string Wx_QRCodeLogin(string username,string password) {
+            var result = "";
+            fixed (int* WxUser1 = &pointerWxUser, msgptr1 = &msgPtr)
+            {
+                XzyWxApis.WXQRCodeLogin(pointerWxUser, username, password, (int)msgptr1);
+                var datas = MarshalNativeToManaged((IntPtr)msgPtr);
+                result = datas.ToString();
+                Wx_ReleaseEX(ref msgPtr);
+            }
+            return result;
+        }
+
         /// <summary>
         /// 获取好友详情
         /// </summary>

BIN
IPADDemo/bin/Debug/EUtils.dll


BIN
IPADDemo/bin/Debug/IPADDemo.exe


BIN
IPADDemo/bin/Debug/IPADDemo.pdb


BIN
IPADDemo/bin/Debug/Xzy.IPAD.Core.dll


BIN
IPADDemo/bin/Debug/Xzy.IPAD.Core.pdb


BIN
IPADDemo/bin/Debug/wxipadapi6.7.dll


BIN
IPADDemo/bin/Debug/xzyapi.dll


+ 1 - 0
IPADDemo/bin/Debug/使用文档.txt

@@ -0,0 +1 @@
+淃커多흙Xzy.IPAD.Core.dll 깻할쉥wxipadapi6.7.dll 렴零Bin커쩌苟

BIN
IPADDemo/bitbug_favicon.ico


BIN
IPADDemo/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


+ 1 - 1
IPADDemo/obj/Debug/IPADDemo.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-271dd2a058acdccc155c8bf7295da1f6feda920d
+af297cc092a33f735b9a837ee026a88ff73f589c

+ 1 - 1
IPADDemo/obj/Debug/IPADDemo.csproj.FileListAbsolute.txt

@@ -170,7 +170,6 @@ C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\bin\Debug\log4net.xml
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\bin\Debug\Newtonsoft.Json.xml
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\bin\Debug\SuperSocket.ProtoBase.xml
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\bin\Debug\System.ValueTuple.xml
-C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.csprojAssemblyReference.cache
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.FormDemo.resources
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.Properties.Resources.resources
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.csproj.GenerateResource.cache
@@ -179,3 +178,4 @@ C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.csproj.CopyCompl
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.exe
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.pdb
 C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\bin\Debug\Xzy.IPAD.Core.pdb
+C:\xm\git\Xzy.Mac.WeChat\Mac.WeChat\IPADDemo\obj\Debug\IPADDemo.csprojAssemblyReference.cache

BIN
IPADDemo/obj/Debug/IPADDemo.csproj.GenerateResource.cache


BIN
IPADDemo/obj/Debug/IPADDemo.csprojAssemblyReference.cache


BIN
IPADDemo/obj/Debug/IPADDemo.exe


BIN
IPADDemo/obj/Debug/IPADDemo.pdb



BIN
dll/Xzy.IPAD.Core.dll


BIN
dll/Xzy.IPAD.Core.pdb


BIN
dll/wxipadapi6.7.dll



+ 1 - 1
dll/使用文档.txt

@@ -1 +1 @@
-项目引入Xzy.IPAD.Core.dll 并且将wxipadapi6.7.dll 放置Bin目录下
+项目引入Xzy.IPAD.Core.dll 并且将wxipadapi6.7.dll  ,xzyapi.dll放置Bin目录下