Exemple #1
0
        public static void CheckForUpdate(long Version)
        {
            if (Settings.Default.version >= Version)
            {
                DarkMessageBoxHelper.DMB("Update", "There is an update available! Downloading now!");
                WebClient wc = new WebClient();
                if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/ProjectPlatoV2.exe"))
                {
                    DarkMessageBoxHelper.DMB("ERROR", "Please rename this swapper or move it off the desktop");
                }
                else
                {
                    wc.DownloadFile("https://github.com/Tamely/PlatoV2/releases/download/v" + Settings.Default.version + ".0/ProjectPlatoV2.exe", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ProjectPlatoV2.exe");
                    DarkMessageBoxHelper.DMB("Update", "Update downloaded on your desktop! Starting new exe!");
                    Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\ProjectPlatoV2.exe");

                    string batchCommands = string.Empty;
                    string exeFileName   = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty).Replace("/", "\\");

                    batchCommands += "@ECHO OFF\n";
                    batchCommands += "ping 127.0.0.1 > nul\n";
                    batchCommands += "echo j | del /F ";
                    batchCommands += exeFileName + "\n";
                    batchCommands += "echo j | del deletePlato.bat";

                    File.WriteAllText("deletePlato.bat", batchCommands);

                    Process.Start("deletePlato.bat");

                    Environment.Exit(-1);
                }
            }
        }
Exemple #2
0
 public static void News(string news)
 {
     if (news != "")
     {
         DarkMessageBoxHelper.DMB("News", news);
     }
 }
Exemple #3
0
        public static bool Login(string username, string password)
        {
            if (!Constants.Initialized)
            {
                MessageBox.Show("Please initialize your application first!", OnProgramStart.Name);
                Process.GetCurrentProcess().Kill();
            }
            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                MessageBox.Show("Missing user login information!", ApplicationSettings.Name);
                Process.GetCurrentProcess().Kill();
            }
            string[] response = new string[] { };
            using (WebClient wc = new WebClient())
            {
                try
                {
                    Security.Start();
                    wc.Proxy = null;
                    response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection
                    {
                        ["token"] = Encryption.EncryptService(Constants.Token),
                        ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()),
                        ["aid"] = Encryption.APIService(OnProgramStart.AID),
                        ["session_id"] = Constants.IV,
                        ["api_id"] = Constants.APIENCRYPTSALT,
                        ["api_key"] = Constants.APIENCRYPTKEY,
                        ["username"] = Encryption.APIService(username),
                        ["password"] = Encryption.APIService(password),
                        ["hwid"] = Encryption.APIService(Constants.HWID()),
                        ["session_key"] = Constants.Key,
                        ["secret"] = Encryption.APIService(OnProgramStart.Secret),
                        ["type"] = Encryption.APIService("login")
                    }))).Split("|".ToCharArray()));
                    if (response[0] != Constants.Token)
                    {
                        MessageBox.Show("Security error has been triggered!", OnProgramStart.Name);
                        Process.GetCurrentProcess().Kill();
                    }
                    if (Security.MaliciousCheck(response[1]))
                    {
                        MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name);
                        Process.GetCurrentProcess().Kill();
                    }
                    if (Constants.Breached)
                    {
                        MessageBox.Show("Possible malicious activity detected!", OnProgramStart.Name);
                        Process.GetCurrentProcess().Kill();
                    }
                    switch (response[2])
                    {
                    case "success":
                        User.ID           = response[3];
                        User.Username     = response[4];
                        User.Password     = response[5];
                        User.Email        = response[6];
                        User.HWID         = response[7];
                        User.UserVariable = response[8];
                        User.Rank         = response[9];
                        User.IP           = response[10];
                        User.Expiry       = response[11];
                        User.LastLogin    = response[12];
                        User.RegisterDate = response[13];
                        string Variables = response[14];
                        foreach (string var in Variables.Split('~'))
                        {
                            string[] items = var.Split('^');
                            try
                            {
                                App.Variables.Add(items[0], items[1]);
                            }
                            catch
                            {
                                //If some are null or not loaded, just ignore.
                                //Error will be shown when loading the variable anyways
                            }
                        }
                        Security.End();
                        return(true);

                    case "invalid_details":
                        DarkMessageBoxHelper.DMB("ERROR", "Sorry, your username/password does not match!");
                        Security.End();
                        return(false);

                    case "time_expired":
                        DarkMessageBoxHelper.DMB("ERROR", "Your subscription has expired!");
                        Security.End();
                        return(false);

                    case "hwid_updated":
                        DarkMessageBoxHelper.DMB("ERROR", "New machine has been binded, re-open the application!");
                        Security.End();
                        return(false);

                    case "invalid_hwid":
                        DarkMessageBoxHelper.DMB("ERROR", "This user is binded to another computer.");
                        Security.End();
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ApplicationSettings.Name);
                    Security.End();
                    Process.GetCurrentProcess().Kill();
                }
                return(false);
            }
        }
Exemple #4
0
        public static void Initialize(string name, string aid, string secret, string version)
        {
            if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(aid) || string.IsNullOrWhiteSpace(secret) || string.IsNullOrWhiteSpace(version))
            {
                DarkMessageBoxHelper.DMB("Error", "Invalid application information!");
                Process.GetCurrentProcess().Kill();
            }
            AID     = aid;
            Secret  = secret;
            Version = version;
            Name    = name;
            string[] response = new string[] { };
            using (WebClient wc = new WebClient())
            {
                try
                {
                    wc.Proxy = null;
                    Security.Start();
                    response = (Encryption.DecryptService(Encoding.Default.GetString(wc.UploadValues(Constants.ApiUrl, new NameValueCollection
                    {
                        ["token"] = Encryption.EncryptService(Constants.Token),
                        ["timestamp"] = Encryption.EncryptService(DateTime.Now.ToString()),
                        ["aid"] = Encryption.APIService(AID),
                        ["session_id"] = Constants.IV,
                        ["api_id"] = Constants.APIENCRYPTSALT,
                        ["api_key"] = Constants.APIENCRYPTKEY,
                        ["session_key"] = Constants.Key,
                        ["secret"] = Encryption.APIService(Secret),
                        ["type"] = Encryption.APIService("start")
                    }))).Split("|".ToCharArray()));
                    if (Security.MaliciousCheck(response[1]))
                    {
                        DarkMessageBoxHelper.DMB("Error", "Possible malicious activity detected!");
                        Process.GetCurrentProcess().Kill();
                    }
                    if (Constants.Breached)
                    {
                        DarkMessageBoxHelper.DMB("Error", "Possible malicious activity detected!");
                        Process.GetCurrentProcess().Kill();
                    }
                    if (response[0] != Constants.Token)
                    {
                        DarkMessageBoxHelper.DMB("Error", "Possible malicious activity detected!");
                        Process.GetCurrentProcess().Kill();
                    }
                    switch (response[2])
                    {
                    case "success":
                        Constants.Initialized = true;
                        if (response[3] == "Enabled")
                        {
                            ApplicationSettings.Status = true;
                        }
                        if (response[4] == "Enabled")
                        {
                            ApplicationSettings.DeveloperMode = true;
                        }
                        ApplicationSettings.Hash        = response[5];
                        ApplicationSettings.Version     = response[6];
                        ApplicationSettings.Update_Link = response[7];
                        if (response[8] == "Enabled")
                        {
                            ApplicationSettings.Freemode = true;
                        }
                        if (response[9] == "Enabled")
                        {
                            ApplicationSettings.Login = true;
                        }
                        ApplicationSettings.Name = response[10];
                        if (response[11] == "Enabled")
                        {
                            ApplicationSettings.Register = true;
                        }
                        if (ApplicationSettings.DeveloperMode)
                        {
                            DarkMessageBoxHelper.DMB("Dev Mode", "Application is in Developer Mode, bypassing integrity and update check!");
                            File.Create(Environment.CurrentDirectory + "/integrity.log").Close();
                            string hash = Security.Integrity(Process.GetCurrentProcess().MainModule.FileName);
                            File.WriteAllText(Environment.CurrentDirectory + "/integrity.log", hash);
                        }
                        else
                        {
                            if (response[12] == "Enabled")
                            {
                                if (ApplicationSettings.Hash != Security.Integrity(Process.GetCurrentProcess().MainModule.FileName))
                                {
                                    DarkMessageBoxHelper.DMB("ERROR", $"File has been tampered with, couldn't verify integrity!");
                                    Process.GetCurrentProcess().Kill();
                                }
                            }
                            if (ApplicationSettings.Version != Version)
                            {
                                DarkMessageBoxHelper.DMB("ERROR", "Update Available!");
                                Process.Start(ApplicationSettings.Update_Link);
                                Process.GetCurrentProcess().Kill();
                            }
                        }
                        if (ApplicationSettings.Status == false)
                        {
                            DarkMessageBoxHelper.DMB("ERROR", "This application is disabled! Try again later!");
                            Process.GetCurrentProcess().Kill();
                        }
                        break;

                    case "binderror":
                        MessageBox.Show(Encryption.Decode("RmFpbGVkIHRvIGJpbmQgdG8gc2VydmVyLCBjaGVjayB5b3VyIEFJRCAmIFNlY3JldCBpbiB5b3VyIGNvZGUh"), Name);
                        Process.GetCurrentProcess().Kill();
                        return;

                    case "banned":
                        MessageBox.Show("This application has been banned for violating the TOS" + Environment.NewLine + "Contact us at [email protected]", Name);
                        Process.GetCurrentProcess().Kill();
                        return;
                    }
                    Security.End();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Name);
                    Process.GetCurrentProcess().Kill();
                }
            }
        }