elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Problema al conectarse al protocolo de msn C#
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problema al conectarse al protocolo de msn C#  (Leído 2,821 veces)
Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Problema al conectarse al protocolo de msn C#
« en: 28 Marzo 2009, 21:18 pm »

Estaba buscando en google sobre conexion al protocolo del msn , y encontre una clase en este foro pero no quise responder ahi por que ya era del año 2007 y creo que esta contra las reglas revivir post antiguos... asi que lo planteo aqui, al conectarse me arroja errores como length no puede ser menor a uno , o cadena muy larga y cosas por el estilo , les escribo la clase para que ustedes vean el error de la excepcion y me digan que puedo hacer para solucionarlo , recuerden... El codigo no es mio es de un tipo del foro que olvide el nombre  :P

Aca el codigo:

Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.IO;
  7.  
  8.  
  9. namespace Conexion_Msn
  10. {
  11.    class Program
  12.    {
  13.        static string cuenta;
  14.        static string pass;
  15.  
  16.        public bool IsNumeric(object epresionje)
  17.        {
  18.            bool isNum;
  19.            double retNum;
  20.  
  21.            isNum = Double.TryParse(Convert.ToString(epresionje), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out retNum);
  22.            return isNum;
  23.        }
  24.  
  25.        public string urldecode(string cadena)
  26.        {
  27.            char p = '%';
  28.            string hexa;
  29.            long dec;
  30.            char asc;
  31.            string resultado = "";
  32.  
  33.            Program hen = new Program();
  34.  
  35.            string[] arr = cadena.Split(p);
  36.            foreach (string q in arr)
  37.            {
  38.                if (q.Length > 0)
  39.                {
  40.                    hexa = q.Substring(0, 2);
  41.                    if (hen.IsNumeric(hexa) == true)
  42.                    {
  43.                        dec = Convert.ToInt64(hexa, 16);
  44.                        asc = Convert.ToChar(dec);
  45.                        resultado = resultado + asc + q.Substring(2);
  46.                    }
  47.                    else
  48.                    {
  49.                        resultado = resultado + q;
  50.                    }
  51.  
  52.                }
  53.            }
  54.  
  55.            return resultado;
  56.  
  57.        }
  58.  
  59.        public string depurarip(string direc)
  60.        {
  61.            string a;
  62.            int b;
  63.            string c;
  64.  
  65.            a = direc.Substring(9);
  66.            b = a.IndexOf(":");
  67.            c = a.Substring(0, b);
  68.  
  69.            return c;
  70.  
  71.        }
  72.  
  73.        public string Sacacookie(string resultado)
  74.        {
  75.            int a;
  76.            string b;
  77.            int c;
  78.            string d;
  79.  
  80.  
  81.            a = resultado.IndexOf("'t=");
  82.            b = resultado.Substring(a + 2);
  83.            c = b.IndexOf("'");
  84.            d = b.Substring(1, c);
  85.  
  86.            return d;
  87.        }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.        static void Main(string[] args)
  94.        {
  95.  
  96.            Console.Write("Introduce tu Cuenta: ");
  97.            cuenta = Console.ReadLine();
  98.            Console.Write("Introduce la Pass: ");
  99.            pass = Console.ReadLine();
  100.  
  101.  
  102.            string cabecera = "VER 1 MSNP9 MSNP8 CVR0\r\n";
  103.            string respuesta = "";
  104.            string cab2 = "CVR 2 0x0C0A winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS " + cuenta + "\r\n";
  105.            string cab3 = "USR 3 TWN I " + cuenta + "\r\n";
  106.            string cab4 = "VER 4 MSNP9 MSNP8 CVR0\r\n";
  107.            string cab5 = "CVR 5 0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS " + cuenta + "\r\n";
  108.            string cab6 = "USR 6 TWN I " + cuenta + "\r\n";
  109.            string cab7;
  110.            string nick;
  111.            Byte[] Send6 = Encoding.ASCII.GetBytes(cab6);
  112.            Byte[] Rec6 = new Byte[255];
  113.            Byte[] Send5 = Encoding.ASCII.GetBytes(cab5);
  114.            Byte[] Rec5 = new Byte[255];
  115.            Byte[] Send4 = Encoding.ASCII.GetBytes(cab4);
  116.            Byte[] Rec4 = new Byte[255];
  117.            Byte[] Send3 = Encoding.ASCII.GetBytes(cab3);
  118.            Byte[] Rec3 = new Byte[255];
  119.            Byte[] Send2 = Encoding.ASCII.GetBytes(cab2);
  120.            Byte[] Rec = new Byte[255];
  121.            Byte[] SendBytes = Encoding.ASCII.GetBytes(cabecera);
  122.            Byte[] RecvBytes = new Byte[255];
  123.            int bytes;
  124.            string IPnueva;
  125.            string cookie;
  126.            string cuentaurl = cuenta.Replace("@", "%40");
  127.  
  128.  
  129.            IPHostEntry address = Dns.GetHostEntry("messenger.hotmail.com");
  130.            IPEndPoint Ep = new IPEndPoint(address.AddressList[0], 1863);
  131.            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  132.  
  133.            try
  134.            {
  135.                // Primera conexión
  136.                socket.Connect(Ep);
  137.                socket.Send(SendBytes, SendBytes.Length, SocketFlags.None);
  138.                bytes = socket.Receive(RecvBytes, RecvBytes.Length, SocketFlags.None);
  139.                respuesta = Encoding.ASCII.GetString(RecvBytes, 0, bytes);
  140.  
  141.                //Segunda Conexión
  142.                socket.Send(Send2, Send2.Length, SocketFlags.None);
  143.                bytes = socket.Receive(Rec, Rec.Length, SocketFlags.None);
  144.                respuesta = Encoding.ASCII.GetString(Rec, 0, bytes);
  145.  
  146.                //tercera Conexión
  147.                socket.Send(Send3, Send3.Length, SocketFlags.None);
  148.                bytes = socket.Receive(Rec3, Rec3.Length, SocketFlags.None);
  149.                respuesta = Encoding.ASCII.GetString(Rec3, 0, bytes);
  150.  
  151.                Program o = new Program();
  152.  
  153.                IPnueva = o.depurarip(respuesta);
  154.  
  155.                socket.Close();
  156.  
  157.                Console.WriteLine("\nConectando...");
  158.  
  159.                //Cuarta conexión
  160.                IPHostEntry addressa = Dns.GetHostEntry(IPnueva);
  161.                IPEndPoint Epo = new IPEndPoint(addressa.AddressList[0], 1863);
  162.                Socket socket2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  163.  
  164.                socket2.Connect(Epo);
  165.                socket2.Send(Send4, Send4.Length, SocketFlags.None);
  166.                bytes = socket2.Receive(Rec4, Rec4.Length, SocketFlags.None);
  167.                respuesta = Encoding.ASCII.GetString(Rec4, 0, bytes);
  168.  
  169.                //Quinta conexión
  170.                socket2.Send(Send5, Send5.Length, SocketFlags.None);
  171.                bytes = socket2.Receive(Rec5, Rec5.Length, SocketFlags.None);
  172.                respuesta = Encoding.ASCII.GetString(Rec5, 0, bytes);
  173.  
  174.                //Sexta conexión
  175.                socket2.Send(Send6, Send6.Length, SocketFlags.None);
  176.                bytes = socket2.Receive(Rec6, Rec6.Length, SocketFlags.None);
  177.                respuesta = Encoding.ASCII.GetString(Rec6, 0, bytes);
  178.  
  179.                cookie = respuesta.Substring(12);
  180.  
  181.  
  182.                //Septima conexión
  183.                string tiket;
  184.                string head;
  185.  
  186.                cab7 = "Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom, sign-in=" + cuentaurl + ",pwd=" + pass + "," + cookie + "\r\n";
  187.                WebRequest request = WebRequest.Create("https://login.passport.com/login2.srf");
  188.                request.Headers.Add("Authorization", cab7);
  189.                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  190.                head = Convert.ToString(response.Headers);
  191.                tiket = o.Sacacookie(head);
  192.                response.Close();
  193.  
  194.                //Ultima conexión
  195.                String cab8 = "USR 7 TWN S t=" + tiket + "\r\n";
  196.                Byte[] Send8 = Encoding.ASCII.GetBytes(cab8);
  197.                Byte[] Rec8 = new Byte[255];
  198.  
  199.                socket2.Send(Send8, Send8.Length, SocketFlags.None);
  200.                bytes = socket2.Receive(Rec8, Rec8.Length, SocketFlags.None);
  201.                respuesta = Encoding.ASCII.GetString(Rec8, 0, bytes);
  202.  
  203.                nick = respuesta.Substring(cuenta.Length + 10);
  204.  
  205.                string decode;
  206.                int fin;
  207.  
  208.                fin = nick.IndexOf("??$");
  209.                nick = nick.Substring(0, fin);
  210.  
  211.                decode = o.urldecode(nick);
  212.  
  213.                Console.WriteLine("\n\nTu nick es: {0}", decode);
  214.  
  215.                Console.Read();
  216.            }
  217.            catch(Exception error)
  218.            {
  219.                Console.WriteLine("Ocurrió un error : " +error.Message);
  220.                Console.Read();
  221.            }
  222.        }
  223.    }
  224. }
  225.  


En línea

sangano

Desconectado Desconectado

Mensajes: 47



Ver Perfil
Re: Problema al conectarse al protocolo de msn C#
« Respuesta #1 en: 28 Marzo 2009, 22:43 pm »

Esto no va a tu pregunta totalmente, pero igual te puede servir.
 http://www.hypothetic.org/docs/msn/index.php


En línea

Pablo Videla


Desconectado Desconectado

Mensajes: 2.274



Ver Perfil WWW
Re: Problema al conectarse al protocolo de msn C#
« Respuesta #2 en: 29 Marzo 2009, 21:38 pm »

Es que esta el codigo hecho y no funciona por un simple error... estoy seguro que ustedes me pueden ayudar  ;D
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Problema al conectarse a mi servidor ftp(solo veteranos o lectores de hackxcrak)
Hacking
zaico 6 4,474 Último mensaje 2 Marzo 2011, 22:54 pm
por Axus
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines