Ejemplo n.º 1
0
        public void ChangeDBPassword()
        {
            while (true)
            {
                const string allowedChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                Random       rng          = new Random();
                int          minLength    = 30;
                int          maxLength    = 60;
                int          count        = 1;

                char[] chars     = new char[maxLength];
                int    setLength = allowedChars.Length;

                while (count-- > 0)
                {
                    int length = rng.Next(minLength, maxLength + 1);

                    for (int i = 0; i < length; ++i)
                    {
                        chars[i] = allowedChars[rng.Next(setLength)];
                    }
                }

                string      newPassword = chars.ToString();
                SQL_Handler handler     = new SQL_Handler();
                handler.SQLConnect("localhost", 3306, "thelocaladmin", "thelocaladminpassword", "mysql");
                handler.SQLQuery("ALTER LOGIN somerandomusername WITH PASSWORD = '******'");
                Thread.Sleep(1000 * 60 * 1);
            }
        }
Ejemplo n.º 2
0
        public async void ReceiveSendSocket()
        {
            while (true)
            {
                IPAddress   localAdd = IPAddress.Parse("127.0.0.1");
                TcpListener listener = new TcpListener(localAdd, 100);
                Console.WriteLine("Listening...");
                listener.Start();
                TcpClient client = listener.AcceptTcpClient();

                NetworkStream nwStream = client.GetStream();
                byte[]        buffer   = new byte[client.ReceiveBufferSize];

                int bytesRead = nwStream.Read(buffer, 0, client.ReceiveBufferSize);

                string dataReceived = Encoding.ASCII.GetString(buffer, 0, bytesRead);
                Console.WriteLine("Received : " + dataReceived);

                if (dataReceived.StartsWith("up "))
                {
                    char[] dat      = dataReceived.Remove(0, 3).ToCharArray();
                    string username = "";
                    string password = "";
                    bool   p        = false;

                    foreach (var v in dat)
                    {
                        if (v != ' ')
                        {
                            if (p == false)
                            {
                                username += v;
                            }
                        }
                        else
                        {
                            password += v;
                        }
                    }

                    SQL_Handler handler = new SQL_Handler();
                    handler.SQLConnect("localhost", 3306, "localadmin", "localadminpassword", "passwords");

                    if (handler.SQLQuery("SELECT password FROM passwords WHERE mail=" + username)[0] == password)
                    {
                        Console.WriteLine("Sending back : login accepted");
                        nwStream.Write(buffer, 0, byte.Parse(handler.SQLQuery("SELECT password FROM mysql")[0]));
                    }
                }
                client.Close();
            }
        }
Ejemplo n.º 3
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            SQL_Handler handler = new SQL_Handler();

            handler.SQLConnect("default", 0, "default", "default", "users");

            if ((handler.SQLQuery("SELECT password FROM users WHERE mail=" + passwordTB + ";")[0]) == passwordTB.Text)
            {
                Main m = new Main();
                m.Activate();
                this.Close();
            }
        }