Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool LogIn()
- {
- string lgnSrc = webHelper.DownloadStuff(MainUrl + "wp-login.php");
- int crackedNumber = this.CrackCaptcha(lgnSrc);
- if (crackedNumber == -1) return false;
- string cptchResult = Regex.Match(lgnSrc, "name=(?:\"|')cptch_result(?:\"|') value=(?:\"|')(?<result>[^\"']+)(?:\"|')").Groups["result"].Value;
- string fulladdress = MainUrl.Replace("http://", "").Replace("/", "");
- string username = HttpUtility.UrlEncode(UserName);
- string password = HttpUtility.UrlEncode(PassWord);
- string formdata = "log=" + HttpUtility.UrlEncode(UserName) + "&pwd=" + HttpUtility.UrlEncode(PassWord) + "&cptch_result=" + HttpUtility.UrlEncode(cptchResult) + "&cptch_number=" + crackedNumber + "&rememberme=forever&wp-submit=Log+In&redirect_to=http%3A%2F%2F300mblinks.com%2Fwp-admin%2F&testcookie=1";
- formdata = string.Format(formdata, username, password, fulladdress);
- IPHostEntry entry = Dns.GetHostEntry(fulladdress);
- NetworkStream networkStream;
- string responseStr = string.Empty;
- using (TcpClient client = new TcpClient(fulladdress, 80))
- {
- client.SendTimeout = 30000;
- client.ReceiveTimeout = 30000;
- client.Client.Send(new ASCIIEncoding().GetBytes("POST " + MainUrl + "wp-login.php HTTP/1.1\nHost: 300mblinks.com\nConnection: close\nContent-Type: application/x-www-form-urlencoded\nContent-Length: " + formdata.Length + "\n\n" + formdata));
- networkStream = client.GetStream();
- byte[] buffer = new byte[6666];
- System.Threading.Thread.Sleep(1000);
- int bytesRead = networkStream.Read(buffer, 0, buffer.Length);
- responseStr = Encoding.ASCII.GetString(buffer, 0, bytesRead);
- }
- List<String> cookieHeaders = new List<string>();
- foreach (string header in responseStr.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
- {
- if (header.StartsWith("Set-Cookie"))
- {
- cookieHeaders.Add(header.Replace("Set-Cookie: ", ""));
- }
- }
- CookieContainer jar = new CookieContainer();
- foreach (string cook in cookieHeaders)
- {
- string name, value, path, domain;
- name = value = path = domain = "";
- string[] split = cook.Split(';');
- foreach (string part in split)
- {
- if (part.StartsWith(" path="))
- {
- path = part.Replace(" path=", "").Trim();
- }
- if (part.StartsWith(" domain="))
- {
- domain = part.Replace(" domain=", "").Trim();
- }
- if (!part.StartsWith(" path=") && !part.StartsWith(" domain=") && part.Contains("=") && !part.Contains("expires"))
- {
- name = part.Split('=')[0].Trim();
- value = part.Split('=')[1].Trim();
- }
- }
- Cookie cookie = new Cookie(name, value, path, fulladdress);
- jar.Add(cookie);
- }
- webHelper.SetCookieContainer(jar);
- string src = webHelper.DownloadStuff(MainUrl);
- if (!src.Contains("Howdy, " + UserName)) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement