Ejemplo n.º 1
0
        public static bool Register(string username, string password, string email, string token, bool message = true)
        {
            Start_Session();
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(token))
            {
                MessageBox.Show("Please fill in all fields!", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            if (!Security.HashCheck())
            {
                Gay = true;
                MessageBox.Show("Invalid Newtonsoft.Json.dll please use the file provided with the download!", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                Process.GetCurrentProcess().Kill();
                return(false);
            }
            if (!Gay)
            {
                var request = (HttpWebRequest)WebRequest.Create(ApiUrl + "register.php");

                var postData = $"username={Algorithms.EncryptData(username).Replace("+", "#")}";
                postData += $"&password={Algorithms.EncryptData(password).Replace("+", "#")}";
                postData += $"&email={Algorithms.EncryptData(email).Replace("+", "#")}";
                postData += $"&hwid={Algorithms.EncryptData(getUniqueID()).Replace("+", "#")}";
                postData += $"&token={Algorithms.EncryptData(token).Replace("+", "#")}";
                postData += $"&programtoken={Algorithms.EncryptData(Secret).Replace("+", "#")}";
                postData += $"&session_id={Key}";
                postData += $"&session_salt={Salt}";
                var data = Encoding.ASCII.GetBytes(postData);

                request.Method        = "POST";
                request.UserAgent     = "AuthGuard";
                request.ContentType   = "application/x-www-form-urlencoded";
                request.ContentLength = data.Length;

                using (var stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                var response = (HttpWebResponse)request.GetResponse();

                var     responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                dynamic json           = JsonConvert.DeserializeObject(Algorithms.DecryptData(responseString));
                string  status         = json.status;
                if (status != "success")
                {
                    string info = json.info;
                    if (message)
                    {
                        MessageBox.Show(info, "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 public static string Var(string Name)
 {
     try
     {
         return(Algorithms.DecryptData(Vars[Name].ToString()));
     }
     catch
     {
         return("Unknown variable");
     }
 }
Ejemplo n.º 3
0
        public static bool GrabVariables(string secretkey, string programtoken, string username, string password)
        {
            Start_Session();
            if (!Gay)
            {
                var request = (HttpWebRequest)WebRequest.Create(ApiUrl + "variables.php");

                var postData = $"&programtoken={Algorithms.EncryptData(programtoken).Replace("+", "#")}";
                postData += $"&username={Algorithms.EncryptData(username).Replace("+", "#")}";
                postData += $"&password={Algorithms.EncryptData(password).Replace("+", "#")}";
                postData += $"&hwid={Algorithms.EncryptData(getUniqueID()).Replace("+", "#")}";
                postData += $"&key={Algorithms.EncryptData(secretkey).Replace("+", "#")}";
                postData += $"&session_id={Key}";
                postData += $"&session_salt={Salt}";
                var data = Encoding.ASCII.GetBytes(postData);

                request.Method        = "POST";
                request.UserAgent     = "AuthGuard";
                request.ContentType   = "application/x-www-form-urlencoded";
                request.ContentLength = data.Length;

                using (var stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                var response = (HttpWebResponse)request.GetResponse();

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

                dynamic json   = JsonConvert.DeserializeObject(Algorithms.DecryptData(responseString));
                string  status = json.status;
                if (status != "success")
                {
                    string info = json.info;
                    MessageBox.Show(info, "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    Vars = JsonConvert.DeserializeObject <Dictionary <string, string> >(json.vars.ToString());
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static bool Login(string username, string password, bool message = true)
        {
            Start_Session();
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Please fill in all fields!", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                if (!Security.HashCheck())
                {
                    Gay = true;
                    MessageBox.Show("Failed hash check on Newtonsoft.Json.dll please use the one provided with the AuthGuard download.", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                    Process.GetCurrentProcess().Kill();
                    return(false);
                }
                if (!Gay)
                {
                    var request = (HttpWebRequest)WebRequest.Create(ApiUrl + "login.php");

                    var postData = $"username={Algorithms.EncryptData(username).Replace("+", "#")}";
                    postData += $"&password={Algorithms.EncryptData(password).Replace("+", "#")}";
                    postData += $"&hwid={Algorithms.EncryptData(getUniqueID()).Replace("+", "#")}";
                    postData += $"&programtoken={Algorithms.EncryptData(Secret).Replace("+", "#")}";
                    postData += $"&timestamp={Algorithms.EncryptData(Algorithms.Encrypt(DateTime.Now.ToString())).Replace("+", "#")}";
                    postData += $"&session_id={Key}";
                    postData += $"&session_salt={Salt}";
                    var data = Encoding.ASCII.GetBytes(postData);

                    request.Method        = "POST";
                    request.UserAgent     = "AuthGuard";
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.ContentLength = data.Length;

                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }

                    var response = (HttpWebResponse)request.GetResponse();

                    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

                    dynamic json   = JsonConvert.DeserializeObject(Algorithms.DecryptData(responseString));
                    string  status = json.status;
                    if (status != "success")
                    {
                        string info = json.info;
                        if (message)
                        {
                            MessageBox.Show(info, "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        return(false);
                    }
                    else
                    {
                        Initialized = true;
                        string datetime = json.timestamp;
                        string hwidd    = json.hwid;
                        string userr    = json.username;
                        string email    = json.email;
                        int    level    = json.level;
                        string expires  = json.expires;
                        string ip       = json.ip;
                        LoadData(userr, email, level, DateTime.Parse(expires), ip);
                        GrabVariables(VariableKey, Secret, userr, password);
                        if (Security.SecurityChecks(Algorithms.Decrypt(datetime), hwidd))
                        {
                            if (!string.IsNullOrEmpty(GuardSettings.Message))
                            {
                                MessageBox.Show(GuardSettings.Message, "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                            }
                            else
                            {
                                Security.ChallengesPassed = true;
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        private static bool Initialize(string version)
        {
            Start_Session();
            if (string.IsNullOrEmpty(version))
            {
                MessageBox.Show("Please enter a version!", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            else
            {
                if (!Security.HashCheck())
                {
                    Gay = true;
                    MessageBox.Show("Invalid Newtonsoft.Json.dll", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                    Process.GetCurrentProcess().Kill();
                }
                if (!Gay)
                {
                    var request = (HttpWebRequest)WebRequest.Create(ApiUrl + "program.php");

                    var postData = $"&programtoken={Algorithms.EncryptData(Secret).Replace("+", "#")}";
                    postData += $"&session_id={Key}";
                    postData += $"&session_salt={Salt}";
                    var data = Encoding.ASCII.GetBytes(postData);

                    request.Method        = "POST";
                    request.UserAgent     = "AuthGuard";
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.ContentLength = data.Length;

                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(data, 0, data.Length);
                    }

                    var response = (HttpWebResponse)request.GetResponse();

                    var     responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                    dynamic json           = JsonConvert.DeserializeObject(Algorithms.DecryptData(responseString));
                    string  status         = json.status;
                    if (status != "success")
                    {
                        string info = json.info;
                        MessageBox.Show(info, "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                    else
                    {
                        InitPassed = true;
                        string versionn    = json.version;
                        int    usercount   = json.clients;
                        string freemode    = json.freemode;
                        string enabled     = json.enabled;
                        string message     = json.message;
                        string updatelink  = json.downloadlink;
                        string hash        = json.hash;
                        string filename    = json.filename;
                        string devmode     = json.devmode;
                        string hwidlock    = json.hwidlock;
                        string programname = json.programname;
                        GuardSettings.HWIDLock    = true;
                        GuardSettings.ProgramName = programname;
                        if (hwidlock != "1")
                        {
                            GuardSettings.HWIDLock = false;
                        }
                        GuardSettings.DeveloperMode = true;
                        if (devmode != "1")
                        {
                            GuardSettings.DeveloperMode = false;
                            try
                            {
                                if (Algorithms.CalculateMD5(filename) != hash)
                                {
                                    Gay = true;
                                    MessageBox.Show("File hash mismatch, exiting...", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                                    Process.GetCurrentProcess().Kill();
                                    return(false);
                                }
                            }
                            catch
                            {
                                Gay = true;
                                MessageBox.Show("Exception caught, please ensure that you have used the hash checker to implement the right hash and exe name in your program settings!", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                                Process.GetCurrentProcess().Kill();
                                return(false);
                            }
                        }
                        bool bruhfreemode;
                        if (freemode == "1")
                        {
                            bruhfreemode = true;
                        }
                        else
                        {
                            bruhfreemode = false;
                        }
                        GuardSettings.Clients  = usercount;
                        GuardSettings.Freemode = bruhfreemode;
                        GuardSettings.Version  = version;
                        GuardSettings.Message  = message;
                        if (enabled == "0")
                        {
                            Gay = true;
                            MessageBox.Show("Program disabled by owner, exiting...", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Error);
                            Process.GetCurrentProcess().Kill();
                            return(false);
                        }
                        if (version != versionn)
                        {
                            MessageBox.Show("Update available!", "AuthGuard", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                            try
                            {
                                Process.Start(updatelink);
                            }
                            catch
                            {
                                Process.Start("https://" + updatelink);
                            }
                            Gay = true;
                            Process.GetCurrentProcess().Kill();
                            return(false);
                        }
                        if (bruhfreemode == true)
                        {
                            GuardSettings.Freemode = true;
                        }
                    }
                }
                return(false);
            }
        }