private void _btnLoadText_Click(object sender, EventArgs e) { List <string> domains = File.ReadAllLines(@"C:\Alternative\Source\list.txt").ToList(); DomainController domainController = new DomainController(); foreach (string domaintxt in domains) { Clark.Domain.Data.Domain domain = domainController.FindByDomain(domaintxt); if (domain == null) { domain = new Domain(); domain.Platform = ""; domain.BountyURL = ""; domain.BountyEndDate = new DateTime(2999, 12, 31); domain.Private = false; domain.DomainName = domaintxt; domainController.Insert(domain); } } }
private void _btnProgramLoad_Click(object sender, EventArgs e) { List <HackingTarget> items = JsonLoader.Load(@"C:\Alternative\Source\doc.json"); DomainController domainController = new DomainController(); DomainIgnoreController ignoreController = new DomainIgnoreController(); foreach (HackingTarget item in items) { foreach (Target target in item.Targets.in_scope) { string platform = ""; if (item.URL.Contains("hackerone")) { if (!target.asset_type.Equals("URL")) { continue; } platform = "hackerone"; } if (item.URL.Contains("bugcrowd")) { //if (!target.type.Equals("website")) if (!target.target.Contains("http")) { continue; } platform = "bugcrowd"; } string domaintext = target.asset_identifier; if (String.IsNullOrEmpty(domaintext)) { domaintext = target.target; } domaintext = domaintext.Replace("*.", "").Replace("https://", "").Replace("http://", "").Replace("(", "").Replace(")", "").Split('?')[0].Split('/')[0]; string regex = "(\\[.*\\])|(\".*\")|('.*')|(\\(.*\\))|(<.*>)"; domaintext = Regex.Replace(domaintext, regex, ""); string[] parts = domaintext.Split('.'); if (parts.Length >= 2) { int count = parts.Length - 1; domaintext = parts[count - 1] + "." + parts[count]; } Clark.Domain.Data.Domain domain = domainController.FindByDomain(domaintext); if (domain == null) { domain = new Domain(); domain.Platform = platform; domain.BountyURL = item.URL; domain.BountyEndDate = new DateTime(2999, 12, 31); domain.Private = false; domain.DomainName = domaintext; UpdateResult res = domainController.Insert(domain); if (res.Error) { MessageBox.Show(target.asset_identifier + " error"); } } } foreach (Target target in item.Targets.out_of_scope) { if (!target.asset_type.Equals("URL")) { continue; } DomainIgnore ignore = ignoreController.FindByIgnoreDomain(target.asset_identifier.Replace("*.", "")); if (ignore == null) { ignore = new DomainIgnore(); string domain2Ignore = target.asset_identifier; domain2Ignore = domain2Ignore.Replace("*.", "").Replace("https://", "").Replace("http://", "").Replace("(", "").Replace(")", "").Split('?')[0].Split('/')[0]; string regex = "(\\[.*\\])|(\".*\")|('.*')|(\\(.*\\))|(<.*>)"; domain2Ignore = Regex.Replace(domain2Ignore, regex, ""); ignore.DomainToIgnore = domain2Ignore; UpdateResult res = ignoreController.Insert(ignore); if (res.Error) { MessageBox.Show(target.asset_identifier + " error"); } } } } }