Untitled
unknown
csharp
2 years ago
4.4 kB
3
Indexable
Never
private async Task VerifyPhone(string password) { Console.WriteLine("[*] Starting phone verification..."); var simClient = new OnlineSimClient(Config.ONLINESIM_API_KEY); var phone = await simClient.GetNumber(); Console.WriteLine("[*] Created phone number {0}", phone); var res = await _client.GetAsync("/api/users/@me/affinities/users"); var content = await res.Content.ReadAsStringAsync(); bool locked = content.Contains("You need to verify your account in order to perform this action."); var changePhoneReason = locked ? "user_action_required" : "user_settings_update"; await Task.Delay(2500); string? code; Console.WriteLine("[*] Sending phone verification..."); int tries = 0; while (true) { if (tries > 0 && tries % 2 == 0) { phone = await simClient.GetNumber(); Console.WriteLine("[*] Created a new phone number {0}", phone); } await SendPhoneVerification(phone, changePhoneReason); Console.WriteLine("[*] Waiting for verification code..."); code = await simClient.WaitForCode(); if (code != null) break; Console.WriteLine("[*] Resending verification code..."); tries++; } Console.WriteLine("[*] Phone verification code: {0}", code); var verifyPhoneReq = new VerifyPhoneRequest { Code = code, Phone = phone, }; res = await _client.PostAsync("/api/phone-verifications/verify", new StringContent(JsonSerializer.Serialize(verifyPhoneReq), Encoding.UTF8, "application/json")); content = await res.Content.ReadAsStringAsync(); var verifyPhoneRes = JsonSerializer.Deserialize<VerifyPhoneResponse>(content); if (verifyPhoneRes == null) throw new JsonException(); var confirmPhoneReq = new ConfirmPhoneVerificationRequest { ChangePhoneReason = changePhoneReason, Password = password, PhoneToken = verifyPhoneRes.Token, }; await _client.PostAsync("/api/users/@me/phone", new StringContent(JsonSerializer.Serialize(confirmPhoneReq), Encoding.UTF8, "application/json")); } private async Task<bool> SendPhoneVerification(string phone, string changePhoneReason) { var phoneReq = new CreatePhoneVerificationRequest { ChangePhoneReason = changePhoneReason, Phone = phone, }; var res = await _client.PostAsync("/api/users/@me/phone", new StringContent(JsonSerializer.Serialize(phoneReq), Encoding.UTF8, "application/json")); var content = await res.Content.ReadAsStringAsync(); await Task.Delay(2500); if (content.Contains("captcha_sitekey")) { var captchaRes = JsonSerializer.Deserialize<CaptchaResponse>(content); if (captchaRes == null) throw new JsonException(); Console.WriteLine("[*] Solving HCaptcha..."); var solved = await _solver.SolveHCaptcha("discord.com", captchaRes.CaptchaSitekey); var phoneCaptchaReq = new CreatePhoneVerificationCaptchaRequest { CaptchaKey = solved.Solution, ChangePhoneReason = changePhoneReason, Phone = phone, }; res = await _client.PostAsync("/api/users/@me/phone", new StringContent(JsonSerializer.Serialize(phoneCaptchaReq), Encoding.UTF8, "application/json")); if (!res.IsSuccessStatusCode) { await _solver.Report(solved.Id, false); return false; } Console.WriteLine("[*] Solved captcha: {0}", captchaRes.CaptchaSitekey); await _solver.Report(solved.Id, true); await Task.Delay(2500); } return true; }