public void StartWorker(dynamic order, int TimeOut, int numHttpDelay, int nbrThread, Hashtable urlQueue) { /* if (__RunningWorker) * { * return; * }*/ __Analizer.Order = order; Globals.UpDateStatus(__Analizer.Order, "Scanner URLS", "Scanner thread, loading please wait.."); checked { if (urlQueue.Keys.Count == 0) { global::Globals.UpDateStatus(__Analizer.Order, "Scanner URLS", "Exploiter thread, URL's queue is empty."); Interaction.Beep(); return; } stScanner stScanner = default(stScanner); stScanner.Order = order; stScanner.TimeOut = Convert.ToInt32(TimeOut); stScanner.Delay = Convert.ToInt32(numHttpDelay); stScanner.Urls = urlQueue; stScanner.Method = enHTTPMethod.GET; stScanner.Threads = Convert.ToByte(nbrThread); stScanner.TrashMsAccess = true; stScanner.TrashUnknown = true; //commence this.bckWorkerSQL.RunWorkerAsync(stScanner); goto IL_FD3; } Interaction.Beep(); return; IL_FD3: Console.WriteLine("Goto IL_FD3 Lauched"); }
private void bckWorkerSQL_DoWork(object sender, DoWorkEventArgs e) { int threads = 0; stScanner argument = (stScanner)e.Argument; /* try * {*/ __RunningWorker = true; if (argument.Urls.Count > argument.Threads) { threads = argument.Threads; } else { threads = argument.Urls.Count; } this.__ThreadPoolScanner = new ThreadPool(threads); using (HTTP http = new HTTP(argument.TimeOut, false)) { IDictionaryEnumerator enumerator = argument.Urls.GetEnumerator(); int num2 = 0; while (enumerator.MoveNext()) { DictionaryEntry current = (DictionaryEntry)enumerator.Current; dynamic currData = current.Value; string sUrlEntered = Conversions.ToString(currData["url"]); if (this.bckWorkerSQL.CancellationPending || (this.__ThreadPoolScanner.Status == ThreadPool.ThreadStatus.Stopped)) { return; } /*if (__Loading.Paused) * { * this.__ThreadPoolScanner.Paused = true; * while (__Loading.Paused) * { * Thread.Sleep(500); * } * this.__ThreadPoolScanner.Paused = false; * }*/ int percentProgress = (int)Math.Round(Math.Round((double)(((double)(100 * (num2 + 1))) / ((double)argument.Urls.Count)))); if (threads > 1) { Globals.UpDateStatus(__Analizer.Order, "Exploiter thread", "[" + Strings.FormatNumber(num2 + 1, 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + "/" + Strings.FormatNumber(argument.Urls.Count, 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + "] Exploiter thread, exploitable detected: " + Conversions.ToString(this.__SearchSummary.Added)); } else { Globals.UpDateStatus(__Analizer.Order, "Exploiter thread", "[" + Strings.FormatNumber(num2 + 1, 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + "/" + Strings.FormatNumber(argument.Urls.Count, 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + "] Exploiter thread, exploitable detected: " + Conversions.ToString(this.__SearchSummary.Added) + ", exploiting: " + Globals.G_Utilities.GetDomain(sUrlEntered)); } this.bckWorkerSQL.ReportProgress(percentProgress, ""); Label_024C: /* try * {*/ Thread thread = new Thread(new ParameterizedThreadStart(_Lambda__11)) { IsBackground = true, Name = "Pos : " + num2.ToString() }; ThreadScanner parameter = new ThreadScanner(num2) { Thread = thread, HTTP = http, OriginalUrl = Conversions.ToString(currData["url"]), URL = sUrlEntered, TrashMsAccess = argument.TrashMsAccess, TrashUnknown = argument.TrashUnknown, Delay = argument.Delay }; thread.Start(parameter); this.__ThreadPoolScanner.Open(thread); /* } * catch (Exception exception1) * { * // ProjectData.SetProjectError(exception1); * Thread.Sleep(0x3e8); * this.__ThreadPoolScanner.WaitForThreads(); * ProjectData.ClearProjectError(); * goto Label_024C; * // }*/ this.__ThreadPoolScanner.WaitForThreads(); num2++; Thread.Sleep(200); //Application.DoEvents(); } } /*} * finally * {*/ this.__ThreadPoolScanner.AllJobsPushed(); goto Label_045E; Label_036F: if (this.__ThreadPoolScanner.Finished) { goto Label_0481; } if (threads == 1) { //Dernier Thread restant Donc on envoie les resultats Globals.GUI.sendExploitables(__Analizer.Order, __EXPLOITABLES__); Globals.UpDateStatus(__Analizer.Order, "Exploiter thread", "[" + Conversions.ToString(argument.Urls.Count) + "/" + Conversions.ToString(argument.Urls.Count) + "] Exploiter thread, finishing thread.."); } else { Globals.GUI.sendExploitables(__Analizer.Order, __EXPLOITABLES__); Globals.UpDateStatus(__Analizer.Order, "Exploiter thread", "[" + Conversions.ToString(argument.Urls.Count) + "/" + Conversions.ToString(argument.Urls.Count) + "] Exploiter thread, finishing thread(s) [" + Conversions.ToString(this.__ThreadPoolScanner.ThreadCount) + "]"); } Thread.Sleep(200); Label_045E: this.bckWorkerSQL.ReportProgress(100, this.GetExploiterSummary()); if (!this.bckWorkerSQL.CancellationPending) { goto Label_036F; } Label_0481 :; //} }