Пример #1
0
        internal void CheckIfGameIsRunning()
        {
            if (!ProcessManagement.ProcessIsRunning(File.ReadAllText(Core.AppPath + "chosengameexec.txt")))
            {
                ProcessManagement.TriggerTaskmanager(true);
                timer.Enabled = false;
                timer.Stop();

                gamerunningtimer.Enabled = false;
                gamerunningtimer.Stop();

                this.watcher.OnNewProcess -= new NewProcessStartedEvent(watcher_OnNewProcess);

                _fs.Close();

                if (OnStopped != null)
                {
                    OnStopped();
                }
            }
        }
Пример #2
0
        private void MainForm_FormClosing(System.Object sender, System.Windows.Forms.FormClosingEventArgs e)
        {
            try
            {
                if (ProcessManagement.ProcessIsRunning(File.ReadAllText(Core.AppPath + "chosengameexec.txt")))
                {
                    int gameclosedtimestamp = TextHandling.GetUnixTimestamp();

                    GameReport report = new GameReport();

                    report.WriteLine("Anticheat closed while game was running! at " + DateTime.Now.TimeOfDay + " timestamp: " + gameclosedtimestamp + Environment.NewLine + "On match ID: " + getID + Environment.NewLine);

                    File.WriteAllText(Core.AppPath + "acscreens\\gameclosed.txt", report.toFile());

                    try
                    {
                        FileManagement fm = new FileManagement();
                        fm.postFile(username, null, null, Core.AppPath + "acscreens\\gameclosed.txt");
                    }

                    catch (Exception)
                    {
                        ReportForm ef = new ReportForm();
                        ef.label2.Text = "Upload failed.";
                        ef.Show();
                    }

                    File.Delete(Core.AppPath + "acscreens\\gameclosed.txt");

                    string grabName;
                    grabName = File.ReadAllText(Core.AppPath + "chosengameexec.txt");
                    string grabProc;
                    grabProc = grabName;
                    grabProc = grabProc.Substring(0, grabProc.Length - 4);

                    RuntimeChecker.IsGameRunning(grabProc);
                    ProcessManagement.TriggerTaskmanager(true);

                    notifyIcon1.Visible = false;

                    Environment.Exit(0);
                }
            }

            catch (FileNotFoundException)
            {
                /* user does not need to know about this error */
                try
                {
                    string grabName;
                    grabName = File.ReadAllText(Core.AppPath + "chosengameexec.txt");
                    string grabProc;
                    grabProc = grabName;
                    grabProc = grabProc.Substring(0, grabProc.Length - 4);

                    RuntimeChecker.IsGameRunning(grabProc);
                    ProcessManagement.TriggerTaskmanager(true);
                    notifyIcon1.Visible = false;
                    Environment.Exit(0);
                }
                catch (Exception)
                {
                    ProcessManagement.TriggerTaskmanager(true);
                    notifyIcon1.Visible = false;
                    Environment.Exit(0);
                }
            }
            ProcessManagement.TriggerTaskmanager(true);
            notifyIcon1.Visible = false;
            Environment.Exit(0);
        }
Пример #3
0
        private void Execute()
        {
            try
            {
                _fs.Close();

                try
                {
                    FileManagement fm1 = new FileManagement();
                    fm1.createFolder(0, username, null, null);
                    FileManagement fm2 = new FileManagement();
                    fm2.createFolder(1, username, getGame, null);
                    FileManagement fm3 = new FileManagement();
                    fm3.createFolder(2, username, getGame, getMatchID);
                }
                catch (Exception)
                {
                    // we assume that the server is down.
                    Environment.Exit(0);
                }

                FileStream fs = new FileStream(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileMode.Open, FileAccess.ReadWrite, FileShare.None);

                writeProcesses();

                FileManagement fm = new FileManagement();

                fs.Close();

                ZipStorer zip;

                zip = ZipStorer.Open(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileAccess.Write);
                zip.AddFile(ZipStorer.Compression.Store, Core.AppPath + "ac_log_" + getTimeProcesses + "_matchid" + getMatchID + ".txt", "ac_log_" + getTimeProcesses + "_matchid" + getMatchID + ".txt", "Anticheat process log during game for match ID " + getMatchID.ToString() + "and at " + DateTime.Now.ToString());
                zip.Close();

                File.Delete(Core.AppPath + "ac_log_" + getTimeProcesses + "_matchid" + getMatchID + ".txt");

                FileStream fs2 = new FileStream(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileMode.Open, FileAccess.ReadWrite, FileShare.None);

                int getTime2 = TextHandling.GetUnixTimestamp();

                using (ScreenshotDump screen = new ScreenshotDump())
                {
                    try
                    {
                        AeroControl ac = new AeroControl();
                        ac.ControlAero(false);

                        screen.SaveToFile(Core.AppPath + "acscreens\\" + "screen_" + getTime2 + "_matchid" + getMatchID + ".jpeg");

                        fs2.Close();

                        zip = ZipStorer.Open(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileAccess.Write);
                        zip.AddFile(ZipStorer.Compression.Store, Core.AppPath + "acscreens\\" + "screen_" + getTime2 + "_matchid" + getMatchID + ".jpeg", "screen_" + getTime2 + "_matchid" + getMatchID + ".jpeg", "Screenshot during game for match ID " + getMatchID.ToString() + "and at " + DateTime.Now.ToString());
                        zip.Close();

                        File.Delete(Core.AppPath + "acscreens\\" + "screen_" + getTime2 + "_matchid" + getMatchID + ".jpeg");
                    }

                    catch (Exception)
                    {
                        File.WriteAllText(Core.AppPath + "acscreens\\captureerror_" + getTime2 + "_matchid" + getMatchID + ".txt", "Failed to grab screenshot! at " + DateTime.Now.TimeOfDay);

                        fm.postFile(username, getGame, getMatchID, Core.AppPath + "acscreens\\captureerror_" + getTime2 + "_matchid" + getMatchID + ".txt");

                        File.Delete(Core.AppPath + "acscreens\\captureerror_" + getTime2 + "_matchid" + getMatchID + ".txt");

                        ReportForm ef = new ReportForm();
                        ef.label2.Text = "Screenshot capture failed!";
                        ef.Show();
                    }
                }

                FileStream fs3 = new FileStream(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileMode.Open, FileAccess.ReadWrite, FileShare.None);

                using (ScreenshotBitBltDump screenbitblthandle = new ScreenshotBitBltDump())
                {
                    try
                    {
                        string grabProc;

                        grabProc = File.ReadAllText(Core.AppPath + "chosengameexec.txt");
                        grabProc = grabProc.Substring(0, grabProc.Length - 4);

                        Process[] getHandle = Process.GetProcessesByName(grabProc);

                        foreach (Process p in getHandle)
                        {
                            IntPtr windowHandle = p.MainWindowHandle;

                            AeroControl ac = new AeroControl();
                            ac.ControlAero(false);

                            screenbitblthandle.CaptureWindowToFile(windowHandle, Core.AppPath + "acscreens\\" + "screen_bitblt_handle_" + getTime2 + "_matchid" + getMatchID + ".jpeg", ImageFormat.Jpeg);

                            fs3.Close();

                            zip = ZipStorer.Open(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileAccess.Write);
                            zip.AddFile(ZipStorer.Compression.Store, Core.AppPath + "acscreens\\" + "screen_bitblt_handle_" + getTime2 + "_matchid" + getMatchID + ".jpeg", "screen_bitblt_handle_" + getTime2 + "_matchid" + getMatchID + ".jpeg", "Screenshot aggro mode during game for match ID " + getMatchID.ToString() + "and at " + DateTime.Now.ToString());
                            zip.Close();

                            File.Delete(Core.AppPath + "acscreens\\" + "screen_bitblt_handle_" + getTime2 + "_matchid" + getMatchID + ".jpeg");
                        }
                    }
                    catch (Exception)
                    {
                        File.WriteAllText(Core.AppPath + "acscreens\\captureerror_" + getTime2 + "_matchid" + getMatchID + ".txt", "Failed to grab screenshot! at " + DateTime.Now.TimeOfDay);

                        fm.postFile(username, getGame, getMatchID, Core.AppPath + "acscreens\\captureerror_" + getTime2 + "_matchid" + getMatchID + ".txt");

                        File.Delete(Core.AppPath + "acscreens\\captureerror_" + getTime2 + "_matchid" + getMatchID + ".txt");

                        ReportForm ef = new ReportForm();
                        ef.label2.Text = "Screenshot capture failed!";
                        ef.Show();
                    }
                }

                FileStream fs4 = new FileStream(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", FileMode.Open, FileAccess.ReadWrite, FileShare.None);

                if (ProcessManagement.ProcessIsRunning("taskmgr.exe"))
                {
                    int tskmgrtimestamp = TextHandling.GetUnixTimestamp();

                    GameReport taskmgrReport = new GameReport();

                    taskmgrReport.WriteLine("Taskmgr opened while anticheat running for user " + username + " at " + DateTime.Now.TimeOfDay + " timestamp: " + tskmgrtimestamp + " on match: " + getMatchID);

                    File.WriteAllText(Core.AppPath + "acscreens\\taskmgr.txt", taskmgrReport.toFile());

                    fm.postFile(username, getGame, getMatchID, Core.AppPath + "acscreens\\taskmgr.txt");

                    File.Delete(Core.AppPath + "acscreens\\taskmgr.txt");

                    TaskManagerIsRunning();
                }

                fs4.Close();
            }
            catch (Exception ex)
            {
                ReportForm ef = new ReportForm();
                ef.label2.Text = ex.ToString();
                ef.Show();
            }
        }
Пример #4
0
        private void startRoutine(DialogResult getdr)
        {
            if (label4.Text.Equals("Scanning"))
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "Routine is already running!";
                ef.Show();
                return;
            }

            if (label4.Text.Equals("Uploading"))
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "Please wait until uploading ends!";
                ef.Show();
                return;
            }

            else
            {
                try
                {
                    getID = int.Parse(TextBox1.Text);

                    if (getID == 0)
                    {
                        ErrorForm ef = new ErrorForm();
                        ef.label2.Text = "Match ID cannot be 0.";
                        ef.Show();
                        return;
                    }

                    File.WriteAllText(Core.AppPath + "matchid.txt", TextBox1.Text);
                }
                catch (Exception)
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "Invalid Match ID.";
                    ef.Show();
                    return;
                }

                DialogResult dr = getdr;

                if (dr == DialogResult.Cancel)
                {
                    //we continue
                }

                else if (dr == DialogResult.OK)
                {
                    noGameSelectedToolStripMenuItem.Text = "Scanning game: " + selectedGame;

                    label4.Text = "Scanning";

                    this.Hide();
                    this.WindowState = FormWindowState.Minimized;

                    string grabName;
                    grabName = File.ReadAllText(Core.AppPath + "chosengameexec.txt");

                    if (grabName.Equals("steam://run/730"))
                    {
                        grabName = "csgo.exe";
                    }

                    else if (grabName.Equals("steam://run/440"))
                    {
                        grabName = "hl2.exe";
                    }

                    else if (grabName.Equals("steam://run/570"))
                    {
                        grabName = "dota.exe";
                    }

                    else if (grabName.Equals("Shootmania"))
                    {
                        string read = string.Empty;

                        try
                        {
                            read = File.ReadAllText(Core.AppPath + "chosengamefullexec.txt");
                        }
                        catch (Exception) { }

                        if (!read.Contains("ManiaPlanet"))
                        {
                            OpenFileDialog ofd = new OpenFileDialog();
                            ofd.Filter = "maniaplanet.exe|maniaplanet.exe| Exe Files (.exe)|*.exe";
                            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                string fullPath = ofd.InitialDirectory + ofd.FileName;
                                string execName = ofd.SafeFileName;
                                File.WriteAllText(Core.AppPath + "chosengamefullexec.txt", fullPath);
                                File.WriteAllText(Core.AppPath + "chosengameexec.txt", execName);
                            }
                            else
                            {
                                label4.Text = "Idle";

                                this.Show();
                                this.WindowState = FormWindowState.Normal;
                                this.Activate();

                                return;
                            }
                        }

                        File.WriteAllText(Core.AppPath + "chosengameexec.txt", "ManiaPlanet.exe");
                    }

                    if (ProcessManagement.ProcessIsRunning(grabName))
                    {
                        grabName = grabName.Substring(0, grabName.Length - 4);
                        RuntimeChecker.IsGameRunning(grabName); //kills old process and opens new one with anticheat
                        ProcessManagement.TriggerTaskmanager(true);
                        Thread.Sleep(1000);
                    }

                    bool primaryFail = false;

                    try
                    {
                        RuntimeChecker checker = new RuntimeChecker(ServerType.PrimaryServer, username);
                        checker.OnStopped += new CheckerStoppedEvent(checker_OnStopped);
                    }
                    catch (Exception)
                    {
                        primaryFail = true;
                    }

                    if (primaryFail == true)
                    {
                        this.Show();
                        this.WindowState = FormWindowState.Normal;

                        ReportForm ef = new ReportForm();
                        ef.label2.Text = "A error has occurred!";
                        ef.Show();

                        checker_OnStopped();

                        ProcessManagement.TriggerTaskmanager(false);
                        ProcessManagement.TaskManagerIsRunning();

                        button5.Image = ESA_AC.Properties.Resources.startscan_normal;

                        label4.Text = "Uploading";

                        try
                        {
                            if (File.Exists(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip"))
                            {
                                using (FileStream fsread = new FileStream(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip", FileMode.Open, FileAccess.Read, FileShare.Read))
                                {
                                    if (File.Exists(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip"))
                                    {
                                        FileManagement fm = new FileManagement();
                                        fm.postFile(username, selectedGame, getID.ToString(), Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip");

                                        fsread.Close();

                                        File.Delete(Core.AppPath + "acscreens\\log_" + getID + "_" + selectedGame + "_" + RuntimeChecker.getTimeZip + ".zip");
                                    }
                                    else
                                    {
                                        File.WriteAllText(Core.AppPath + "acscreens\\warning.txt", "Anticheat zip log has been deleted.");

                                        FileManagement fm = new FileManagement();
                                        fm.postFile(username, selectedGame, getID.ToString(), Core.AppPath + "acscreens\\warning.txt");

                                        File.Delete(Core.AppPath + "acscreens\\warning.txt");
                                    }
                                }
                            }
                            else
                            {
                                File.WriteAllText(Core.AppPath + "acscreens\\warning.txt", "Anticheat zip log has been deleted.");

                                FileManagement fm = new FileManagement();
                                fm.postFile(username, selectedGame, getID.ToString(), Core.AppPath + "acscreens\\warning.txt");

                                File.Delete(Core.AppPath + "acscreens\\warning.txt");
                            }
                        }
                        catch (Exception)
                        {
                            ReportForm ef2 = new ReportForm();
                            ef2.label2.Text = "Upload failed.";
                            ef2.Show();
                        }

                        ProcessManagement.TriggerTaskmanager(true);

                        noGameSelectedToolStripMenuItem.Text = "No game currently selected";

                        selectedGame = "";

                        label4.Text = "Idle";
                    }
                }
            }
        }