public NarrativeObject(PhantomTorDriver cralwer, ScanObject scanObject) { Created = DateTime.Now; MessageCollection = new List<Message>(); Guid = Guid.NewGuid(); Crawler = cralwer; ScanObject = scanObject; BeginNarrative(); }
private async static Task<bool> StartNewAsyncScan(string port) { await Task.Run((Action)(() => { PhantomTorDriver crawler = new PhantomTorDriver(port); ScanObject potential = new ScanObject().GetNext(); NarrativeObject narrative = new NarrativeObject(crawler, potential); crawler.Driver.Quit(); narrative.FindPotentialScans(); })); return true; }
public void FindPotentialScans() { if (this.ScanObject.PageStatus != "ERROR") { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(this.ScanObject.PageSource); var _test = doc.DocumentNode.SelectNodes("//a"); if(_test != null) { var links = doc.DocumentNode.SelectNodes("//a").Select(x => x.OuterHtml).ToList(); for (int i = 0; i < links.Count; i++) { string[] parts = links[i].Split(new string[] { "href=" }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in parts) { if (s.Contains(@"http://") && s.Contains(".onion")) { string url = string.Empty; string name = string.Empty; string[] initial = s.Split(new string[] { ">" }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < initial[0].Count(); j++) { if (initial[0][j] != '"') url += initial[0][j]; } url = RemoveKnownHindrences(url); string[] nameSplit = initial[1].Split(new string[] { "<" }, StringSplitOptions.RemoveEmptyEntries); name = nameSplit[0]; Console.WriteLine(String.Format("Name: {0}, Url: {1}", name, url)); ScanObject o = new ScanObject(name, url, ScanObject.Id, ScanObject.CrawlDepth + 1 ); o.Insert(); NewMessage(String.Format("ScanObject: {0} inserted at {1}", o.Name, DateTime.Now.ToShortTimeString()), false); } } } } } }