/*Retorna o html de uma página passando pelo captcha é preciso passar o link da imagem * o linksite é concatenado ao texto retirado da imagem linksite + captcharesolvido*/ internal static HtmlDocument GetHtmlHandleCaptcha(string linksite, Encoding e, string captchaParameter, string capthcaLink = "", NameValueCollection formparameters = null, string metodo = "POST") { DeathByCaptcha.Client objSocketClient; try { objSocketClient = new DeathByCaptcha.SocketClient(CaptchaUser, CaptchaPass); } catch (Exception ex) { RService.Log("RService Exception WebHandle: (SocketClient)" + ex.Message + " / " + ex.StackTrace + " / " + ex.InnerException + " at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); return(null); } DeathByCaptcha.Captcha objCaptcha; HtmlDocument htmlDoc = new HtmlDocument(); RService.Log("RService WebHandle: (Linha 90) at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); if (formparameters == null) { formparameters = new NameValueCollection(); } int number = 0; while (number < 2) { try { ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(CustomValidation); using (CookieAwareWebClient wc = new CookieAwareWebClient()) using (MemoryStream ms = new MemoryStream(wc.DownloadData(capthcaLink))) { RService.Log("RService WebHandle: (Linha 103) at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); RService.Log("RService WebHandle [MemoryStream Length: " + ms.Length + "] [CapthcaLink: " + capthcaLink + "]: (Linha 104) at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); objCaptcha = objSocketClient.Decode(ms, 120); if (objCaptcha.Solved && objCaptcha.Correct) { RService.Log("RService WebHandle: (Linha 108) at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); objSocketClient.Close(); formparameters[captchaParameter] = objCaptcha.Text; htmlDoc.LoadHtml(HttpUtility.HtmlDecode(e.GetString(wc.UploadValues(linksite, metodo, formparameters)))); RService.Log("RService WebHandle: (Linha 111) at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); } } break; } catch (Exception ex) { RService.Log("RService Exception WebHandle: (GetHtmlHandleCaptcha)" + ex.Message + " / " + ex.StackTrace + " / " + ex.InnerException + " at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); Thread.Sleep(1000 * 10); objSocketClient = new DeathByCaptcha.SocketClient(CaptchaUser, CaptchaPass); number++; } } return(number == 2 ? null : htmlDoc); }
/*Resolve captcha usando api DeathByCaptcha*/ internal static string ResolveCaptcha(string file) { string solution = string.Empty; DeathByCaptcha.Client objSocketClient; try { objSocketClient = new DeathByCaptcha.SocketClient(CaptchaUser, CaptchaPass); } catch (Exception e) { RService.Log("Exception WebHandle: (ResolveCaptcha)" + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); return(null); } DeathByCaptcha.Captcha objCaptcha; int number = 0; while (number < 2) { try { using (FileStream f = new FileStream(file, FileMode.Open, FileAccess.Read)) { objCaptcha = objSocketClient.Decode(f, 120); if (objCaptcha.Solved && objCaptcha.Correct) { objSocketClient.Close(); solution = objCaptcha.Text; } } break; } catch (Exception e) { Thread.Sleep(1000 * 5); objSocketClient = new DeathByCaptcha.SocketClient(CaptchaUser, CaptchaPass); number++; RService.Log("Exception WebHandle: (ResolveCaptcha)" + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + "RSERVICE" + ".txt"); } } return(number == 2 ? null : solution); }
public string DecodeDBC(string[] args, byte[] imageBytes) { try { // Put your DBC username & password here: DeathByCaptcha.Client client = new DeathByCaptcha.SocketClient(args[0], args[1]); client.Verbose = true; Console.WriteLine("Your balance is {0:F2} US cents", client.Balance); if (!client.User.LoggedIn) { // Log("Please check your DBC Account Details"); return null; } if (client.Balance == 0.0) { // Log("You have 0 Balance in your DBC Account"); return null; } for (int i = 2, l = args.Length; i < l; i++) { Console.WriteLine("Solving CAPTCHA {0}", args[i]); // Upload a CAPTCHA and poll for its status. Put the CAPTCHA image // file name, file object, stream, or a vector of bytes, and desired // solving timeout (in seconds) here: DeathByCaptcha.Captcha captcha = client.Decode(imageBytes, 2 * DeathByCaptcha.Client.DefaultTimeout); if (null != captcha) { Console.WriteLine("CAPTCHA {0:D} solved: {1}", captcha.Id, captcha.Text); //// Report an incorrectly solved CAPTCHA. //// Make sure the CAPTCHA was in fact incorrectly solved, do not //// just report it at random, or you might be banned as abuser. //if (client.Report(captcha)) //{ // Console.WriteLine("Reported as incorrectly solved"); //} //else //{ // Console.WriteLine("Failed reporting as incorrectly solved"); //} return captcha.Text; } else { // Log("CAPTCHA was not solved"); Console.WriteLine("CAPTCHA was not solved"); return null; } } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> LinkedinSignup - SignupMultiThreaded() -- DecodeDBC() --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> LinkedinSignup - DecodeDBC() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " || DateTime :- " + DateTime.Now, Globals.Path_LinkedinAccountCraetionErrorLogs); } return null; }