public bool Login( string username, string password, Enums.OnlineStatus onlineStatus = Enums.OnlineStatus.Online, Enums.DeviceType deviceType = Enums.DeviceType.Android) { try { Current = this; PacketManager.InitializeHandlers(); CommandManager.InitializeCommands(); Username = username; Password = password; OnlineStatus = onlineStatus; DeviceType = deviceType; _tcpClient = new TcpClient(_host, _port); Current = this; _networkStream = _tcpClient.GetStream(); SendPacket(PacketTemplates.Logon(Username, DeviceType)); _networkStream.BeginRead(_buffer, 0, _buffer.Length, ReadCallback, null); Console.WriteLine(_buffer.Length); return true; } catch (Exception a) { return false; } }
public static void HandlePacket(Tcp tcp, Packet packet) { if (_packetHandlers.ContainsKey(packet.Command)) _packetHandlers[packet.Command].Process(tcp, packet); else Console.WriteLine("UNSUPPORTED COMMAND: " + packet.Command); }
public void Process(Tcp tcp, Packet packet) { return; Console.WriteLine("[Start Response Packet]"); Console.WriteLine(packet.ToString()); var what = int.Parse(packet["WHAT"]); Console.WriteLine("[Stop Response Packet]"); }
public void Process(Tcp tcp, Packet packet) { var payload = Encoding.Default.GetBytes(packet.Payload); // windows-1252 var password = Encoding.Default.GetBytes(tcp.Password); var encrypted = Crypto.GenerateAuth(payload, password); var authpacket = PacketTemplates.Auth(encrypted, Enums.OnlineStatus.Online); tcp.SendPacket(authpacket); }
public void Process(Tcp tcp, Packet packet) { // Gather info for deserialization int iv = 0; int rk = 0; if (packet.ContainsHeader("IV")) iv = int.Parse(packet["IV"]); if (iv > 0) rk = int.Parse(packet["RK"]); int l = packet.Payload.Length; int length = packet.Payload.Length - iv - rk; int startPos = iv; // Time to extract information var enc = Encoding.GetEncoding("windows-1252"); // Allows support for other OS (provided they have the windows-1252 encoding) var maps = Deserialize(enc.GetBytes(packet.Payload), startPos, length); try { var contactsMap = Deserialize(maps["contacts"], 0, maps["contacts"].Length); ParseContacts(contactsMap); } catch { } try { var groupsMap = Deserialize(maps["group_sub"], 0, maps["group_sub"].Length); ParseGroups(groupsMap); } catch { } try { var blockedMap = Deserialize(maps["blocked"], 0, maps["blocked"].Length); ParseBlockedUsers(blockedMap); } catch { } try { var requestsMap = Deserialize(maps["contact_add"], 0, maps["contact_add"].Length); ParseContactRequests(requestsMap); } catch { } if (_loginPacket) { var profile = new Contact(); profile.ContactID = uint.Parse(Encoding.UTF8.GetString(maps["sub-id"])); profile.Reputation = int.Parse(Encoding.UTF8.GetString(maps["rep"])); profile.Privileges = uint.Parse(Encoding.UTF8.GetString(maps["privileges"])); profile.Nickname = Encoding.UTF8.GetString(maps["nickname"]); Cache.Profile = profile; tcp.RaiseLoginSuccess(); _loginPacket = false; } }
//public Tcp(string host = "80.69.129.4", int port = 12345) 80.69.129.12 //public Tcp(string host = "80.69.129.64", int port = 8080) public Tcp(string host = "80.69.129.123", int port = 443) { _host = host; _port = port; _parser = new PacketParser(packet => { if (PacketParsed != null) PacketParsed(packet); PacketManager.HandlePacket(this, packet); }); Current = this; }
//public Tcp(string host = "80.69.129.4", int port = 12345) 80.69.129.12 //public Tcp(string host = "80.69.129.64", int port = 8080) public Tcp(string host = "80.69.129.123", int port = 443) { _host = host; _port = port; _parser = new PacketParser(packet => { if (PacketParsed != null) { PacketParsed(packet); } PacketManager.HandlePacket(this, packet); }); Current = this; }
static void Main(string[] args) { // Load our Settings Settings settings = new Settings(); tcp = new Tcp(); tcp.LoginSuccess += () => { }; // Packet Received and sent events tcp.PacketSent += packet => Console.WriteLine("Packet Sent: " + packet.Command); tcp.PacketParsed += packet => Console.WriteLine("Packet Parsed: " + packet.Command); // Send our Login Packet tcp.Login(settings.JsonEmail, settings.JsonPassword); Console.Read(); }
public void Process(Tcp tcp, Packet packet) { // Gather info for deserialization int iv = 0; int rk = 0; if (packet.ContainsHeader("IV")) { iv = int.Parse(packet["IV"]); } if (iv > 0) { rk = int.Parse(packet["RK"]); } int l = packet.Payload.Length; int length = packet.Payload.Length - iv - rk; int startPos = iv; // Time to extract information var enc = Encoding.GetEncoding("windows-1252"); // Allows support for other OS (provided they have the windows-1252 encoding) var maps = Deserialize(enc.GetBytes(packet.Payload), startPos, length); try { var contactsMap = Deserialize(maps["contacts"], 0, maps["contacts"].Length); ParseContacts(contactsMap); } catch { } try { var groupsMap = Deserialize(maps["group_sub"], 0, maps["group_sub"].Length); ParseGroups(groupsMap); } catch { } try { var blockedMap = Deserialize(maps["blocked"], 0, maps["blocked"].Length); ParseBlockedUsers(blockedMap); } catch { } try { var requestsMap = Deserialize(maps["contact_add"], 0, maps["contact_add"].Length); ParseContactRequests(requestsMap); } catch { } if (_loginPacket) { var profile = new Contact(); profile.ContactID = uint.Parse(Encoding.UTF8.GetString(maps["sub-id"])); profile.Reputation = int.Parse(Encoding.UTF8.GetString(maps["rep"])); profile.Privileges = uint.Parse(Encoding.UTF8.GetString(maps["privileges"])); profile.Nickname = Encoding.UTF8.GetString(maps["nickname"]); Cache.Profile = profile; tcp.RaiseLoginSuccess(); _loginPacket = false; } }
public void Process(Tcp tcp, Packet packet) { System.Console.WriteLine("GroupUpdate Here"); }
public void Process(Tcp tcp, Packet packet) { }
public void Process(Tcp tcp, Packet packet) { tcp.SendPacket(PacketTemplates.PING()); }
public void Process(Tcp tcp, Packet packet) { //tcp.SendPacket(PacketTemplates.PING()); CommandManager.HandleMessage(packet); }