Advertisement
maus234

Untitled

Dec 11th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using OpenQA.Selenium;
  4. using OpenQA.Selenium.Chrome;
  5. using System.Threading;
  6. using TwoCaptcha.Captcha;
  7. using TwoCaptcha;
  8. public class BingXAtomatic
  9. {
  10. static void Main(string[] args)
  11. {
  12. // Read data from the file
  13. string filePath = "C:\\bot\\1234.txt";
  14. var credentials = ReadCredentialsFromFile(filePath);
  15.  
  16.  
  17. IWebDriver driver = new ChromeDriver();
  18. driver.Navigate().GoToUrl("https://bingx.com/ru-ru/register");
  19.  
  20. IWebElement usernameElement = driver.FindElement(By.XPath("//*[@id=\"__layout\"]/div/div[1]/div/div/div/div[4]/div/div/input"));
  21. IWebElement passwordElement = driver.FindElement(By.XPath("//*[@id=\"__layout\"]/div/div[1]/div/div/div/div[5]/div/div/input"));
  22.  
  23. // Assuming credentials is a KeyValuePair<string, string>
  24. usernameElement.SendKeys(credentials.Key);
  25. Thread.Sleep(10000);
  26. passwordElement.SendKeys(credentials.Value);
  27. IWebElement register = driver.FindElement(By.XPath("//*[@id=\"__layout\"]/div/div[1]/div/div/div/button"));
  28. register.Click();
  29. CaptchaSolve(driver);
  30.  
  31.  
  32.  
  33. }
  34.  
  35. private static void CaptchaSolve(IWebDriver driver)
  36. {
  37.  
  38. TwoCaptcha.TwoCaptcha solver = new TwoCaptcha.TwoCaptcha("API");
  39. GeeTestV4 captcha = new GeeTestV4();
  40. captcha.SetCaptchaId("3dd5c2c85ab5702b553993389dc41859&challenge=365be3fa-a1b1-400b-bdbb-d21ad3898641&client_type=web&lang=rus&callback=geetest_170223272441");
  41. captcha.SetUrl("https://bingx.com/ru-ru/register");
  42. try
  43. {
  44. solver.Solve(captcha).Wait();
  45. Console.WriteLine("Captcha solved: " + captcha.Code);
  46.  
  47. SendCaptchaSolutionToServer(driver, captcha.Code);
  48. }
  49. catch (AggregateException e)
  50. {
  51. Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
  52. }
  53. }
  54.  
  55. private static void SendCaptchaSolutionToServer(IWebDriver driver, string captchaSolution)
  56. {
  57. using (var httpClient = new HttpClient())
  58. {
  59. var content = new FormUrlEncodedContent(new[]
  60. {
  61. new KeyValuePair<string, string>("captcha_solution", captchaSolution),
  62. // Add any other parameters needed by the server
  63. });
  64.  
  65. var response = httpClient.PostAsync("https://bingx.com/ru-ru/register/", content).Result;
  66.  
  67. // Check the response status or perform further actions based on the server response
  68. if (response.IsSuccessStatusCode)
  69. {
  70. Console.WriteLine("Captcha solution sent successfully");
  71. }
  72. else
  73. {
  74. Console.WriteLine($"Failed to send captcha solution. Status code: {response.StatusCode}");
  75. }
  76. }
  77.  
  78. }
  79.  
  80. // Function to read email and password from a file
  81. static KeyValuePair<string, string> ReadCredentialsFromFile(string filePath)
  82. {
  83. try
  84. {
  85. string[] lines = File.ReadAllLines(filePath);
  86.  
  87. if (lines.Length > 0)
  88. {
  89. string[] parts = lines[0].Split(':');
  90.  
  91. if (parts.Length == 2)
  92. {
  93. string email = parts[0].Trim();
  94. string password = parts[1].Trim();
  95. return new KeyValuePair<string, string>(email, password);
  96. }
  97. else
  98. {
  99. Console.WriteLine("Invalid formot");
  100. }
  101. }
  102. else
  103. {
  104. Console.WriteLine("File is empty.");
  105. }
  106. }
  107. catch(Exception ex)
  108. {
  109. Console.WriteLine($"{ex.Message}");
  110. }
  111.  
  112. return default;
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement