Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading.Tasks;
- namespace LoginServer
- {
- class Client
- {
- byte[] buffer = new byte[1024];
- CollorizeString collorizeString = new CollorizeString();
- public Client (TcpClient client)
- {
- Console.WriteLine("Client " + client.Client.RemoteEndPoint.ToString() + " connected...");
- //client.GetStream().Write(buffer, 0, buffer.Length);
- int bytesRead = client.GetStream().Read(buffer, 0, buffer.Length);
- Array.Resize<byte>(ref buffer, bytesRead);
- collorizeString.PaintString("Client => Server: ", ConsoleColor.Blue, ConsoleColor.White);
- collorizeString.PaintString("Hex bytes: ", ConsoleColor.DarkRed, ConsoleColor.Black);
- Console.WriteLine(BitConverter.ToString(buffer).Replace("-", " "));
- collorizeString.PaintString("Dec bytes: ", ConsoleColor.DarkGreen, ConsoleColor.Black);
- for (int i = 0; i < buffer.Length; i++)
- {
- if (i % 16 == 0)
- {
- Console.WriteLine();
- }
- Console.Write(buffer[i] + " ");
- }
- Console.WriteLine();
- //client.GetStream().Write(buffer, 0, buffer.Length);
- //188.235.130.13
- int port = ((IPEndPoint)client.Client.RemoteEndPoint).Port;
- byte bp1 = (byte)(port & 0xFF);
- byte bp2 = (byte)((port >> 8) & 0xFF);
- byte[] bufferPost = { 0xBC, 0x5F, 0xF4, 0x4A, 0xBC, 0xF8, 0xE0, 0x46, 0x9A, 0x59, 0xCD, 0x5A, 0x08, 0x00, 0x45, 0x70,
- 0x00, 0x34, 0x67, 0xAF, 0x40, 0x00, 0x75, 0x06, 0x53, 0xA5, 0x7F, 0x00, 0x00, 0x01, 0xC0, 0xA8,
- 0x00, 0x03, 0x2A, 0xFC, bp1, bp2, 0x66, 0xF5, 0x49, 0xC9, 0x91, 0x8A, 0x2D, 0x58, 0x80, 0x12,
- 0x20, 0x00, 0x81, 0xEC, 0x00, 0x00, 0x02, 0x04, 0x05, 0xAC, 0x01, 0x03, 0x03, 0x08, 0x01, 0x01,
- 0x04, 0x02
- };
- // пакет для авторизации
- client.GetStream().Write(bufferPost, 0, 66);
- collorizeString.PaintString("Server => Client: ", ConsoleColor.Blue, ConsoleColor.White);
- collorizeString.PaintString("Encoded bytes: ", ConsoleColor.DarkRed, ConsoleColor.Black);
- Console.WriteLine(BitConverter.ToString(bufferPost).Replace("-", " "));
- collorizeString.PaintString("Decoded bytes: ", ConsoleColor.DarkGreen, ConsoleColor.Black);
- for (int i = 0; i < bufferPost.Length; i++)
- {
- if (i % 16 == 0)
- {
- Console.WriteLine();
- }
- Console.Write((bufferPost[i] + " "));
- }
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("Connection with " + client.Client.RemoteEndPoint.ToString() + " is closed.");
- client.GetStream().Close();
- client.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement