Advertisement
Guest User

Untitled

a guest
Jan 26th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.13 KB | None | 0 0
  1.       public bool Login()
  2.         {
  3.             try
  4.             {
  5.                 var Request = (HttpWebRequest)WebRequest.Create("https://mbasic.facebook.com/");
  6.                 Request.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
  7.                 Request.Method = WebRequestMethods.Http.Get;
  8.                 Request.CookieContainer = new CookieContainer();
  9.                 var Response = (HttpWebResponse)Request.GetResponse();
  10.                 string Form = new StreamReader(Response.GetResponseStream()).ReadToEnd();
  11.                 Regex Regexr = new Regex(@"<form .*<\/form>");
  12.                 Form = Regexr.Match(Form).Value;
  13.                 string[] parts1 = Form.Split(new string[] { "<input" }, StringSplitOptions.None);
  14.                 foreach (Cookie cookie in Response.Cookies)
  15.                 {
  16.                     Cookies.Add(cookie);
  17.                 }
  18.                 Regexr = new Regex("name=" + '"' + "(.*)" + '"' + " value=" + '"' + "(.*)" + '"');
  19.                 string LoginData = "";
  20.                 for (int i = 0; i < 10; i++)
  21.                 {
  22.                     foreach (Match item in Regexr.Matches(parts1[i]))
  23.                     {
  24.                         if (item.Value.Contains("autocomplete") == true)
  25.                         {
  26.                             string[] str2 = item.Groups[2].Value.Split(' ');
  27.                             LoginData += item.Groups[1] + "=" + str2[0] + "&";
  28.                         }
  29.                         else
  30.                         {
  31.                             LoginData += item.Groups[1] + "=" + item.Groups[2] + "&";
  32.                         }
  33.                     }
  34.                 }
  35.                 Regexr = new Regex(@"\/><ul(.*)");
  36.                 LoginData = LoginData.Replace(Convert.ToString('"'), String.Empty).Remove(LoginData.IndexOf(Regexr.Match(LoginData).Value)).Replace("/>", "") + "&email=" + Email + "&pass=" + Pass; ;
  37.                 var Request2 = (HttpWebRequest)WebRequest.Create("https://mbasic.facebook.com/login.php?refsrc=https%3A%2F%2Fm.facebook.com%2F&lwv=101&refid=8");
  38.                 var GetBytesData = Encoding.ASCII.GetBytes(LoginData);
  39.                 Request2.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
  40.                 Request2.Method = WebRequestMethods.Http.Post;
  41.                 Request2.ContentType = "application/x-www-form-urlencoded";
  42.                 Request2.ContentLength = GetBytesData.Length;
  43.                 Request2.AllowAutoRedirect = true;
  44.                 Request2.CookieContainer = Cookies;
  45.                 using (var StreamR = Request2.GetRequestStream())
  46.                 {
  47.                     StreamR.Write(GetBytesData, 0, GetBytesData.Length);
  48.                 }
  49.                 var Response2 = (HttpWebResponse)Request2.GetResponse();
  50.                 Cookies = Request2.CookieContainer;
  51.                 Thread.Sleep(5);
  52.                 if (Response2.ResponseUri.ToString().Contains("home.php")==true)
  53.                 {
  54.                     var Request3 = (HttpWebRequest)WebRequest.Create("https://mbasic.facebook.com/profile.php");
  55.                     Request3.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
  56.                     Request3.Method = WebRequestMethods.Http.Get;
  57.                     Request3.CookieContainer = Cookies;
  58.                     var Response3 = (HttpWebResponse)Request3.GetResponse();
  59.                     string Form2 = new StreamReader(Response3.GetResponseStream()).ReadToEnd();
  60.                     Regexr = new Regex("<strong class=" + '"' + "profileName" + '"' + @">(.*)<\/strong>");
  61.                     UserName = Regexr.Match(Form2).Groups[1].Value;
  62.                     System.Windows.Forms.MessageBox.Show(UserName);
  63.                 }
  64.                 return true;
  65.             }
  66.             catch (Exception)
  67.             {
  68.  
  69.                 return false;
  70.             }
  71.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement