Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace LoginServer
  10. {
  11. class Client
  12. {
  13. byte[] buffer = new byte[1024];
  14. CollorizeString collorizeString = new CollorizeString();
  15.  
  16. public Client (TcpClient client)
  17. {
  18. Console.WriteLine("Client " + client.Client.RemoteEndPoint.ToString() + " connected...");
  19. //client.GetStream().Write(buffer, 0, buffer.Length);
  20. int bytesRead = client.GetStream().Read(buffer, 0, buffer.Length);
  21. Array.Resize<byte>(ref buffer, bytesRead);
  22.  
  23. collorizeString.PaintString("Client => Server: ", ConsoleColor.Blue, ConsoleColor.White);
  24. collorizeString.PaintString("Hex bytes: ", ConsoleColor.DarkRed, ConsoleColor.Black);
  25. Console.WriteLine(BitConverter.ToString(buffer).Replace("-", " "));
  26. collorizeString.PaintString("Dec bytes: ", ConsoleColor.DarkGreen, ConsoleColor.Black);
  27. for (int i = 0; i < buffer.Length; i++)
  28. {
  29. if (i % 16 == 0)
  30. {
  31. Console.WriteLine();
  32. }
  33. Console.Write(buffer[i] + " ");
  34. }
  35. Console.WriteLine();
  36.  
  37. //client.GetStream().Write(buffer, 0, buffer.Length);
  38.  
  39. //188.235.130.13
  40. int port = ((IPEndPoint)client.Client.RemoteEndPoint).Port;
  41. byte bp1 = (byte)(port & 0xFF);
  42. byte bp2 = (byte)((port >> 8) & 0xFF);
  43. byte[] bufferPost = { 0xBC, 0x5F, 0xF4, 0x4A, 0xBC, 0xF8, 0xE0, 0x46, 0x9A, 0x59, 0xCD, 0x5A, 0x08, 0x00, 0x45, 0x70,
  44. 0x00, 0x34, 0x67, 0xAF, 0x40, 0x00, 0x75, 0x06, 0x53, 0xA5, 0x7F, 0x00, 0x00, 0x01, 0xC0, 0xA8,
  45. 0x00, 0x03, 0x2A, 0xFC, bp1, bp2, 0x66, 0xF5, 0x49, 0xC9, 0x91, 0x8A, 0x2D, 0x58, 0x80, 0x12,
  46. 0x20, 0x00, 0x81, 0xEC, 0x00, 0x00, 0x02, 0x04, 0x05, 0xAC, 0x01, 0x03, 0x03, 0x08, 0x01, 0x01,
  47. 0x04, 0x02
  48. };
  49. // пакет для авторизации
  50. client.GetStream().Write(bufferPost, 0, 66);
  51.  
  52. collorizeString.PaintString("Server => Client: ", ConsoleColor.Blue, ConsoleColor.White);
  53. collorizeString.PaintString("Encoded bytes: ", ConsoleColor.DarkRed, ConsoleColor.Black);
  54. Console.WriteLine(BitConverter.ToString(bufferPost).Replace("-", " "));
  55. collorizeString.PaintString("Decoded bytes: ", ConsoleColor.DarkGreen, ConsoleColor.Black);
  56.  
  57. for (int i = 0; i < bufferPost.Length; i++)
  58. {
  59. if (i % 16 == 0)
  60. {
  61. Console.WriteLine();
  62. }
  63. Console.Write((bufferPost[i] + " "));
  64. }
  65. Console.WriteLine();
  66.  
  67. Console.WriteLine();
  68. Console.WriteLine("Connection with " + client.Client.RemoteEndPoint.ToString() + " is closed.");
  69. client.GetStream().Close();
  70. client.Close();
  71.  
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement