Guest User

Untitled

a guest
Jan 19th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. static string login(string url, string username, string password)
  2. {
  3. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  4. string cookie = "";
  5. string values = "vb_login_username="+username+"&vb_login_password="+password
  6. + "securitytoken=guest&"
  7. + "cookieuser=checked&"
  8. + "do=login";
  9. req.Method = "POST";
  10. req.ContentType = "application/x-www-form-urlencoded";
  11. req.ContentLength = values.Length;
  12. CookieContainer a = new CookieContainer();
  13. req.CookieContainer = a;
  14.  
  15. System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error
  16.  
  17. using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) {writer.Write(values);}
  18.  
  19. HttpWebResponse c = (HttpWebResponse)req.GetResponse();
  20. foreach (Cookie cook in c.Cookies){cookie = cookie + cook.ToString() + ";";}
  21.  
  22. return cookie;
  23. }
  24.  
  25.  
  26. string cookie = login("forum.codecall.net/login.php?do=login", "username", "password"); // include http and www (I don't have 10 forum posts)
  27. Console.Write(cookie);
  28. Console.Read();
Add Comment
Please, Sign In to add comment