예제 #1
0
 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;
     }
 }
예제 #2
0
 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);
 }
예제 #3
0
 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]");
 }
예제 #4
0
 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);
 }
예제 #5
0
        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;
            }
        }
예제 #6
0
 //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;
 }
예제 #7
0
 //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;
 }
예제 #8
0
        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();
        }
예제 #9
0
        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();
        }
예제 #10
0
        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;
            }
        }
예제 #11
0
 public void Process(Tcp tcp, Packet packet)
 {
     System.Console.WriteLine("GroupUpdate Here");
 }
예제 #12
0
        public void Process(Tcp tcp, Packet packet)
        {

        }
예제 #13
0
 public void Process(Tcp tcp, Packet packet)
 {
     tcp.SendPacket(PacketTemplates.PING());
 }
예제 #14
0
 public void Process(Tcp tcp, Packet packet)
 {
 
     //tcp.SendPacket(PacketTemplates.PING());
     CommandManager.HandleMessage(packet);
 }
예제 #15
0
 public void Process(Tcp tcp, Packet packet)
 {
     tcp.SendPacket(PacketTemplates.PING());
 }
예제 #16
0
 public void Process(Tcp tcp, Packet packet)
 {
     System.Console.WriteLine("GroupUpdate Here");
 }
예제 #17
0
 public void Process(Tcp tcp, Packet packet)
 {
     //tcp.SendPacket(PacketTemplates.PING());
     CommandManager.HandleMessage(packet);
 }
예제 #18
0
 public void Process(Tcp tcp, Packet packet)
 {
 }