Exemplo n.º 1
0
        private void try_login()
        {
            try
            {
                if (username_input.Text == "")
                {
                    throw new Exception("Sisesta kasutajanimi");
                }

                if (password_input.Text == "")
                {
                    throw new Exception("Sisesta parool");
                }

                network udpcon = new network();

                if (udpcon.connect_to_server())
                {
                    // Get sha512 password
                    string sha512_password = "";

                    if (Properties.Settings.Default.remember_me)
                    {
                        sha512_password = Properties.Settings.Default.sha512_pw;
                    }
                    else
                    {
                        UnicodeEncoding UE         = new UnicodeEncoding();
                        byte[]          message    = UE.GetBytes(password_input.Text);
                        SHA512Managed   hashString = new SHA512Managed();

                        byte[] hashValue = hashString.ComputeHash(message);
                        foreach (byte x in hashValue)
                        {
                            sha512_password += String.Format("{0:x2}", x);
                        }
                    }


                    // Let's start building the packet
                    List <string> login_packet = new List <string>();
                    string        version      = Properties.Settings.Default.version.ToString();
                    //Clipboard.SetText(sha512_password);
                    if (version.Contains(","))
                    {
                        version = version.Replace(',', '.');
                    }

                    login_packet.Add(username_input.Text.ToLower());
                    login_packet.Add(sha512_password);

                    login_packet.Add(version);
                    login_packet.Add(get_hw_id());

                    // Send login packet and recieve response
                    byte[] login_response = udpcon.send_and_recieve(0x02, login_packet);

                    if (login_response[0] == 0xFA)
                    {
                        // we have failed login attempt
                        switch (login_response[1])
                        {
                        case 0x01:
                            throw new Exception("Tundmatu veateade!");

                        case 0x02:
                            throw new Exception("Sinu kliendi versioon on liiga vana!");

                        case 0x03:
                            throw new Exception("Vale kasutajanimi või parool!");

                        case 0x04:
                            throw new Exception("Kasutaja on juba sisse loginud. Juhul kui Sinu ühendus aegus, oota 2min!");

                        case 0x05:
                            List <string> ban_info = udpcon.extract_data(login_response);
                            throw new Exception("Sa oled banned.\nPõhjus: " + ban_info[0] + "\nKestab kuni: " + ban_info[1]);

                        case 0x06:
                            throw new Exception("Serveriga ühenduse loomine ebaõnnestus!");
                        }
                    }

                    if (login_response[0] == 0xFF)
                    {
                        // Login was successful
                        List <string> recieved_data = udpcon.extract_data(login_response);
                        steamid = recieved_data[0];
                        string password = recieved_data[1];
                        s_hash = long.Parse(recieved_data[2]);

                        if (password != sha512_password)
                        {
                            List <string> abuse_data = new List <string>();
                            abuse_data.Add("Passwords do not match at user-side after getting 'ok'");
                            //main_client.send_data(0x16, abuseData);
                        }
                        else
                        {
                            if (remember_me.Checked)
                            {
                                string keyName = @"HKEY_CURRENT_USER\SOFTWARE\everest\Gather";
                                Registry.SetValue(keyName, "username", username_input.Text);
                                Registry.SetValue(keyName, "password", sha512_password);
                                Registry.SetValue(keyName, "remember_me", true);
                            }
                            else
                            {
                                string keyName = @"HKEY_CURRENT_USER\SOFTWARE\everest\Gather";
                                Registry.SetValue(keyName, "username", "");
                                Registry.SetValue(keyName, "password", "");
                                Registry.SetValue(keyName, "remember_me", false);
                            }

                            // initialize new window and give refrence to connection and this form
                            main_hub_scr main_window = new main_hub_scr(this, udpcon);
                            main_window.Show();
                            this.Hide();
                            //throw new Exception("LOGIN OK");
                        }
                    }

                    //c_msgbox.show_msg(false, "See funktsioon ei ole valmis veel!\nSinu hw_id: " + get_hw_id());
                }
                else
                {
                    c_msgbox.show_msg(true, "Serveriga ühenduse loomine ebaõnnestus!");
                }
            }
            catch (Exception ex)
            {
                c_msgbox.show_msg(true, ex.Message);
            }
        }
Exemplo n.º 2
0
        private void try_register()
        {
            try
            {
                if (txt_chk.is_empty(username_input.Text))
                {
                    throw new Exception("Sisestage kasutajanimi!");
                }

                if (txt_chk.is_empty(password_input.Text))
                {
                    throw new Exception("Sisestage parool!");
                }

                if (txt_chk.is_empty(password_repeat_input.Text))
                {
                    throw new Exception("Sisestage kordus parool!");
                }

                if (txt_chk.is_empty(email_input.Text))
                {
                    throw new Exception("Sisestage email!");
                }

                if (txt_chk.is_empty(steamid_input.Text))
                {
                    throw new Exception("Valige menüüst enda steamid!");
                }

                if (password_repeat_input.Text != password_input.Text)
                {
                    throw new Exception("Sisestatud paroolid ei klapi!");
                }

                if (!txt_chk.is_text_aZ09(username_input.Text))
                {
                    throw new Exception("Kasutajanimi tohib sisaldada ainult\n tähti a-Z ja numbreid 0-9!");
                }

                if (!txt_chk.is_email(email_input.Text))
                {
                    throw new Exception("Emaili formaat on ebakorrektne!");
                }


                UnicodeEncoding UE              = new UnicodeEncoding();
                byte[]          message         = UE.GetBytes(password_input.Text);
                SHA512Managed   hashString      = new SHA512Managed();
                string          sha512_password = "";

                byte[] hashValue = hashString.ComputeHash(message);
                foreach (byte x in hashValue)
                {
                    sha512_password += String.Format("{0:x2}", x);
                }

                network udpcon = new network();

                if (udpcon.connect_to_server())
                {
                    List <string> reg_packet = new List <string>();
                    reg_packet.Add(username_input.Text);
                    reg_packet.Add(username_input.Text.ToLower());
                    reg_packet.Add(sha512_password);
                    reg_packet.Add(email_input.Text);
                    reg_packet.Add(steamid_input.Text);

                    byte[] register_response = udpcon.send_and_recieve(0x18, reg_packet);

                    if (register_response[0] == 0xFF)
                    {
                        // successful register
                        c_msgbox.show_msg(false, "Registreerimine õnnestus!");
                        this.Close();
                    }
                    else
                    {
                        // failed to register
                        switch (register_response[1])
                        {
                        case 0x01:
                            throw new Exception("Server ei suutnud registreerimist käsitleda!");

                        case 0x02:
                            throw new Exception("Selline kasutajanimi juba eksisteerib!");

                        case 0x03:
                            throw new Exception("Selline e-mail juba eksisteerib!");

                        case 0x04:
                            throw new Exception("Selline steamid juba eksisteerib!");

                        case 0x06:
                            throw new Exception("Serveriga ühenduse loomine ebaõnnestus!");
                        }
                    }
                }
                else
                {
                    c_msgbox.show_msg(true, "Serveriga ühenduse loomine ebaõnnestus!");
                }
            }
            catch (Exception ex)
            {
                c_msgbox.show_msg(false, ex.Message);
            }
        }
Exemplo n.º 3
0
        public main_hub_scr(login_scr r_login, network r_udpclient)
        {
            InitializeComponent();



            // send prof pic request
            List <string> prof_pic_req_packet = new List <string>();

            prof_pic_req_packet.Add(r_login.steamid);
            r_udpclient.send_data(0x27, prof_pic_req_packet);

            // transfer refrences
            login_screen     = r_login;
            udpclient        = r_udpclient;
            shared_udpclient = r_udpclient;

            // set playscreen ref
            play_screen = new play_scr(this);

            // set lobby screen ref
            lobby_screen = new lobby_scr(this);

            // set ready screen ref
            ready_screen = new ready_scr(this);

            // load fonts
            username_label.Font = c_font.load_font(20, 1, true);


            // initialize packet listener thread
            listener_thread = new Thread(new ThreadStart(manage_packets));
            listener_thread.Start();



            // USER STUFF
            // load profile picture
            //paint_my_profile_picture("asd");
            my_info.steamid  = login_screen.steamid;
            my_info.username = login_screen.get_username();
            my_info.s_hash   = login_screen.s_hash;

            // Update labels
            username_label.Text = my_info.username;



            // add screens to screen panel

            // home screen
            keep_alive_tick(this, new EventArgs());
            home_screen.TopLevel   = false;
            home_screen.AutoScroll = false;
            screen_panel.Controls.Add(home_screen);
            home_screen.Show();

            // play screen
            play_screen.TopLevel   = false;
            play_screen.AutoScroll = false;
            screen_panel.Controls.Add(play_screen);

            // warmup screen
            warmup_screen.TopLevel   = false;
            warmup_screen.AutoScroll = false;
            screen_panel.Controls.Add(warmup_screen);
            warmup_screen.servers.Add(new warmup_server("212.49.20.161", 27015, 0));
            warmup_screen.servers.Add(new warmup_server("212.49.20.163", 27015, 1));
            warmup_screen.servers.Add(new warmup_server("212.49.20.163", 27025, 2));
            warmup_screen.servers.Add(new warmup_server("212.49.20.163", 27035, 3));
            warmup_screen.servers.Add(new warmup_server("212.49.20.163", 27045, 4));


            // stats screen
            stats_screen.TopLevel   = false;
            stats_screen.AutoScroll = false;
            screen_panel.Controls.Add(stats_screen);

            // lobby screen
            lobby_screen.TopLevel   = false;
            lobby_screen.AutoScroll = false;
            screen_panel.Controls.Add(lobby_screen);

            // initialize timers
            keep_alive.Interval = 2000; // 2 sec
            keep_alive.Tick    += new EventHandler(keep_alive_tick);
            keep_alive.Start();

            server_alive.Interval = 30000; // 30 sec
            server_alive.Tick    += new EventHandler(check_server_alive);
            server_alive.Start();

            update_warmup_servers.Interval = 10000;
            update_warmup_servers.Tick    += new EventHandler(warmup_screen.refresh_servers);
            update_warmup_servers.Start();
        }