Advertisement
DoctorWhoDoctorWho

Untitled

Aug 30th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.96 KB | None | 0 0
  1. //Type type_rucaptcha = AppDomain.CurrentDomain.GetAssemblies().First(x => x.FullName.IndexOf("Rucaptcha", StringComparison.OrdinalIgnoreCase) != -1).GetType("ZennoLab.RuCaptcha.RuCaptchaConfigurator");
  2. string rucaptcha_key = project.Variables["captchakey"].Value;
  3. string site_key = project.Variables["sitekey"].Value ;
  4. if (site_key == string.Empty)
  5.     throw new Exception("google key не найден, задайте его вручную");
  6. string domen = project.Variables["url"].Value;
  7.  
  8. System.Net.HttpWebRequest post_rucaptcha = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(project.Variables["captchaip"].Value+"/in.php");
  9. post_rucaptcha.Proxy = null;
  10. post_rucaptcha.AllowAutoRedirect = false;
  11. post_rucaptcha.ContentType = @"multipart/form-data; boundary=--8d373f8bt2f4cf3";
  12. post_rucaptcha.Method = "POST";
  13. post_rucaptcha.ServicePoint.Expect100Continue = false;
  14. post_rucaptcha.Timeout = 30000;
  15.  
  16. string content = string.Format(@"----8d373f8bt2f4cf3
  17. Content-Disposition: form-data; name=""method""
  18.  
  19. userrecaptcha
  20. ----8d373f8bt2f4cf3
  21. Content-Disposition: form-data; name=""soft_id""
  22.  
  23. 1313
  24. ----8d373f8bt2f4cf3
  25. Content-Disposition: form-data; name=""key""
  26.  
  27. " + rucaptcha_key + @"
  28. ----8d373f8bt2f4cf3
  29. Content-Disposition: form-data; name=""googlekey""
  30.  
  31. " + site_key + @"
  32. ----8d373f8bt2f4cf3
  33. Content-Disposition: form-data; name=""proxy""
  34.  
  35.  
  36. ----8d373f8bt2f4cf3
  37. Content-Disposition: form-data; name=""pageurl""
  38.  
  39. " + domen + @"
  40. ----8d373f8bt2f4cf3--");
  41.  
  42. using (Stream reqStream = post_rucaptcha.GetRequestStream())
  43. using (StreamWriter sw = new StreamWriter(reqStream))
  44.     sw.Write(content);
  45.  
  46. string url_get;
  47. using (System.Net.WebResponse resp = post_rucaptcha.GetResponse())
  48. using (Stream respStream = resp.GetResponseStream())
  49. using (StreamReader sr = new StreamReader(respStream))
  50. {
  51.     string resp_answer = sr.ReadToEnd();
  52.     if (!resp_answer.Contains("OK|"))
  53.         throw new Exception(resp_answer);
  54.     url_get =project.Variables["captchaip"].Value+"/res.php?key=" + rucaptcha_key + @"&action=get&id=" + resp_answer.Split('|')[1];    
  55. }
  56. Thread.Sleep(10000);
  57.  
  58. for (int z = 0; ;z++)
  59. {
  60.     System.Net.HttpWebRequest get_rucaptcha = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url_get);
  61.     get_rucaptcha.Method = "GET";
  62.     get_rucaptcha.Timeout = 30000;
  63.     get_rucaptcha.Proxy = null;
  64.     get_rucaptcha.AllowAutoRedirect = false;
  65.     post_rucaptcha.ServicePoint.Expect100Continue = false;
  66.  
  67.     string response;
  68.     using (System.Net.WebResponse resp = get_rucaptcha.GetResponse())
  69.     using (Stream respStream = resp.GetResponseStream())
  70.     using (StreamReader sr = new StreamReader(respStream))
  71.         response = sr.ReadToEnd();
  72.  
  73.     if (response.Contains("OK|"))
  74.     {
  75.         project.Variables["token"].Value = response.Split('|')[1];
  76.         break;
  77.     }
  78.     else if ((response != "CAPCHA_NOT_READY" && response != string.Empty) || z > 35)
  79.         throw new Exception("не удалось решить рекапчу, ответ от сервиса: " + response);
  80.     else
  81.         Thread.Sleep(7000);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement