public static BackdoorData toData(string AddonID, string URL) { BackdoorData Data = new BackdoorData(); Data.ID = AddonID; Data.URL = URL; return(Data); }
public static void whitelistAddon(BackdoorData Data) { if (!(File.Exists(jsonFile_2))) { JObject Object = new JObject(); Object.Add(Data.ID, JsonConvert.SerializeObject(Data)); string JsonDataStr = JsonConvert.SerializeObject(Object, Formatting.Indented); File.Create(jsonFile_2).Dispose(); File.WriteAllText(jsonFile_2, JsonDataStr); } else { string json = File.ReadAllText(jsonFile_2); var jsonData = JObject.Parse(json); jsonData.Add(Data.ID, JsonConvert.SerializeObject(Data)); string newJsonData = JsonConvert.SerializeObject(jsonData, Formatting.Indented); File.WriteAllText(jsonFile_2, newJsonData); } }
public static void addData(BackdoorData data) { if (!(File.Exists(jsonFile_1))) { JObject Object = new JObject(); Object.Add(data.ID, JsonConvert.SerializeObject(data)); string newJson = JsonConvert.SerializeObject(Object, Formatting.Indented); File.Create(jsonFile_1).Dispose(); File.WriteAllText(jsonFile_1, newJson); } else { string json = File.ReadAllText(jsonFile_1); var Data = JObject.Parse(json); Data.Add(data.ID, JsonConvert.SerializeObject(data)); string newJsonResult = JsonConvert.SerializeObject(Data, Formatting.Indented); File.WriteAllText(jsonFile_1, newJsonResult); } }
static async Task ScanWorkshop() { uint pageNumber = 0; while (true) { pageNumber++; Console.Write("Page Number = " + pageNumber.ToString() + "\n"); WorkshopAddon[] Addons = await WorkshopHTTPAPI.GetWorkshopAddonsAsync(steamApiKey, EPublishedFileQueryType.RankedByPublicationDate, pageNumber, 100); Console.Write("# Addons: {0}\n", Addons.Length.ToString()); if (Addons.Length < 1) { Console.Write("Reached end of workshop."); if (Console.ReadLine() == "ok") { Environment.Exit(1); } } foreach (WorkshopAddon Addon in Addons) { if (DataLog.hasBeenLogged(Addon.ID.ToString()) || DataLog.hasBeenWhitelisted(Addon.ID.ToString())) { continue; } Console.Write("Downloading Addon: {0}\n", Addon.URL); GMADAddon parsedAddon; try { using (var wc = new WebClient()) { Byte[] data = await wc.DownloadDataTaskAsync(Addon.URL); parsedAddon = GMADParser.Parse(data); data = new Byte[0]; } Backdoor backdoorFinder = new Backdoor(parsedAddon); List <List <Backdoor.FlagStruct> > flagList = backdoorFinder.scanFile(); foreach (var flagFile in flagList) { foreach (Backdoor.FlagStruct fileStruct in flagFile) { int lineNumber = fileStruct.lineNumber; String FlagStr = fileStruct.FlagStr; GMADAddon.File AddonFile = fileStruct.AddonFile; GMADAddon._Author Author = parsedAddon.Author; String FlagDescription = fileStruct.FlagDescription; Regex CheckRegex = fileStruct.CheckRegex; int CheckType = fileStruct.CheckType; int Priority = fileStruct.Priority; string AddonUrl = "https://steamcommunity.com/sharedfiles/filedetails/?id=" + Addon.ID.ToString(); Webhook discordWebhook = new Webhook(webhookURL); Embed discordEmbed = new Embed(); List <Embed> embedList = new List <Embed>(); Dictionary <string, string> fieldDict = new Dictionary <string, string>() { { "line number", lineNumber.ToString() }, { "Addon name", parsedAddon.Name }, { "Current File", AddonFile.Path }, { "Priority", Priority.ToString() }, { "Flag", FlagDescription }, { "Code", FlagStr.Length < 1024 ? FlagStr : "Code too long" }, { "Author Name", Author.Name }, { "Author SteamID", Author.SteamID64.ToString() }, { "Addon URL", AddonUrl } }; discordEmbed.Title = "FLAG FOUND"; discordEmbed.Fields = Backdoor.makeEmbedList(fieldDict); discordEmbed.Color = Extensions.ToRgb(Color.FromName("purple")); embedList.Add(discordEmbed); await discordWebhook.Send(null, null, null, false, embedList); } } if (flagList.Count < 1) { Console.Write("No flags found.\n"); } BackdoorData toLog = DataLog.toData(Addon.ID.ToString(), Addon.URL); DataLog.addData(toLog); flagList = null; backdoorFinder = null; GC.Collect(); } catch (Exception ex) { Console.Write("Something went wrong...\n"); Console.Write(ex.Message + "\n"); } } } }
static void whiteListAddon(WorkshopAddon Addon) { BackdoorData Data = DataLog.toData(Addon.ID.ToString(), Addon.URL); DataLog.whitelistAddon(Data); }