/// <summary> /// GetToken in page for Secound request (One Token) /// </summary> /// /// <param name="Tokken">Token for get all value grupe in request.</param> /// <param name="config">Config for Request.</param> /// <param name="manage">Keep your request by cookies.</param> /// <param name="Proxy">Send request by proxy service.</param> public Token GetToken(Token Tokken, Config config, RequestManage manage = null, Proxy Proxy = null) { Token end = new Token(); end = Tokken; config.Method = Method.GET; logger.AddMessage("Method config automatic seted on GET", Log.Type.Infomation); RequestManage man = GETData(config, manage, Proxy); Match match = Regex.Match(man.SourcePage, Tokken.RegexPattern); end.Matchs = Regex.Matches(man.SourcePage, Tokken.RegexPattern); end.GrpValue = new List <string>(); for (int i = 1; i <= match.Groups.Count; i++) { if (match.Groups[i].Success) { end.GrpValue.Add(match.Groups[i].Value.ToString()); } } logger.AddMessage("Found " + match.Groups.Count.ToString() + " Groups in Regexing.", Log.Type.Infomation); end.Manage = man; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + man.SourcePage + "\n\nCookies:\n" + Utils.GetCookiesString(man.Cookies, config) + "\n\nHeaders:\n" + man.Headers.ToString(), Log.Type.OutPut); return(end); }
/// <summary> /// Normal GETData /// </summary> /// <param name="config">Config for Request.</param> /// <param name="manage">Keep your request by cookies.</param> /// <param name="Proxy">Send request by proxy service.</param> public RequestManage GETData(Config config, RequestManage Manage = null, Proxy proxy = null) { config.Method = Method.GET; logger.AddMessage("Method config automatic seted on GET", Log.Type.Infomation); RequestManage Get = Rs.GetPageSource(config, Manage, proxy); return(Get); }
/// <summary> /// Capture account whit setting /// </summary> /// <param name="Account">Account for capture.</param> /// <param name="config">Config for Request.</param> /// <param name="manage">Keep your request by cookies.</param> /// <param name="Proxy">Send request by proxy service.</param> /// <param name="Capture">Capture array list for get capture account.</param> /// <param name="source">The source page for search values in Regex Capture.</param> public Account CaptureAccount(string source, Capture[] Capture, Account Account, Config config, RequestManage manage = null, Proxy Proxy = null) { RequestManage manage2 = new RequestManage(); string end = ""; manage2.SourcePage = source; foreach (Capture cap in Capture) { manage2.SourcePage = source; config.LoginURL = cap.Redirect; if (cap.Redirect != null) { if (config.Method == Method.GET) { manage2 = GETData(config, cap.UseCookies ? manage : null, Proxy); } else if (config.Method == Method.POST) { manage2 = POSTData(config, cap.UseCookies ? manage : null, Proxy); } } if (cap.RemoveLines) { manage2.SourcePage = source.Replace("\n", ""); } if (cap.RemoveSpaseChars) { manage2.SourcePage = source.Replace(" ", ""); } if (cap.Remove2SpaseChars) { manage2.SourcePage = source.Replace(" ", ""); } MatchCollection match = Regex.Matches(manage2.SourcePage, cap.Regex); for (int i = 0; i < match.Count; i++) { if (i < cap.MaxMatchs) { for (int j = 1; j <= match[i].Groups.Count; j++) { if (match[i].Groups[j].Success) { end += cap.Lable[i] + match[i].Groups[j].ToString() + " # "; } } } } end += " | "; } Account.Capture = end; logger.AddMessage("Account:\nUsername="******"\nPassword="******"\nHit=" + Account.Hit + "\nCapture=" + Account.Capture, Log.Type.OutPut); return(Account); }
internal RequestManage GetBytesRequest(Config config, Proxy proxy = null, bool GetImage = false) { WebClient wc = new WebClient(); RequestManage Rm = new RequestManage(); if (ProxyService.proxy.Ip != null | proxy != null) { string setProxy = SetProxy(proxy, wc, out wc); if (setProxy != "OK") { Rm.Cookies = null; Rm.Headers = null; Rm.SourcePage = "ERROR|PROXY|" + setProxy; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + Rm.SourcePage + "\n\nCookies:\n" + Utils.GetCookiesString(Rm.Cookies, config) + "\n\nHeaders:\n" + Rm.Headers.ToString(), Log.Type.OutPut); return(Rm); } } else { wc.Proxy = null; } wc.Headers["Cookies"] = config.Cookies; wc.Headers["UserAgent"] = config.UserAgent; wc.Headers["KeepAlive"] = config.KeepAlive.ToString(); wc.Headers["ContentType"] = config.ContectType; wc.Headers["Referer"] = config.Referer; byte[] Res = wc.DownloadData(config.LoginURL); if (GetImage) { try { Image x = (Bitmap)((new ImageConverter()).ConvertFrom(Res)); Rm.Image = x; } catch { } } Rm.Bytes = Res; Rm.CookiesString = wc.Headers["Cookies"]; Rm.Headers = wc.Headers; return(Rm); }
/// <summary> /// GetToken in page for Secound request (One Value) /// </summary> /// <param name="RegexP">Regex Pattenrn for get request value.</param> /// <param name="config">Config for Request.</param> /// <param name="manage">Keep your request by cookies.</param> /// <param name="Proxy">Send request by proxy service.</param> public RequestManage GetToken(string RegexP, Config config, RequestManage manage = null, Proxy Proxt = null) { config.Method = Method.GET; logger.AddMessage("Method config automatic seted on GET", Log.Type.Infomation); RequestManage get = GETData(config, manage, Proxt); Match match = Regex.Match(get.SourcePage, RegexP); logger.AddMessage("Found " + match.Groups.Count.ToString() + " Groups in Regexing.", Log.Type.Infomation); RequestManage end = get; end.SourcePage = match.Groups[1].ToString(); logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + end.SourcePage + "\n\nCookies:\n" + Utils.GetCookiesString(end.Cookies, config) + "\n\nHeaders:\n" + end.Headers.ToString(), Log.Type.OutPut); return(end); }
/// <summary> /// Check account for Value /// </summary> /// <param name="config">Config for Request.</param> /// <param name="manage">Keep your request by cookies.</param> /// <param name="Proxy">Send request by proxy service.</param> public bool CheckAccount(Config config, RequestManage Manage = null, Proxy proxy = null) { RequestManage Get = new RequestManage(); if (config.Method == Method.POST) { Get = POSTData(config, Manage, proxy); } else if (config.Method == Method.GET) { Get = GETData(config, Manage, proxy); } bool End = isHit(config, Get.SourcePage); logger.AddMessage("Hit=" + End.ToString(), Log.Type.OutPut); return(End); }
public string Yon(string url) { Config config = new Config(); MSC.Brute.Requester Rer = new MSC.Brute.Requester(); config.LoginURL = "http://yon.ir"; MSC.Brute.RequestManage login = Rer.GETData(config); config.Cookies = login.CookiesString; config.LoginURL = "http://yon.ir/app/shorten.php"; config.KeepAlive = true; config.Method = Method.POST; config.Referer = "http://yon.ir/"; config.ContectType = "application/x-www-form-urlencoded"; config.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0"; config.PostData = "url=" + url + "&wish="; MSC.Brute.RequestManage manage = Rer.POSTData(config, login);; string pattern = @"output"":""(.*?)"""; return("http://yon.ir/" + System.Text.RegularExpressions.Regex.Match(manage.SourcePage, pattern).Groups[1].Value.ToString()); }
/// <summary> /// Check account and set capture by your setting in params /// </summary> /// <param name="ac">Account for check.</param> /// <param name="config">Config for Request.</param> /// <param name="manage">Keep your request by cookies.</param> /// <param name="Proxy">Send request by proxy service.</param> /// <param name="Caper">Capture array list for get capture account.</param> public Account CheckAccount(Config config, Account ac, Capture[] Caper, RequestManage manage = null, Proxy proxy = null) { RequestManage Get = new RequestManage(); if (config.Method == Method.POST) { Get = POSTData(config, manage, proxy); } else if (config.Method == Method.GET) { Get = GETData(config, manage, proxy); } ac.Hit = isHit(config, Get.SourcePage); if (Caper != null) { ac = CaptureAccount(Get.SourcePage, Caper, ac, config, manage, proxy); } logger.AddMessage("Account:\nUsername="******"\nPassword="******"\nHit=" + ac.Hit + "\nCapture=" + ac.Capture, Log.Type.OutPut); return(ac); }
/// <summary> /// POSTData base request /// </summary> /// <param name="config">Config for Request.</param> /// <param name="mange">Keep your request by cookies.</param> /// <param name="proxy">Send request by proxy service.</param> internal RequestManage GetRequestByData(Config config, RequestManage mange = null, Proxy Proxy = null) { if (mange != null) { if (mange.CookiesString != null) { config.Cookies += mange.CookiesString; } } RequestManage end = new RequestManage(); try { //SetConfig CookieContainer container = new CookieContainer(); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(config.LoginURL); if (ProxyService.proxy.Ip != null | Proxy != null) { string setProxy = SetProxy(Proxy, httpWebRequest, out httpWebRequest); if (setProxy != "OK") { end.Cookies = null; end.ErrorAst = true; end.Headers = null; end.SourcePage = "ERROR|PROXY|" + setProxy; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + end.SourcePage + "\n\nCookies:\n" + Utils.GetCookiesString(end.Cookies, config) + "\n\nHeaders:\n" + end.Headers.ToString(), Log.Type.OutPut); return(end); } } else { httpWebRequest.Proxy = null; } byte[] bytes = new ASCIIEncoding().GetBytes(config.PostData); httpWebRequest.ContentLength = bytes.Length; httpWebRequest = SetOtherSetting(config, httpWebRequest); httpWebRequest.CookieContainer = container; //Add Headers if (config.Headers != null) { httpWebRequest.Headers = Utils.SetHeaders(config); } //Add Cookies if (config.Cookies != null) { container = Utils.SetCookies(config, container, httpWebRequest.Host); } //GetRequest try { if (mange.Cookies.Count != 0) { container = mange.Cookies; container.ToString(); } } catch { } httpWebRequest.CookieContainer = container; logger.AddMessage("Getting Response", Log.Type.Infomation); Stream requestStream = httpWebRequest.GetRequestStream(); requestStream.Write(bytes, 0, bytes.Length); HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse(); requestStream.Close(); container.Add(response.Cookies); end = Utils.GetManage(response, container); end.CookiesString = Utils.GetCookiesString(container, config); end.StatusCode = (int)response.StatusCode; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + end.SourcePage + "\n\nCookies:\n" + Utils.GetCookiesString(end.Cookies, config) + "\n\nHeaders:\n" + end.Headers.ToString() + "\nCode: " + end.StatusCode.ToString(), Log.Type.OutPut); return(end); } catch (WebException ex) { string error = ex.Message; end.StatusCode = (int)((HttpWebResponse)ex.Response).StatusCode; end.ErrorAst = true; end.SourcePage = "ERROR|" + error + "|" + ex.Message; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + end.SourcePage + "\n\nCode: " + end.StatusCode.ToString(), Log.Type.OutPut); return(end); } }
/// <summary> /// GETData base request /// </summary> /// <param name="config">Config for Request.</param> /// <param name="mange">Keep your request by cookies.</param> /// <param name="proxy">Send request by proxy service.</param> internal RequestManage GetPageSource(Config config, RequestManage mange = null, Proxy Proxy = null) { if (mange != null) { if (mange.CookiesString != null) { config.Cookies += mange.CookiesString; } } RequestManage end = new RequestManage(); try { ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); }); CookieContainer container = new CookieContainer(); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(config.LoginURL); try { if (mange.Cookies.Count != 0) { container = mange.Cookies; } } catch { } //Set Proxy if (ProxyService.proxy.Ip != null | Proxy != null) { string setProxy = SetProxy(Proxy, httpWebRequest, out httpWebRequest); if (setProxy != "OK") { end.Cookies = null; end.Headers = null; end.SourcePage = "ERROR|PROXY|" + setProxy; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + end.SourcePage + "\n\nCookies:\n" + Utils.GetCookiesString(end.Cookies, config) + "\n\nHeaders:\n" + end.Headers.ToString(), Log.Type.OutPut); return(end); } } else { httpWebRequest.Proxy = null; } httpWebRequest = SetOtherSetting(config, httpWebRequest); //Add Headres if (config.Headers != null) { httpWebRequest.Headers = Utils.SetHeaders(config); } //Add Cookies if (config.Cookies != null) { container = Utils.SetCookies(config, container, httpWebRequest.Host); } httpWebRequest.CookieContainer = container; logger.AddMessage("Getting Response", Log.Type.Infomation); HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse(); end = Utils.GetManage(response, container); end.CookiesString = Utils.GetCookiesString(container, config); logger.AddMessage("RequestManage OutPut\nCookies:\n" + Utils.GetCookiesString(end.Cookies, config) + "\n\nHeaders:\n" + end.Headers.ToString() + "\nCode: " + end.StatusCode.ToString(), Log.Type.OutPut); return(end); } catch (WebException ex) { string error = ex.Message; end.StatusCode = (int)((HttpWebResponse)ex.Response).StatusCode; end.ErrorAst = true; end.SourcePage = "ERROR|" + error + "|" + ex.Message; logger.AddMessage("RequestManage OutPut\nSoucePage:\n" + end.SourcePage + "\n\nCode: " + end.StatusCode.ToString(), Log.Type.OutPut); return(end); } }