Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. private void LoginTinychat(string Username, string Password)
  2. {
  3. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://tinychat.com/start?");
  4. var _with3 = request;
  5. _with3.KeepAlive = true;
  6. _with3.CookieContainer = LoginCookies;
  7. _with3.Method = "GET";
  8. _with3.Host = "tinychat.com";
  9. _with3.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36";
  10. _with3.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
  11. _with3.Referer = "https://tinychat.com/";
  12.  
  13. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  14. StreamReader StreamReader = new StreamReader(response.GetResponseStream());
  15. string PageSource = StreamReader.ReadToEnd();
  16. StreamReader.Close();
  17. LoginCookies.Add(response.Cookies);
  18.  
  19. string CSRFToken = string.Empty;
  20. if (PageSource.Contains("<meta name=\"csrf-token\" id=\"csrf-token\" content=\""))
  21. {
  22. string[] tempToken = PageSource.Substring(PageSource.IndexOf("csrf-token", 50)).Split('"');
  23. Form1.token = tempToken[4];
  24. Debug.WriteLine(tempToken[4]);
  25. }
  26. else
  27. {
  28. Debug.WriteLine("Unabled to grab CSRF Token for login!");
  29. return;
  30. }
  31.  
  32.  
  33. UTF8Encoding UTF8Encoding = new UTF8Encoding();
  34. byte[] PostData = UTF8Encoding.GetBytes(string.Format("login_username={0}&login_password={1}&remember=1&next=https%3A%2F%2Ftinychat.com%2F&_token={2}", Username, Password, CSRFToken));
  35. HttpWebRequest PostRequest = (HttpWebRequest)WebRequest.Create("https://tinychat.com/login");
  36. var _with4 = PostRequest;
  37. _with4.KeepAlive = true;
  38. _with4.Method = "POST";
  39. _with4.Host = "tinychat.com";
  40. _with4.Referer = "https://tinychat.com/start";
  41. _with4.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36";
  42. _with4.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  43. _with4.ContentType = "application/x-www-form-urlencoded";
  44. _with4.ContentLength = PostData.Length;
  45. _with4.CookieContainer = LoginCookies;
  46.  
  47.  
  48. Stream newStream = PostRequest.GetRequestStream();
  49. newStream.Write(PostData, 0, PostData.Length);
  50. newStream.Close();
  51.  
  52. HttpWebResponse PostResponse = (HttpWebResponse)PostRequest.GetResponse();
  53. StreamReader SR = new StreamReader(PostResponse.GetResponseStream());
  54. string LoginSource = SR.ReadToEnd();
  55. SR.Close();
  56. LoginCookies.Add(PostResponse.Cookies);
  57. Form1.cookieCon = LoginCookies;
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement