Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Net.Sockets;
- using System.Net.Security;
- using System.Security.Authentication;
- using System.Security.Cryptography.X509Certificates;
- namespace instaLOGINsok
- {
- class MainClass
- {
- static bool ValidateServerCertificate(object sender,X509Certificate certificate,X509Chain chain,SslPolicyErrors sslPolicyErrors)
- {if (sslPolicyErrors == SslPolicyErrors.None)return true;
- return false;}
- public static void Main (string[] args)
- {
- String id = "";String pass="";String csrftoken = "";String mid = "";
- String cooks = "";
- var request1 = "GET /" + " HTTP/1.1\r\n" +
- "Host: www.instagram.com\r\n" +
- "\r\n";
- Console.WriteLine ("Insta login via tcp client By [ZeR0]\n");
- while (id == "") {Console.WriteLine ("Enter id or email and press enter");id = Console.ReadLine ().ToString();}
- Console.WriteLine ("Id set to => " + id + "\n");
- while (pass == "") {Console.WriteLine ("Enter email password and press enter");pass = Console.ReadLine ().ToString ();}
- Console.WriteLine ("Pass set to => " + pass + "\nStart login ...\n");
- try{
- TcpClient client = new TcpClient("52.20.205.154", 443);
- SslStream sslStream = new SslStream(client.GetStream(),false,new RemoteCertificateValidationCallback(ValidateServerCertificate),null);
- try{sslStream.AuthenticateAsClient("instagram.com");}
- catch (AuthenticationException e){
- Console.WriteLine("Authentication failed with instagram.com\npress any key to exit ..");
- client.Close();
- Console.ReadKey();
- return;}
- #region "Get Cookies"
- byte[] messsage = Encoding.UTF8.GetBytes(request1);
- sslStream.Write(messsage);
- sslStream.Flush();
- byte[] buffer = new byte[client.ReceiveBufferSize];
- String head="";
- while(!(head.Contains("</html>"))){
- sslStream.Read(buffer, 0, buffer.Length);
- head+=System.Text.Encoding.UTF8.GetString(buffer);
- }
- csrftoken = head.Substring(head.IndexOf("csrftoken=") + "csrftoken=".Length);
- csrftoken = csrftoken.Substring(0, csrftoken.IndexOf(";") - 0);
- mid = head.Substring(head.IndexOf("mid=") + "mid=".Length);
- mid = mid.Substring(0, mid.IndexOf(";") - 0);
- cooks+= "mid="+mid+";csrftoken="+csrftoken;
- head="";
- #endregion
- #region "Login"
- string x="username=" + id + "&password=" + pass ;
- var request2 = "POST /accounts/login/ajax/" + " HTTP/1.1\r\n" +
- "Host: www.instagram.com\r\n" +
- "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.3.0\r\n"+
- "Referer: https://www.instagram.com/\r\n"+
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"+
- "X-CSRFToken: " + csrftoken + "\r\n"+
- "Cookie: " + cooks +"\r\n"+
- "Content-Length: " + x.Length.ToString()+"\r\n\r\n"+
- x;
- messsage = Encoding.UTF8.GetBytes(request2);
- sslStream.Write(messsage);
- sslStream.Flush();
- buffer = new byte[2048];
- head="";
- sslStream.Read(buffer, 0, buffer.Length);
- head=System.Text.Encoding.UTF8.GetString(buffer);
- if(head.Contains("\"authenticated\": false")){
- Console.WriteLine("Login faild\nPress any key to exit..");
- Console.ReadKey();
- client.Close();
- return;
- }
- else if(head.Contains("\"authenticated\": true")){
- Console.WriteLine("Login Ok\nPress any key to exit..");
- Console.ReadKey();
- client.Close();
- return;
- }
- else{
- Console.WriteLine("Bad status\nPress any key to exit..");
- Console.ReadKey();
- client.Close();
- return;
- }
- #endregion
- }catch{
- Console.WriteLine("Error in request\nPress any key to exit..");
- Console.ReadKey();
- return;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment