Guest User

Untitled

a guest
Jan 18th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Text;
  3. using System.Net.Sockets;
  4. using System.Net.Security;
  5. using System.Security.Authentication;
  6. using System.Security.Cryptography.X509Certificates;
  7. namespace instaLOGINsok
  8. {
  9.     class MainClass
  10.     {
  11.         static bool ValidateServerCertificate(object sender,X509Certificate certificate,X509Chain chain,SslPolicyErrors sslPolicyErrors)
  12.         {if (sslPolicyErrors == SslPolicyErrors.None)return true;
  13.             return false;}
  14.         public static void Main (string[] args)
  15.         {          
  16.             String id = "";String pass="";String csrftoken = "";String mid = "";
  17.             String cooks = "";
  18.             var request1 = "GET /" + " HTTP/1.1\r\n" +
  19.                 "Host: www.instagram.com\r\n" +
  20.                 "\r\n";
  21.            
  22.             Console.WriteLine ("Insta login via tcp client By [ZeR0]\n");
  23.             while (id == "") {Console.WriteLine ("Enter id or email and press enter");id = Console.ReadLine ().ToString();}
  24.             Console.WriteLine ("Id set to => " + id + "\n");
  25.             while (pass == "") {Console.WriteLine ("Enter email password and press enter");pass = Console.ReadLine ().ToString ();}
  26.             Console.WriteLine ("Pass set to => " + pass + "\nStart login ...\n");
  27.             try{
  28.                 TcpClient client = new TcpClient("52.20.205.154", 443);
  29.                 SslStream sslStream = new SslStream(client.GetStream(),false,new RemoteCertificateValidationCallback(ValidateServerCertificate),null);
  30.                 try{sslStream.AuthenticateAsClient("instagram.com");}
  31.                 catch (AuthenticationException e){
  32.                 Console.WriteLine("Authentication failed with instagram.com\npress any key to exit ..");
  33.                 client.Close();
  34.                 Console.ReadKey();
  35.                 return;}
  36.                 #region "Get Cookies"
  37.                 byte[] messsage = Encoding.UTF8.GetBytes(request1);
  38.                 sslStream.Write(messsage);
  39.                 sslStream.Flush();
  40.                 byte[] buffer = new byte[client.ReceiveBufferSize];
  41.                 String head="";
  42.                 while(!(head.Contains("</html>"))){
  43.                         sslStream.Read(buffer, 0, buffer.Length);
  44.                         head+=System.Text.Encoding.UTF8.GetString(buffer);
  45.                     }
  46.                
  47.                 csrftoken = head.Substring(head.IndexOf("csrftoken=") + "csrftoken=".Length);
  48.                 csrftoken = csrftoken.Substring(0, csrftoken.IndexOf(";") - 0);
  49.                 mid = head.Substring(head.IndexOf("mid=") + "mid=".Length);
  50.                 mid = mid.Substring(0, mid.IndexOf(";") - 0);
  51.                 cooks+= "mid="+mid+";csrftoken="+csrftoken;
  52.                 head="";
  53.                 #endregion
  54.                 #region "Login"
  55.                 string x="username=" + id + "&password=" + pass ;
  56.                 var request2 = "POST /accounts/login/ajax/" + " HTTP/1.1\r\n" +
  57.                     "Host: www.instagram.com\r\n" +
  58.                     "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.3.0\r\n"+
  59.                     "Referer: https://www.instagram.com/\r\n"+
  60.                     "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"+
  61.                     "X-CSRFToken: " + csrftoken + "\r\n"+
  62.                     "Cookie: " + cooks +"\r\n"+
  63.                     "Content-Length: " + x.Length.ToString()+"\r\n\r\n"+
  64.                     x;
  65.                 messsage = Encoding.UTF8.GetBytes(request2);
  66.                 sslStream.Write(messsage);
  67.                 sslStream.Flush();
  68.                 buffer = new byte[2048];
  69.                 head="";
  70.                 sslStream.Read(buffer, 0, buffer.Length);
  71.                 head=System.Text.Encoding.UTF8.GetString(buffer);
  72.                 if(head.Contains("\"authenticated\": false")){
  73.                     Console.WriteLine("Login faild\nPress any key to exit..");
  74.                     Console.ReadKey();
  75.                     client.Close();
  76.                     return;
  77.                 }
  78.                 else if(head.Contains("\"authenticated\": true")){
  79.                     Console.WriteLine("Login Ok\nPress any key to exit..");
  80.                     Console.ReadKey();
  81.                     client.Close();
  82.                     return;
  83.                 }
  84.                 else{
  85.                     Console.WriteLine("Bad status\nPress any key to exit..");
  86.                     Console.ReadKey();
  87.                     client.Close();
  88.                     return;
  89.                 }
  90.                 #endregion
  91.             }catch{
  92.                 Console.WriteLine("Error in request\nPress any key to exit..");
  93.                 Console.ReadKey();
  94.                 return;
  95.             }
  96.         }
  97.     }
  98. }
Add Comment
Please, Sign In to add comment