Exemple #1
0
        public static int[] TakeCurrent()
        {
            int[] pids = { };
            try
            {
                pids = ProcessValidation.ListAllProcessIds();
            }
            catch (Exception ex)
            {
                SimpleLog.Log(ex);
            }

            return(pids);
        }
Exemple #2
0
        public static void BGProc()
        {
            Debug.WriteLine("Entering BGProc");                      // Debug Message
            SimpleLog.Info("Entered 'Background thread (BGProc)'."); // Writes 'info' level message to log

            // Takes the baseline array of all process IDS running.
            int[] baseline = ProcessValidation.ListAllProcessIds();


            try
            {
                // Continuous loop till broken on "Main" form exit.
                while (true)
                {
                    // Thread waits for 2 seconds.
                    Thread.Sleep(2000);

                    // If the background "watchdog" status is true.
                    while (Program.Globals.status)
                    {
                        // Takes the current array of all process IDS running.
                        int[] current = ProcessValidation.ListAllProcessIds();

                        Program.Globals.uniqueIds = Background.Compareprocesses(baseline, current); // Finds IDs of processes that started after anticheat.

                        /*
                         *  Defines "differentProcessesID" as a list of "UniqueProc" objects by passing "Globals.uniqueIds" into the "PIDlookup()" method
                         *  in the Background class
                         */
                        List <UniqueProc> differentProcessesID = Background.PIDlookup(Program.Globals.uniqueIds);

                        if (differentProcessesID.Count() > 0)
                        {
                            foreach (var p in differentProcessesID) // Logs all unique process to the backend database.
                            {
                                int returnValue;

                                // Defines the Database log thread and specifies what object information is supplied to the "dblog" thread's method.
                                Thread dblog = new Thread(() => { returnValue = Background.LogtoDB(p.Name, p.ProcessId, p.Handle); });

                                dblog.IsBackground = true;
                                dblog.Start(); // Logs the unique process to the Database.
                            }
                        }

                        var txtFile = Globals.blackList;
                        if (txtFile != "" && File.Exists(txtFile))
                        {
                            string[] Globalsproclines = File.ReadAllLines(txtFile);
                        }


                        if (Globals.procLines.Length > 0)
                        {
                            foreach (string line in Globals.procLines)
                            {
                                if (Checkproc(line))
                                {
                                    // Checks if Stealthmode is enabled and if it is then it wont alert the user.
                                    if (Program.Globals.stealthMode == false)
                                    {
                                        // Alerts the user that a blacklisted process was found.
                                        MessageBox.Show("Blacklisted Process: \"" + line + "\" was found.");
                                    }

                                    // If the autokill option is enabled and the status is active then the found process is killed.
                                    if (Program.Globals.autoKill && Program.Globals.status == true)
                                    {
                                        // Supplies "ProcKill" with the name of the process to kill which is stored in the "line" variable.
                                        string ProcName = ProcessValidation.ProcKill(line);

                                        if (Program.Globals.stealthMode == false)
                                        {
                                            // Alerts the user that a blacklisted process was found and killed.
                                            MessageBox.Show("Blacklisted Process: \"" + line + "\" " + "\"" + ProcName + "\"" + "  was killed.");
                                        }
                                    }
                                }

                                if (Checkapp(line))
                                {
                                    if (Program.Globals.stealthMode == false)
                                    {
                                        MessageBox.Show("Application \"" + line + "\" was found.");
                                    }

                                    if (Program.Globals.autoKill && Program.Globals.status == true)
                                    {
                                        string ProcName = ProcessValidation.ProcKill(line);
                                        if (Program.Globals.stealthMode == false)
                                        {
                                            MessageBox.Show("Process \"" + line + "\" " + "\"" + ProcName + "\"" + "  was killed.");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // Checks if the main form has been closed and then if so breaks the loop and preforms "Application.Exit();" which exits the application.
                    int formcount = Int32.Parse(Application.OpenForms.Count.ToString());
                    if (formcount == 0)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                SimpleLog.Log(ex);
            }
            Application.Exit();
        }