Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void LoginTinychat(string Username, string Password)
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://tinychat.com/start?");
- var _with3 = request;
- _with3.KeepAlive = true;
- _with3.CookieContainer = LoginCookies;
- _with3.Method = "GET";
- _with3.Host = "tinychat.com";
- _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";
- _with3.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
- _with3.Referer = "https://tinychat.com/";
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader StreamReader = new StreamReader(response.GetResponseStream());
- string PageSource = StreamReader.ReadToEnd();
- StreamReader.Close();
- LoginCookies.Add(response.Cookies);
- string CSRFToken = string.Empty;
- if (PageSource.Contains("<meta name=\"csrf-token\" id=\"csrf-token\" content=\""))
- {
- string[] tempToken = PageSource.Substring(PageSource.IndexOf("csrf-token", 50)).Split('"');
- Form1.token = tempToken[4];
- Debug.WriteLine(tempToken[4]);
- }
- else
- {
- Debug.WriteLine("Unabled to grab CSRF Token for login!");
- return;
- }
- UTF8Encoding UTF8Encoding = new UTF8Encoding();
- 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));
- HttpWebRequest PostRequest = (HttpWebRequest)WebRequest.Create("https://tinychat.com/login");
- var _with4 = PostRequest;
- _with4.KeepAlive = true;
- _with4.Method = "POST";
- _with4.Host = "tinychat.com";
- _with4.Referer = "https://tinychat.com/start";
- _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";
- _with4.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
- _with4.ContentType = "application/x-www-form-urlencoded";
- _with4.ContentLength = PostData.Length;
- _with4.CookieContainer = LoginCookies;
- Stream newStream = PostRequest.GetRequestStream();
- newStream.Write(PostData, 0, PostData.Length);
- newStream.Close();
- HttpWebResponse PostResponse = (HttpWebResponse)PostRequest.GetResponse();
- StreamReader SR = new StreamReader(PostResponse.GetResponseStream());
- string LoginSource = SR.ReadToEnd();
- SR.Close();
- LoginCookies.Add(PostResponse.Cookies);
- Form1.cookieCon = LoginCookies;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement