anticheat_1
unknown
csharp
2 years ago
4.0 kB
1
Indexable
Never
using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Management; using System.Security.Cryptography; using System.Timers; namespace VerifFichiers { class Program { static void Main(string[] args) { MySqlConnection conn = Passerelle.GetDBConnection("localhost", 3306, "Files", "root", ""); Process currentProcess = Process.GetCurrentProcess(); Process[] localAll = Process.GetProcesses(); int ID = currentProcess.Id; string name = currentProcess.ProcessName; double passes = 0; DateTime time = DateTime.Now; passes++; pass(passes,ID,name,conn, currentProcess); while (true) { TimeSpan elapsed = DateTime.Now - time; double a = Math.Round(elapsed.TotalSeconds); if (a % 5 == 0 && a != 0) { time = DateTime.Now; passes++; pass(passes, ID, name,conn, currentProcess); } } } public static void shutdown(int ID,string Pid,string Pname,MySql.Data.MySqlClient.MySqlConnection c) { Passerelle.InsertUpdateDel(c, "insert into process_to_shutdown(userId) VALUES(" + ID+")"); } public static void pass(double p,int id , string name, MySql.Data.MySqlClient.MySqlConnection c, Process h) { Console.WriteLine("Pass N°" + Convert.ToString(p)); string uuid = ""; ManagementObjectSearcher MOS = new ManagementObjectSearcher("Select * From Win32_BaseBoard"); foreach (ManagementObject getserial in MOS.Get()) { string a = getserial["SerialNumber"].ToString(); List<string[]> ret = Passerelle.Query(c, "select * from users where mbsn = '" + a + "'"); if (ret == null) { Console.WriteLine("Inserted : " + a + ""); Passerelle.InsertUpdateDel(c, "INSERT INTO users(mbsn) VALUES('" + a + "')"); } else { Console.WriteLine("From DB : id = " + ret[0][0] + " MB SN = " + ret[0][1]); } uuid = a; } string[] allfiles = Directory.GetFiles("./Test/", "*.*", SearchOption.AllDirectories); List<string[]> ret1 = Passerelle.Query(c, "select * from Files"); foreach (string a in allfiles) { using (FileStream stream = File.OpenRead(a)) { var sha = new SHA256Managed(); byte[] checksum = sha.ComputeHash(stream); string temp = BitConverter.ToString(checksum).Replace("-", String.Empty); string[] d = { a, temp }; List<string[]> ret2 = Passerelle.Query(c, "select * from Files where FileName = '" + d[0] + "' and sha256='" + d[1] + "'"); if (ret2 == null) { Console.WriteLine("False File : " + a + " | sha256 " + temp); string userid = Passerelle.Query(c, "select id from users where mbsn = '" + uuid + "'")[0][0]; List<string[]> ret3 = Passerelle.Query(c, "select * from process_to_shutdown where userId = '" + userid + "'"); if (ret3 == null) { shutdown(id, name, userid,c); } h.Kill(); } else { Console.WriteLine("From DB : " + ret2[0][0] + " | " + ret2[0][1]); } } } } } }