Advertisement
Guest User

Untitled

a guest
May 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public bool Login(string username, string password)
  2. {
  3. byte[] bytes = Encoding.ASCII.GetBytes("cookieuser=1&do=login&vb_login_username=" + HttpUtility.UrlEncode(username) + "&vb_login_password=" + HttpUtility.UrlEncode(password));
  4. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.LoginPage);
  5. request.CookieContainer = new CookieContainer(0x80);
  6. request.Timeout = Leech.GlobalTimeout;
  7. request.Method = "POST";
  8. request.ContentType = "application/x-www-form-urlencoded";
  9. request.ContentLength = bytes.Length;
  10. Stream requestStream = request.GetRequestStream();
  11. requestStream.Write(bytes, 0, bytes.Length);
  12. requestStream.Close();
  13. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  14. if (response != null)
  15. {
  16. StreamReader reader = new StreamReader(response.GetResponseStream());
  17. string contents = reader.ReadToEnd().Trim();
  18. reader.Close();
  19. File.WriteAllText("D.html", contents);
  20. foreach (Cookie cookie in response.Cookies)
  21. {
  22. if (cookie.Name.EndsWith("bbuserid") && (cookie.Value.Length > 0))
  23. {
  24.  
  25. }
  26. }
  27. }
  28. return false;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement