AI DIGEST
AI 摘要
LIVE

星辰奇缘苹果端使用两次MD5哈希算法验证绑定域名。首次将IP地址转为字节数组计算MD5,并将每个哈希字节格式化为6位十六进制字符串。随后对该字符串再次进行MD5计算,将结果字节格式化为2位十六进制得到最终密文。代码中预设了四个MD5哈希值作为白名单。只有当计算出的密文与其中任一预设值匹配时,才允许建立Socket连接。这是一种简单的域名/IP白名单验证机制。

星辰奇缘苹果端绑定域名解密方法

  1. public void Connect(string address, int port)
  2.         {
  3.                 if (this.socket.Connected)
  4.                 {
  5.                         Debug.Log(string.Format(“错误:重复建立Socke连接,重新连接时请先断开之前的连接”, new object[0]));
  6.                         return;
  7.                 }
  8.                 this.address = address;
  9.                 this.port = port;
  10.                 MD5 md = MD5.Create();
  11.                 string a = “12546f1c61454538c45490”;
  12.                 string a2 = “1252051ca54456902c7054bc”;
  13.                 string a3 = “66610b45455576”;
  14.                 string a4 = “4582fdgs4545wr42saf1”;
  15.                 byte[] bytes = Encoding.Default.GetBytes(address);
  16.                 byte[] array = md.ComputeHash(bytes);
  17.                 string text = string.Empty;
  18.                 for (int i = 0; i < array.Length; i++)
  19.                 {
  20.                         text += array[i].ToString(“x6”);
  21.                 }
  22.                 byte[] bytes2 = Encoding.Default.GetBytes(text);
  23.                 byte[] array2 = md.ComputeHash(bytes2);
  24.                 string text2 = string.Empty;
  25.                 for (int j = 0; j < array2.Length; j++)
  26.                 {
  27.                         text2 += array2[j].ToString(“x2”);
  28.                 }
  29.                 if (!(a == text2) && !(a2 == text2) && !(a3 == text2))
  30.                 {
  31.                         if (!(a4 == text2))
  32.                         {
  33.                                 this.Disconnect();
  34.                                 return;
  35.                         }
  36.                 }
  37.                 try
  38.                 {
  39.                         Log.Debug(“Socket尝试建立连接”);
  40.                         this.ConnectStatus = ConnectStatusEnum.HasConnect;
  41.                         this.connetTime = Time.time;
  42.                         this.result = this.socket.BeginConnect(address, port, null, null);
  43.                         TimerManager.GetInstance().AddTimerTask(new TimerTask(500f, new Action(this.checkConnect)));
  44.                 }
  45.                 catch (SocketException ex)
  46.                 {
  47.                         this.result = null;
  48.                         this.socket.Close();
  49.                         Debug.Log(string.Format(“连接服务器{0}:{1}失败:{2}”, address, port, ex.Message));
  50.                         this.Disconnect();
  51.                 }
  52.         }

复制代码

address=ip地址

byte[] bytes = Encoding.Default.GetBytes(address);

                byte[] array = md.ComputeHash(bytes);

                string text = string.Empty;

                for (int i = 0; i < array.Length; i++)

                {

                        text += array.ToString(“x6”);

                }

                byte[] bytes2 = Encoding.Default.GetBytes(text);

                byte[] array2 = md.ComputeHash(bytes2);

                string text2 = string.Empty;

                for (int j = 0; j < array2.Length; j++)

                {

                        text2 += array2[j].ToString(“x2”);

                }

text2就是最终密文


© 版权声明
THE END
文章不错?点个赞呗
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容