Ejemplo n.º 1
0
        public static void MUFRTime()
        {
            if (ServerProxy.Running())
            {
                if (AntiCheat.SpeedTicket == 0)
                {
                    AntiCheat.SpeedTicket++;
                    AntiCheat.IAmSpeed = 1000;
                }
                else if (AntiCheat.SpeedTicket == 1)
                {
                    AntiCheat.SpeedTicket++;
                    AntiCheat.IAmSpeed = 500;
                }

                int TimeSeconds = InformationCache.RestartTimer;

                if (TimeSeconds >= 2592000)
                {
                    InformationCache.RestartTimer = TimeSeconds - 2592000;
                }
                else if (TimeSeconds >= 86400)
                {
                    InformationCache.RestartTimer = TimeSeconds - 86400;
                }
                else if (TimeSeconds >= 3600)
                {
                    InformationCache.RestartTimer = TimeSeconds - 3600;
                }
                else if (TimeSeconds >= 1800)
                {
                    InformationCache.RestartTimer = TimeSeconds - 1800;
                }
                else if (TimeSeconds >= 900)
                {
                    InformationCache.RestartTimer = TimeSeconds - 900;
                }
                else if (TimeSeconds >= 600)
                {
                    InformationCache.RestartTimer = TimeSeconds - 600;
                }
                else if (TimeSeconds >= 300)
                {
                    InformationCache.RestartTimer = TimeSeconds - 300;
                }
                else if (TimeSeconds >= 60)
                {
                    InformationCache.RestartTimer = TimeSeconds - 60;
                }
                else
                {
                    InformationCache.RestartTimer = 0;
                }
            }
            else
            {
                InformationCache.RestartTimer = 0;
            }
        }
        /// <summary>
        /// Used to Force Close Launcher when Launcher encounters an error during Startup
        /// </summary>
        /// <param name="Notes">Required: Where the Launcher is Closing From</param>
        /// <param name="Boolen">True: Restarts Launcher | False: Closes Launcher</param>
        public static void ErrorCloseLauncher(string Notes, bool Boolen)
        {
            SplashScreen.ThreadStatus("Stop");

            if (DiscordLauncherPresence.Running())
            {
                DiscordLauncherPresence.Stop("Close");
            }

            if (ServerProxy.Running())
            {
                ServerProxy.Instance.Stop("Force Close");
            }

            Log.Warning("LAUNCHER: Exiting (" + Notes + ")");
            if (!string.IsNullOrWhiteSpace(LauncherForceCloseReason))
            {
                DialogResult OpenLogFile = MessageBox.Show(null, "The GameLauncher has ecountered an Error and it must Close. " +
                                                           "Below is a Summary of the Error:" + "\n" + LauncherForceCloseReason + "\n\n" +
                                                           LogToFileAddons.OpenLogMessage, "GameLauncher",
                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (OpenLogFile == DialogResult.Yes)
                {
                    Process.Start(Locations.LogLauncher);
                }
            }

            if (Boolen)
            {
                Application.Restart();
            }
            else
            {
                Application.Exit();
            }
        }
        public static void EnableChecks()
        {
            Process process       = Process.GetProcessById(process_id);
            IntPtr  processHandle = Kernel32.OpenProcess(0x0010, false, process.Id);
            int     baseAddress   = process.MainModule.BaseAddress.ToInt32();

            Secret = new Thread(() =>
            {
                while (true)
                {
                    foreach (int oneAddress in addresses)
                    {
                        int bytesRead = 0;
                        byte[] buffer = new byte[4];
                        Kernel32.ReadProcessMemory((int)processHandle, baseAddress + oneAddress, buffer, buffer.Length, ref bytesRead);

                        String checkInt = "0x" + BitConverter.ToString(buffer).Replace("-", String.Empty);

                        if (oneAddress == 418534 && checkInt != "0x3B010F84" && detect_MULTIHACK == false)
                        {
                            detect_MULTIHACK = true;
                        }
                        if (oneAddress == 3788216 && checkInt != "0x807DFB00" && detect_FAST_POWERUPS == false)
                        {
                            detect_FAST_POWERUPS = true;
                        }
                        if (oneAddress == 4552702 && checkInt != "0x76390F2E" && detect_SPEEDHACK == false)
                        {
                            detect_SPEEDHACK = true;
                        }
                        if (oneAddress == 4476396 && checkInt != "0x84C00F84" && detect_SMOOTH_WALLS == false)
                        {
                            detect_SMOOTH_WALLS = true;
                        }
                        if (oneAddress == 4506534 && checkInt != "0x74170F57" && detect_TANK_MODE == false)
                        {
                            detect_TANK_MODE = true;
                        }
                        if (oneAddress == 4587060 && checkInt != "0x74228B16" && detect_WALLHACK == false)
                        {
                            detect_WALLHACK = true;
                        }
                        if (oneAddress == 4820249 && checkInt != "0x0F845403" && detect_PURSUITBOT == false)
                        {
                            detect_PURSUITBOT = true;
                        }
                        if (oneAddress == 4573882 && checkInt != "0x85FF0F84" && detect_GHOSTING == false)
                        {
                            detect_GHOSTING = true;
                        }

                        if (oneAddress == 4486168 && checkInt != "0xF30F1086")
                        {
                            if (checkInt.Substring(0, 4) == "0xE8" && detect_MULTIHACK == false)
                            {
                                detect_MULTIHACK = true;
                            }
                            if (checkInt.Substring(0, 4) == "0xE9" && detect_DRIFTMOD == false)
                            {
                                detect_DRIFTMOD = true;
                            }
                        }

                        if (!ServerProxy.Running())
                        {
                            if (
                                detect_MULTIHACK == true || detect_FAST_POWERUPS == true || detect_SPEEDHACK == true ||
                                detect_SMOOTH_WALLS == true || detect_TANK_MODE == true || detect_WALLHACK == true ||
                                detect_DRIFTMOD == true || detect_PURSUITBOT == true || detect_GHOSTING == true)
                            {
                                FunctionStatus.ExternalToolsWasUsed = true;
                            }
                        }
                    }
                    Thread.Sleep(IAmSpeed);
                }
            })
            {
                IsBackground = true
            };
            Secret.Start();
        }
        public static void DisableChecks(bool CompletedEvent)
        {
            cheats_detected = Get_Cheat_Status();

            if (cheats_detected != 0)
            {
                if (cheats_detected == 64 && !CompletedEvent)
                {
                    /* You Know the Rules and So Do I */
                }
                else
                {
                    if (ServerProxy.Running())
                    {
                        foreach (string report_url in URLs.AntiCheatFD)
                        {
                            if (Completed == 0)
                            {
                                Completed++;
                                FunctionStatus.ExternalToolsWasUsed = true;
                            }

                            if (report_url.EndsWith("?"))
                            {
                                try
                                {
                                    Uri sendReport = new Uri(report_url + "serverip=" + serverip + "&user_id=" + user_id + "&persona_name=" + persona_name + "&event_session=" + event_id + "&cheat_type=" + cheats_detected + "&hwid=" + HardwareID.FingerPrint.Value() + "&persona_id=" + persona_id + "&launcher_hash=" + WebHelpers.Value() + "&launcher_certificate=" + CertificateStore.LauncherSerial + "&hwid_fallback=" + HardwareID.FingerPrint.ValueAlt() + "&car_used=" + DiscordGamePresence.PersonaCarName + "&os_platform=" + InformationCache.OSName + "&event_status=" + CompletedEvent);
                                    ServicePointManager.FindServicePoint(sendReport).ConnectionLeaseTimeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;

                                    var Client = new WebClient
                                    {
                                        Encoding = Encoding.UTF8
                                    };

                                    if (!WebCalls.Alternative())
                                    {
                                        Client = new WebClientWithTimeout {
                                            Encoding = Encoding.UTF8
                                        };
                                    }
                                    else
                                    {
                                        Client.Headers.Add("user-agent", "SBRW Launcher " + Application.ProductVersion + " - (" + InsiderInfo.BuildNumberOnly() + ")");
                                    }
                                    Client.DownloadStringCompleted += (Nice, Brock) => { Client.Dispose(); };

                                    try
                                    {
                                        string NTVersion = WindowsProductVersion.GetWindowsBuildNumber() != 0 ? WindowsProductVersion.GetWindowsBuildNumber().ToString() : "Wine";
                                        Client.Headers.Add("os-version", NTVersion);
                                        Client.DownloadStringAsync(sendReport);
                                    }
                                    catch { }
                                }
                                catch { }
                            }
                            else
                            {
                                try
                                {
                                    Uri sendReport = new Uri(report_url);
                                    ServicePointManager.FindServicePoint(sendReport).ConnectionLeaseTimeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;

                                    var request  = (HttpWebRequest)WebRequest.Create(sendReport);
                                    var postData = "serverip=" + serverip + "&user_id=" + user_id + "&persona_name=" + persona_name + "&event_session=" + event_id + "&cheat_type=" + cheats_detected + "&hwid=" + HardwareID.FingerPrint.Value() + "&persona_id=" + persona_id + "&launcher_hash=" + WebHelpers.Value() + "&launcher_certificate=" + CertificateStore.LauncherSerial + "&hwid_fallback=" + HardwareID.FingerPrint.ValueAlt() + "&car_used=" + DiscordGamePresence.PersonaCarName + "&os_platform=" + InformationCache.OSName + "&event_status=" + CompletedEvent;

                                    var data = Encoding.ASCII.GetBytes(postData);
                                    request.Method        = "POST";
                                    request.ContentType   = "application/x-www-form-urlencoded";
                                    request.ContentLength = data.Length;
                                    request.Timeout       = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;

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

                                    var    response       = (HttpWebResponse)request.GetResponse();
                                    String responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                                }
                                catch { }
                            }
                        }
                    }
                    else
                    {
                        if (Completed != URLs.AntiCheatSD.Length)
                        {
                            foreach (string report_url in URLs.AntiCheatSD)
                            {
                                Completed++;
                                if (report_url.EndsWith("?"))
                                {
                                    try
                                    {
                                        Uri sendReport = new Uri(report_url + "serverip=" + serverip + "&user_id=" + user_id + "&cheat_type=" + cheats_detected + "&hwid=" + HardwareID.FingerPrint.Value() + "&launcher_hash=" + WebHelpers.Value() + "&launcher_certificate=" + CertificateStore.LauncherSerial + "&hwid_fallback=" + HardwareID.FingerPrint.ValueAlt() + "&os_platform=" + InformationCache.OSName);
                                        ServicePointManager.FindServicePoint(sendReport).ConnectionLeaseTimeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;

                                        var Client = new WebClient
                                        {
                                            Encoding = Encoding.UTF8
                                        };

                                        if (!WebCalls.Alternative())
                                        {
                                            Client = new WebClientWithTimeout {
                                                Encoding = Encoding.UTF8
                                            };
                                        }
                                        else
                                        {
                                            Client.Headers.Add("user-agent", "SBRW Launcher " + Application.ProductVersion + " - (" + InsiderInfo.BuildNumberOnly() + ")");
                                        }
                                        Client.DownloadStringCompleted += (Nice, Brock) => { Client.Dispose(); };

                                        try
                                        {
                                            string NTVersion = WindowsProductVersion.GetWindowsBuildNumber() != 0 ? WindowsProductVersion.GetWindowsBuildNumber().ToString() : "Wine";
                                            Client.Headers.Add("os-version", NTVersion);
                                            Client.DownloadStringAsync(sendReport);
                                        }
                                        catch { }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }

                    TimeConversions.MUFRTime();
                }
            }

            detect_MULTIHACK = detect_FAST_POWERUPS = detect_SPEEDHACK = detect_SMOOTH_WALLS = detect_TANK_MODE = detect_WALLHACK = detect_DRIFTMOD = detect_PURSUITBOT = false;
            cheats_detected  = 0;
            Secret.Abort();
        }
Ejemplo n.º 5
0
        public static void Latest()
        {
            Log.Checking("LAUNCHER UPDATE: Is Version Up to Date or not");
            DiscordLauncherPresence.Status("Start Up", "Checking Latest Launcher Release Information");
            try
            {
                Uri URLCall = new Uri((EnableInsiderBetaTester.Allowed() || EnableInsiderDeveloper.Allowed()) ?
                                      URLs.GitHub_Launcher_Beta : URLs.GitHub_Launcher_Stable);
                ServicePointManager.FindServicePoint(URLCall).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
                var Client = new WebClient
                {
                    Encoding = Encoding.UTF8
                };

                if (!WebCalls.Alternative())
                {
                    Client = new WebClientWithTimeout {
                        Encoding = Encoding.UTF8
                    };
                }
                else
                {
                    Client.Headers.Add("user-agent", "SBRW Launcher " +
                                       Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
                }

                try
                {
                    VersionJSON = Client.DownloadString(URLCall);
                    VisualsAPIChecker.GitHubAPI = true;
                }
                catch (WebException Error)
                {
                    APIChecker.StatusCodes(URLCall.GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped),
                                           Error, (HttpWebResponse)Error.Response);
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("LAUNCHER UPDATE [GITHUB]", null, Error, null, true);
                }
                finally
                {
                    if (Client != null)
                    {
                        Client.Dispose();
                    }
                }

                if (IsJSONValid.ValidJson(VersionJSON) && VisualsAPIChecker.GitHubAPI)
                {
                    LatestLauncherBuild = (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed()) ?
                                          JsonConvert.DeserializeObject <List <GitHubRelease> >(VersionJSON)[0].TagName :
                                          JsonConvert.DeserializeObject <GitHubRelease>(VersionJSON).TagName;
                    Log.Info("LAUNCHER UPDATE: GitHub Latest Version -> " + LatestLauncherBuild);
                    ValidJSONDownload = true;
                }
                else
                {
                    Log.Error("LAUNCHER UPDATE: Failed to retrieve Latest Build information from GitHub");
                    ValidJSONDownload = false;
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("LAUNCHER UPDATE [GITHUB]", null, Error, null, true);
            }

            Log.Completed("LAUNCHER UPDATE: Done");

            if (!UpdateStatusResult())
            {
                Log.Info("FIRST TIME RUN: Moved to Function");
                /* Do First Time Run Checks */
                FunctionStatus.FirstTimeRun();
            }
            else
            {
                if (DiscordLauncherPresence.Running())
                {
                    DiscordLauncherPresence.Stop("Close");
                }

                if (ServerProxy.Running())
                {
                    ServerProxy.Instance.Stop("Force Close");
                }

                Application.Exit();
            }
        }
        private void DebugScreen_Load(object sender, EventArgs e)
        {
            data.AutoGenerateColumns = true;

            string Antivirus   = String.Empty;
            string Firewall    = String.Empty;
            string AntiSpyware = String.Empty;

            if (!UnixOS.Detected())
            {
                try
                {
                    Antivirus   = (String.IsNullOrWhiteSpace(SecurityCenter("AntiVirusProduct"))) ? "---" : SecurityCenter("AntiVirusProduct");
                    Firewall    = (String.IsNullOrWhiteSpace(SecurityCenter("FirewallProduct"))) ? "Built-In" : SecurityCenter("FirewallProduct");
                    AntiSpyware = (String.IsNullOrWhiteSpace(SecurityCenter("AntiSpywareProduct"))) ? "---" : SecurityCenter("AntiSpywareProduct");
                }
                catch
                {
                    Antivirus   = "Unknown";
                    Firewall    = "Unknown";
                    AntiSpyware = "Unknown";
                }
            }

            string UpdateSkip;

            if (FileSettingsSave.IgnoreVersion == Application.ProductVersion || FileSettingsSave.IgnoreVersion == String.Empty)
            {
                UpdateSkip = "False";
            }
            else
            {
                UpdateSkip = FileSettingsSave.IgnoreVersion;
            }

            string StreamOpt;

            if (FileSettingsSave.StreamingSupport == "0")
            {
                StreamOpt = "Displaying Timer";
            }
            else
            {
                StreamOpt = "Native (Timer Removed)";
            }
            string ThemeOpt;

            if (FileSettingsSave.ThemeSupport == "0")
            {
                ThemeOpt = "Disabled";
            }
            else
            {
                ThemeOpt = "Enabled";
            }

            string InsiderOpt;

            if (FileSettingsSave.Insider == "0")
            {
                InsiderOpt = "Release Only";
            }
            else
            {
                InsiderOpt = "Insider Opt-In";
            }

            /* Used to calculate remaining Free Space on the Game Installed Drive */
            ulong lpFreeBytesAvailable = 0;

            if (!UnixOS.Detected())
            {
                try
                {
                    Kernel32.GetDiskFreeSpaceEx(FileSettingsSave.GameInstallation,
                                                out lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("Debug", null, Error, null, true);
                }
            }

            var settings = new List <ListType>
            {
                new ListType {
                    Name = "Operating System", Value = (UnixOS.Detected())? UnixOS.FullName() : Environment.OSVersion.VersionString
                },
                new ListType {
                    Name = "Environment Version", Value = Environment.OSVersion.Version.ToString()
                },
                new ListType {
                    Name = "Screen Resolution", Value = Screen.PrimaryScreen.Bounds.Width + "x" + Screen.PrimaryScreen.Bounds.Height + " (Primary Display)"
                },
                new ListType {
                    Name = "", Value = ""
                },
                new ListType {
                    Name = "InstallationDirectory", Value = FileSettingsSave.GameInstallation
                },
                new ListType {
                    Name = "Launcher Version", Value = Application.ProductVersion
                },
                new ListType {
                    Name = "Credentials Saved", Value = (!String.IsNullOrWhiteSpace(FileAccountSave.UserHashedPassword)) ? "True" : "False"
                },
                new ListType {
                    Name = "Language", Value = FileSettingsSave.Lang
                },
                new ListType {
                    Name = "Skipping Update", Value = UpdateSkip
                },
                new ListType {
                    Name = "Proxy Enabled", Value = ServerProxy.Running().ToString()
                },
                new ListType {
                    Name = "RPC Enabled", Value = DiscordLauncherPresence.Running().ToString()
                },
                new ListType {
                    Name = "Catpure Support", Value = StreamOpt
                },
                new ListType {
                    Name = "Theme Support", Value = ThemeOpt
                },
                new ListType {
                    Name = "Insider State", Value = InsiderOpt
                },
                new ListType {
                    Name = "", Value = ""
                },
                new ListType {
                    Name = "Server Name", Value = ServerListUpdater.ServerName("Debug")
                },
                new ListType {
                    Name = "Server Address", Value = InformationCache.SelectedServerData.IPAddress
                },
                new ListType {
                    Name = "CDN Address", Value = FileSettingsSave.CDN
                },
                new ListType {
                    Name = "ProxyPort", Value = ServerProxy.ProxyPort.ToString()
                },
                new ListType {
                    Name = "Client Method", Value = FileSettingsSave.WebCallMethod
                },
                new ListType {
                    Name = "", Value = ""
                },
            };

            if (!UnixOS.Detected())
            {
                DriveInfo driveInfo = new DriveInfo(FileSettingsSave.GameInstallation);
                settings.AddRange(new[]
                {
                    new ListType {
                        Name = "Antivirus", Value = Antivirus
                    },
                    new ListType {
                        Name = "Firewall Application", Value = Firewall
                    },
                    new ListType {
                        Name = "Firewall Rule - Launcher", Value = FileSettingsSave.FirewallLauncherStatus
                    },
                    new ListType {
                        Name = "Firewall Rule - Game", Value = FileSettingsSave.FirewallGameStatus
                    },
                    new ListType {
                        Name = "AntiSpyware", Value = AntiSpyware
                    },
                    new ListType {
                        Name = "", Value = ""
                    },
                    new ListType {
                        Name = "CPU", Value = HardwareInfo.CPU.CPUName()
                    },
                    new ListType {
                        Name = "RAM", Value = HardwareInfo.RAM.SysMem() + " MB"
                    },
                    new ListType {
                        Name = "GPU", Value = HardwareInfo.GPU.CardName()
                    },
                    new ListType {
                        Name = "GPU Driver", Value = HardwareInfo.GPU.DriverVersion()
                    },
                    new ListType {
                        Name = "Disk Space Left", Value = FormatFileSize(lpFreeBytesAvailable)
                    },
                    new ListType {
                        Name = "Disk Type", Value = driveInfo.DriveFormat
                    },
                    new ListType {
                        Name = "", Value = ""
                    }
                });
            }
            settings.AddRange(new[]
            {
                new ListType {
                    Name = "HWID", Value = HardwareID.FingerPrint.Level_One_Value()
                },
            });

            data.DataSource = settings;

            DataGridViewCellStyle style = new DataGridViewCellStyle
            {
                Font = new Font(data.Font, FontStyle.Regular)
            };

            data.Columns[0].DefaultCellStyle = style;

            data.Columns[0].Width += 50;

            int size_x = 512;
            int size_y = 640;

            data.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.Size = new Size(size_x, size_y);
        }