Exemplo n.º 1
0
 public void Recv_1E74(byte[] data, InitTcp tcp)
 {
     try
     {
         using (ByteArray byteArray = new ByteArray(data))
         {
             byteArray.readUnsignedInt();
             byteArray.readUnsignedInt();
             byteArray.readUnsignedShort();
             byteArray.readUnsignedInt();
             byteArray.readUnsignedInt();
             byteArray.readUnsignedShort();
             uint num = byteArray.readUnsignedInt();
             for (int i = 0; i < num; i++)
             {
                 int    length = byteArray.readUnsignedShort();
                 string ip     = byteArray.readUTFBytes((uint)length);
                 byteArray.readUnsignedInt();
                 uint num2 = byteArray.readUnsignedInt();
                 myip mi   = new myip();
                 mi.ip    = ip;
                 mi.ports = new int[num2];
                 for (int j = 0; j < num2; j++)
                 {
                     ushort num3 = byteArray.readUnsignedShort();
                     mi.ports[j] = num3;
                 }
                 if (concurrentBag_0.Count(delegate(myip p)
                 {
                     if (p.ip == ip)
                     {
                         return(p.ports[0] == mi.ports[0]);
                     }
                     return(false);
                 }) == 0 && num2 == 2)
                 {
                     concurrentBag_0.Add(mi);
                 }
             }
         }
     }
     catch (Exception)
     {
     }
     finally
     {
         if (tcp != null)
         {
             tcp.dispose();
         }
     }
 }
Exemplo n.º 2
0
 public void getapips()
 {
     IPAddress[] lips = Dns.GetHostEntry("aplbs.yy.com").AddressList;
     if (lips == null || lips.Count() == 0)
     {
         throw new Exception("DNS 解析错误");
     }
     int[] lports = new int[22]
     {
         8088,
         8084,
         8080,
         8091,
         8082,
         8083,
         80,
         4002,
         20800,
         23,
         32004,
         28,
         4002,
         5002,
         6002,
         23,
         80,
         87,
         3001,
         8080,
         8008,
         6001
     };
     while (concurrentBag_0.Count < int_0)
     {
         Task.Factory.StartNew(delegate
         {
             string ip       = lips[random_0.Next(0, lips.Length)].ToString();
             int port        = lports[random_0.Next(0, lports.Length)];
             InitTcp initTcp = new InitTcp(ip, port);
             if (initTcp.connect())
             {
                 Send_1E73(initTcp);
             }
             else
             {
                 initTcp.dispose();
             }
         });
         Thread.Sleep(1000);
     }
 }
Exemplo n.º 3
0
 public void processdata(InitTcp tcp)
 {
     try
     {
         byte[] array = tcp.recive();
         if (array == null || array.Length == 0)
         {
             throw new Exception("接收数据为空");
         }
         if (bytetool.fromArray(array, false).Substring(8, 4).ToUpper() == "1E74")
         {
             Recv_1E74(array, tcp);
         }
     }
     catch (Exception)
     {
         tcp.dispose();
     }
 }
Exemplo n.º 4
0
 public void Send_1E73(InitTcp tcp)
 {
     try
     {
         byte[] buffer = default(byte[]);
         using (ByteArray byteArray = new ByteArray())
         {
             byteArray.endian   = Endian.LITTLE_ENDIAN;
             byteArray.position = 4;
             byteArray.writeBytes(bytetool.strToToHexByte("1E730000"));
             byteArray.writeShort(200);
             byteArray.method_2(-1);
             byteArray.method_2(-1);
             byteArray.writeBytes(bytetool.strToToHexByte("03010000"));
             byteArray.method_2(0);
             byteArray.writeUTF(Guid.NewGuid().ToString("N"));
             byteArray.writeBytes(bytetool.strToToHexByte(string_2));
             byteArray.writeUTF(string_1);
             byteArray.writeUTF(string_3);
             byteArray.method_2(0);
             byteArray.method_2(0);
             byteArray.writeBytes(bytetool.strToToHexByte("00000408"));
             byteArray.method_2(0);
             byteArray.method_2(0);
             byteArray.position = 0;
             byteArray.writeUnsignedInt(Convert.ToUInt32(byteArray.length));
             buffer = byteArray.Buffer;
             byteArray.Dispose();
         }
         tcp.send(buffer);
         Thread.Sleep(200);
         processdata(tcp);
     }
     catch (Exception)
     {
         tcp.dispose();
     }
 }