private void bckWorkerGetLinks_DoWork(object sender, DoWorkEventArgs e) { try { __RunningWorker = true; using (HTTP hTTP = new HTTP(__ScannerConf_.TimeOut, false)) { HTTP arg_4A_0 = hTTP; string arg_4A_1 = __ScannerConf_.Url; enHTTPMethod arg_4A_2 = __ScannerConf_.Method; string text = ""; object arg_4A_4 = null; NetworkCredential arg_4A_5 = null; bool arg_4A_6 = false; string text2 = ""; string hTML = arg_4A_0.GetHTML(arg_4A_1, arg_4A_2, ref text, arg_4A_4, arg_4A_5, arg_4A_6, ref text2); if (!string.IsNullOrEmpty(hTML)) { new List <ListViewItem>(); using (RegExp regExp = new RegExp()) { try { IEnumerator enumerator = regExp.GetLinks(__ScannerConf_.Url, hTML, __ScannerConf_.RegExp).Values.GetEnumerator(); while (enumerator.MoveNext()) { Link link = (Link)enumerator.Current; if (string.IsNullOrEmpty(__ScannerConf_.Domain) || !Globals.G_Utilities.IsUrlValid(link.Url) || Strings.InStr(link.Url, __ScannerConf_.Domain, CompareMethod.Binary) != 0) { AddURL(link.Url, new string[0]); } } } finally { IEnumerator enumerator = null; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } } } } } catch (Exception expr_11F) { ProjectData.SetProjectError(expr_11F); Exception ex = expr_11F; MessageBox.Show(ex.Message, "Please report this bug!", MessageBoxButtons.OK, MessageBoxIcon.Hand); ProjectData.ClearProjectError(); } finally { } }
public bool TestOK(WebProxy oProxy, ref string sServer, ref string sCode) { string value = ""; string text = ""; try { if (oProxy != null) { this.__Enable = true; using (HTTP hTTP = new HTTP(5000, false)) { HTTP arg_3A_0 = hTTP; string arg_3A_1 = "http://www.google.com/"; enHTTPMethod arg_3A_2 = enHTTPMethod.GET; string text2 = ""; value = arg_3A_0.GetHTML(arg_3A_1, arg_3A_2, ref text2, null, null, false, ref text); if (hTTP.WebResponse != null && hTTP.WebResponse.HTTPResponse != null) { sServer = hTTP.WebResponse.HTTPResponse.Server; sCode = Conversions.ToString((int)hTTP.WebResponse.HTTPResponse.StatusCode) + " - " + hTTP.WebResponse.HTTPResponse.StatusDescription; } } this.__Enable = false; if (!string.IsNullOrEmpty(text)) { MessageBox.Show(text, "Proxy Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (WebException expr_C4) { ProjectData.SetProjectError(expr_C4); WebException ex = expr_C4; throw ex; } return(!string.IsNullOrEmpty(value)); }
public string GetHTML(string sUrl, enHTTPMethod oMethod, ref string sPostData, object oCokies, NetworkCredential oCredentials, bool bIsDebugable, ref string sErrDesc, bool randUserAgent = true) { string source = ""; string sProxy = "N/A"; bool flag = true; string sID = ""; checked { string sStatus; long value = 0; try { if (flag) { TimeSpan ts = new TimeSpan(DateAndTime.Now.Ticks); } Uri requestUri = new Uri(sUrl); string cookieText = ""; HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(requestUri); httpWebRequest.AllowAutoRedirect = Globals.HTTP_ALLOW_AUTO_REDIRECT; httpWebRequest.Credentials = oCredentials; Proxy g_Proxy = global::Globals.G_Proxy; lock (g_Proxy) { if (global::Globals.G_Proxy.Enable & !this.__DesableProxy) { httpWebRequest.Proxy = global::Globals.G_Proxy.Proxy_; sProxy = Globals.G_Proxy.Proxy_.Address.Host + ":" + Globals.G_Proxy.Proxy_.Address.Port; } } if (randUserAgent) { httpWebRequest.UserAgent = Globals.G_Utilities.getUseragent(); } else { httpWebRequest.UserAgent = Globals.USER_AGENT; } httpWebRequest.Timeout = this.__TimeOut; httpWebRequest.ReadWriteTimeout = this.__TimeOut; httpWebRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; httpWebRequest.AutomaticDecompression = (DecompressionMethods)(-1); httpWebRequest.KeepAlive = true; httpWebRequest.Referer = sUrl; httpWebRequest.CookieContainer = new CookieContainer(); if (oCokies is string) { cookieText = Conversions.ToString(oCokies); } else if (oCokies is CookieCollection && oCokies != null) { object arg_1A8_0 = httpWebRequest.CookieContainer; Type arg_1A8_1 = null; string arg_1A8_2 = "Add"; object[] array = new object[] { RuntimeHelpers.GetObjectValue(oCokies) }; object[] arg_1A8_3 = array; string[] arg_1A8_4 = null; Type[] arg_1A8_5 = null; bool[] array2 = new bool[] { true }; NewLateBinding.LateCall(arg_1A8_0, arg_1A8_1, arg_1A8_2, arg_1A8_3, arg_1A8_4, arg_1A8_5, array2, true); if (array2[0]) { oCokies = RuntimeHelpers.GetObjectValue(array[0]); } } if (!string.IsNullOrEmpty(cookieText)) { string[] array3 = cookieText.Split(new char[] { ';' }); string[] array4 = array3; for (int i = 0; i < array4.Length; i++) { string text3 = array4[i]; try { string[] array5 = text3.Split(new char[] { '=' }); array5[0] = array5[0].Trim(); array5[1] = array5[1].Trim(); if (array5.Length > 2) { int arg_240_0 = 2; int num = array5.Length - 1; for (int j = arg_240_0; j <= num; j++) { string[] array6 = array5; array6[1] = array6[1] + "=" + array5[j]; } } if (array5.Length >= 2 && (array5[0].Trim().Length > 0 & array5[1].Trim().Length > 0)) { httpWebRequest.CookieContainer.Add(new Uri(sUrl), new Cookie(array5[0], array5[1])); } } catch (Exception expr_2B8) { ProjectData.SetProjectError(expr_2B8); ProjectData.ClearProjectError(); } } } if (oMethod == enHTTPMethod.GET) { httpWebRequest.ContentType = "text/html; charset=utf-8"; httpWebRequest.Method = global::HttpRequest.HttpMethod.Get.ToString(); } else { if (Globals.HTTP_ENCONDING_HEADERS) { sPostData = Globals.G_Utilities.EncodeURL(sPostData); } httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.Method = global::HttpRequest.HttpMethod.Post.ToString(); httpWebRequest.ContentLength = unchecked ((long)sPostData.Length); httpWebRequest.KeepAlive = false; using (Stream requestStream = httpWebRequest.GetRequestStream()) { byte[] bytes = Encoding.ASCII.GetBytes(sPostData); requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); } } if (flag) { Console.WriteLine("HTTP ==> " + sProxy); } this.WebRequest = new global::HttpRequest(httpWebRequest); this.WebResponse = this.WebRequest.GetRequest(); if (this.WebResponse != null) { source = this.WebResponse.SourceCode; sStatus = Conversions.ToString((int)this.WebResponse.HTTPResponse.StatusCode) + " - " + this.WebResponse.HTTPResponse.StatusDescription; } else { source = ""; sStatus = "Not Found"; } } catch (Exception expr_425) { ProjectData.SetProjectError(expr_425); Exception ex = expr_425; sErrDesc = ex.Message; sStatus = sErrDesc; ProjectData.ClearProjectError(); } finally { if (flag) { TimeSpan timeSpan = new TimeSpan(DateAndTime.Now.Ticks); TimeSpan timeSpan2 = timeSpan; TimeSpan ts = new TimeSpan(); value = (long)Math.Round(timeSpan2.Subtract(ts).TotalMilliseconds); } } try { if (flag) { // Console.WriteLine(sID + " " + sUrl + " " + global::Globals.G_Utilities.FormatBytes((double)source.Length) + " " + Conversions.ToString(value) + " ms ", sStatus); } global::Globals.TRAFFIC_RECEIVED += unchecked ((long)source.Length); } catch (Exception expr_4EC) { ProjectData.SetProjectError(expr_4EC); ProjectData.ClearProjectError(); } source = HttpUtility.HtmlDecode(source); return(source); } }