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.37 KB | None | 0 0
  1. #region "LoginToTinychat"
  2. private void LoginTinychat(string Username, string Password)
  3. {
  4. AppendTextBoxText(richTextBox1, string.Format("Logging into account: {0}...", Username));
  5. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://tinychat.com/start?");
  6. var _with3 = request;
  7. _with3.KeepAlive = true;
  8. _with3.CookieContainer = LoginCookies;
  9. _with3.Method = "GET";
  10. _with3.Host = "tinychat.com";
  11. _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";
  12. _with3.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
  13. _with3.Referer = "https://tinychat.com/";
  14.  
  15. HttpWebResponse response = (HttpWebResponse)_with3.GetResponse();
  16. StreamReader StreamReader = new StreamReader(response.GetResponseStream());
  17. string PageSource = StreamReader.ReadToEnd();
  18. StreamReader.Close();
  19. LoginCookies.Add(response.Cookies);
  20.  
  21. string CSRFToken = string.Empty;
  22. if (PageSource.Contains("<meta name=\"csrf-token\" id=\"csrf-token\" content=\""))
  23. {
  24. CSRFToken = Regex.Split(PageSource, "<meta name=\"csrf-token\" id=\"csrf-token\" content=\"")[1];
  25. CSRFToken = CSRFToken.Split('"')[0];
  26. recaptchaToken = CSRFToken;
  27. AppendTextBoxText(richTextBox1, "CSRFToken: " + CSRFToken);
  28. }
  29. else
  30. {
  31. AppendTextBoxText(richTextBox1, "Unabled to grab CSRF Token for login!");
  32. return;
  33. }
  34.  
  35. UTF8Encoding UTF8Encoding = new UTF8Encoding();
  36. byte[] PostData = UTF8Encoding.GetBytes(string.Format("login_username={0}&login_password={1}&remember=1&next=https%3A%2F%2Ftinychat.com%2F&_token={2}", userBox.Text, passBox.Text, CSRFToken));
  37. HttpWebRequest PostRequest = (HttpWebRequest)WebRequest.Create("http://tinychat.com/start?#signin");
  38. var _with4 = PostRequest;
  39. _with4.KeepAlive = true;
  40. _with4.Method = "POST";
  41. _with4.Host = "tinychat.com";
  42. _with4.Referer = "https://tinychat.com/start";
  43. _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";
  44. _with4.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  45. _with4.ContentType = "application/x-www-form-urlencoded";
  46. _with4.ContentLength = PostData.Length;
  47. _with4.CookieContainer = LoginCookies;
  48.  
  49.  
  50. Stream newStream = PostRequest.GetRequestStream();
  51. newStream.Write(PostData, 0, PostData.Length);
  52. newStream.Close();
  53.  
  54. HttpWebResponse PostResponse = (HttpWebResponse)_with4.GetResponse();
  55. StreamReader SR = new StreamReader(PostResponse.GetResponseStream());
  56. string LoginSource = SR.ReadToEnd();
  57. SR.Close();
  58. LoginCookies.Add(PostResponse.Cookies);
  59. AppendTextBoxText(richTextBox1, string.Format("Successfully logged into account: {0}...", Username));
  60. Username = userBox.Text;
  61.  
  62. }
  63. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement