Guest User

dsfsdf

a guest
Feb 19th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.40 KB | None | 0 0
  1. string username = "mollybennett";
  2.             string password = "troll123";
  3.             string time = GetTime();
  4.             string hmac = "Epoch:" + time + "|Body:rem=true&passwd=" + password + "&user=" + username + "&api_type=json";
  5.             string hmac2 = "Epoch:" + time + "|User-Agent:RedditAndroid 1.9.3|Client-Vendor-ID:" + GetGuid(username);
  6.             CookieContainer cookieContainer = new CookieContainer();
  7.             UTF8Encoding uTF8Encoding = new UTF8Encoding();
  8.             string s = string.Concat(new string[]
  9.             {
  10.                             "op=login-main&user=",
  11.                             username,
  12.                             "&passwd=",
  13.                             password,
  14.                             "&api_type=json"
  15.             });
  16.             byte[] bytes = uTF8Encoding.GetBytes(s);
  17.             HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://www.reddit.com/api/v1/login");
  18.             httpWebRequest.Host = "www.reddit.com";
  19.             httpWebRequest.Method = "POST";
  20.             httpWebRequest.CookieContainer = cookieContainer;
  21.             httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  22.             httpWebRequest.Headers.Add("X-hmac-signed-body", "1:android:1:" + time + ":" + CreateToken(hmac, ""));
  23.             httpWebRequest.Headers.Add("X-hmac-signed-result", "1:android:1:" + time + ":" + CreateToken(hmac2, ""));
  24.             httpWebRequest.Headers.Add("Client-Vendor-ID", GetGuid(username));
  25.             httpWebRequest.AutomaticDecompression = (DecompressionMethods)Conversions.ToInteger(Conversions.ToString(1) + Conversions.ToString(2));
  26.             httpWebRequest.UserAgent = "RedditAndroid 1.9.3";
  27.             httpWebRequest.Headers.Add("Accept-Encoding", "gzip");
  28.             httpWebRequest.ContentLength = (long)bytes.Length;
  29.  
  30.             Stream requestStream = httpWebRequest.GetRequestStream();
  31.             requestStream.Write(bytes, 0, bytes.Length);
  32.             requestStream.Close();
  33.             HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  34.             cookieContainer.Add(httpWebResponse.Cookies);
  35.             StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
  36.             string text = streamReader.ReadToEnd();
  37.  
  38.             streamReader.Close();
  39.             httpWebResponse.Close();
  40.             MessageBox.Show(text);
Add Comment
Please, Sign In to add comment