Ejemplo n.º 1
0
        internal void writeProcesses()
        {
            string osname  = GetOSFriendlyName();
            string macaddr = GetMacAddress();

            Process[] processlist = System.Diagnostics.Process.GetProcesses();

            GameReport report = new GameReport();

            report.WriteLine("Anti Cheat Version " + Core.AC_Ver + Environment.NewLine);
            report.WriteLine("Anti Cheat Report: " + DateTime.Now.ToString().Remove(11) + "  " + DateTime.Now.TimeOfDay + Environment.NewLine);
            report.WriteLine("From user: "******" - playing: " + getGame + Environment.NewLine);
            report.WriteLine("User HWID: " + Core.ComputerHWID + " - Computer Name: " + System.Environment.MachineName + " - Windows Version: " + osname + " - MAC Address: " + macaddr + Environment.NewLine);
            report.WriteLine("Match ID: " + getMatchID + Environment.NewLine);

            foreach (Process process in processlist)
            {
                try
                {
                    report.WriteLine(process.ProcessName + " " + process.MainWindowTitle + " " + GetFilePath(process.Id) + Environment.NewLine);
                }
                catch (Exception) { /* the user does not need to know about this error. */ }
            }

            getTimeProcesses = TextHandling.GetUnixTimestamp();

            File.WriteAllText(Core.AppPath + "ac_log_" + getTimeProcesses + "_matchid" + getMatchID + ".txt", report.toFile());
        }
Ejemplo n.º 2
0
        public RuntimeChecker(ServerType type, string username)
        {
            this.type     = type;
            this.username = username;

            try
            {
                FileManagement fm2 = new FileManagement();
                fm2.createFolder(1, username, getGame, null);
                FileManagement fm3 = new FileManagement();
                fm3.createFolder(2, username, getGame, getMatchID);

                getTimeZip = TextHandling.GetUnixTimestamp();
            }
            catch (Exception)
            {
                // we assume that the server is down.
                Environment.Exit(0);
            }

            if (!Directory.Exists(Core.AppPath + "acscreens"))
            {
                Directory.CreateDirectory(Core.AppPath + "acscreens");
            }

            ZipStorer zip;

            zip = ZipStorer.Create(Core.AppPath + "acscreens\\log_" + getMatchID + "_" + getGame + "_" + getTimeZip + ".zip", "ESA AntiCheat log for match " + getMatchID.ToString());
            zip.Close();

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

            TaskManagerIsRunning();

            ProcessManagement.TriggerTaskmanager(false);

            writePreGameProcesses();

            FileManagement fm4 = new FileManagement();

            fm4.postFile(username, getGame, getMatchID, Core.AppPath + "ac_logbeforegame_" + getTimepre + "_matchid" + getMatchID + ".txt");

            File.Delete(Core.AppPath + "ac_logbeforegame_" + getTimepre + "_matchid" + getMatchID + ".txt");

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

                    screenpre.SaveToFile(Core.AppPath + "acscreens\\" + "screen_beforegame_" + getTimepre + "_matchid" + getMatchID + ".jpeg");

                    fm4.postFile(username, getGame, getMatchID, Core.AppPath + "acscreens\\" + "screen_beforegame_" + getTimepre + "_matchid" + getMatchID + ".jpeg");

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

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

                    FileManagement fm = new FileManagement();

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

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

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

            //---timer---
            this.timer = new Timer()
            {
                AutoReset = true,
                Interval  = 60000,
                Enabled   = true
            };

            timer.Elapsed += tick;
            timer.Start();

            this.watcher = new ProcessWatchDog(1000);
            this.watcher.OnNewProcess += new NewProcessStartedEvent(watcher_OnNewProcess);

            this.gamerunningtimer = new Timer()
            {
                AutoReset = true,
                Interval  = 5000,
                Enabled   = true
            };

            gamerunningtimer.Elapsed += gametick;
            gamerunningtimer.Start();

            LaunchGame();
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 4
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);
        }