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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


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


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[C#] LocateIP 0.2
« en: 4 Julio 2014, 19:24 pm »

Un simple programa en C# para localizar una IP , su localizacion y sus DNS.

Una imagen :



El codigo :

Form1.cs

Código
  1. // LocateIP 0.2
  2. // (C) Doddy Hackman 2014
  3. // Credits :
  4. // To locate IP : http://www.melissadata.com/lookups/iplocation.asp?ipaddress=
  5. // To get DNS : http://www.ip-adress.com/reverse_ip/
  6. // Theme Skin designed by Aeonhack
  7. // Thanks to www.melissadata.com and www.ip-adress.com and Aeonhack
  8.  
  9. using System;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Text;
  15. using System.Windows.Forms;
  16.  
  17. namespace locateip
  18. {
  19.    public partial class Form1 : Form
  20.    {
  21.        public Form1()
  22.        {
  23.            InitializeComponent();
  24.  
  25.        }
  26.  
  27.        private void mButton2_Click(object sender, EventArgs e)
  28.        {          
  29.            funciones modulos = new funciones();
  30.  
  31.            if (textBox1.Text == "")
  32.            {
  33.                MessageBox.Show("Enter the target");
  34.            }
  35.            else
  36.            {
  37.  
  38.                textBox2.Text = "";
  39.                textBox3.Text = "";
  40.                textBox4.Text = "";
  41.                listBox1.Items.Clear();
  42.  
  43.                toolStripStatusLabel1.Text = "[+] Getting IP ...";
  44.                this.Refresh();
  45.  
  46.  
  47.                string ip = modulos.getip(textBox1.Text);
  48.                if (ip == "Error")
  49.                {
  50.                    MessageBox.Show("Error getting IP ...");
  51.                    toolStripStatusLabel1.Text = "[-] Error getting IP";
  52.                    this.Refresh();
  53.                }
  54.                else
  55.                {
  56.                    textBox1.Text = ip;
  57.                    toolStripStatusLabel1.Text = "[+] Locating ...";
  58.                    this.Refresh();
  59.                    List<String> localizacion = modulos.locateip(ip);
  60.                    if (localizacion[0] == "Error")
  61.                    {
  62.                        MessageBox.Show("Error locating ...");
  63.                        toolStripStatusLabel1.Text = "[-] Error locating";
  64.                        this.Refresh();
  65.                    }
  66.                    else
  67.                    {
  68.                        textBox2.Text = localizacion[0];
  69.                        textBox3.Text = localizacion[1];
  70.                        textBox4.Text = localizacion[2];
  71.  
  72.                        toolStripStatusLabel1.Text = "[+] Getting DNS ...";
  73.                        this.Refresh();
  74.  
  75.                        List<String> dns_found = modulos.getdns(ip);
  76.                        if (dns_found[0] == "")
  77.                        {
  78.                            MessageBox.Show("Error getting DNS ...");
  79.                            toolStripStatusLabel1.Text = "[-] Error getting DNS";
  80.                            this.Refresh();
  81.                        }
  82.                        else
  83.                        {
  84.  
  85.                            foreach (string dns in dns_found)
  86.                            {
  87.                                listBox1.Items.Add(dns);
  88.                            }
  89.  
  90.                            toolStripStatusLabel1.Text = "[+] Finished";
  91.                            this.Refresh();
  92.                        }
  93.  
  94.                    }
  95.  
  96.  
  97.                }
  98.  
  99.            }
  100.  
  101.        }
  102.  
  103.        private void mButton1_Click(object sender, EventArgs e)
  104.        {
  105.            Application.Exit();
  106.        }
  107.    }
  108. }
  109.  
  110. // The End ?
  111.  

funciones.cs

Código
  1. // Funciones for LocateIP 0.2
  2. // (C) Doddy Hackman 2014
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7.  
  8. //
  9. using System.Net;
  10. using System.IO;
  11. using System.Text.RegularExpressions;
  12. //
  13.  
  14. namespace locateip
  15. {
  16.    class funciones
  17.    {
  18.        public string getip(string buscar)
  19.        {
  20.  
  21.            String code = "";
  22.            String url = "http://whatismyipaddress.com/hostname-ip";
  23.            String par = "DOMAINNAME="+buscar;
  24.            String ip = "";
  25.  
  26.            HttpWebRequest nave = (HttpWebRequest)WebRequest.Create(url);
  27.  
  28.            nave.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  29.            nave.Method = "POST";
  30.            nave.ContentType = "application/x-www-form-urlencoded";
  31.  
  32.            Stream anteantecode = nave.GetRequestStream();
  33.  
  34.            anteantecode.Write(Encoding.ASCII.GetBytes(par), 0, Encoding.ASCII.GetBytes(par).Length);
  35.            anteantecode.Close();
  36.  
  37.            StreamReader antecode = new StreamReader(nave.GetResponse().GetResponseStream());
  38.            code = antecode.ReadToEnd();
  39.  
  40.            Match regex = Regex.Match(code, "Lookup IP Address: <a href=(.*)>(.*)</a>", RegexOptions.IgnoreCase);
  41.  
  42.            if (regex.Success)
  43.            {
  44.                ip = regex.Groups[2].Value;
  45.            }
  46.            else
  47.            {
  48.                ip = "Error";
  49.            }
  50.  
  51.            return ip;
  52.        }
  53.  
  54.        public List<String> locateip(string ip)
  55.        {
  56.            string code = "";
  57.  
  58.            string city = "";
  59.            string country = "";
  60.            string state = "";
  61.  
  62.            WebClient nave = new WebClient();
  63.            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  64.            code = nave.DownloadString("http://www.melissadata.com/lookups/iplocation.asp?ipaddress=" + ip);
  65.  
  66.            Match regex = Regex.Match(code, "City</td><td align=(.*)><b>(.*)</b></td>", RegexOptions.IgnoreCase);
  67.  
  68.            if (regex.Success)
  69.            {
  70.                city = regex.Groups[2].Value;
  71.            }
  72.            else
  73.            {
  74.                city = "Error";
  75.            }
  76.  
  77.            regex = Regex.Match(code, "Country</td><td align=(.*)><b>(.*)</b></td>", RegexOptions.IgnoreCase);
  78.  
  79.            if (regex.Success)
  80.            {
  81.                country = regex.Groups[2].Value;
  82.            }
  83.            else
  84.            {
  85.                country = "Error";
  86.            }
  87.  
  88.            regex = Regex.Match(code, "State or Region</td><td align=(.*)><b>(.*)</b></td>", RegexOptions.IgnoreCase);
  89.  
  90.            if (regex.Success)
  91.            {
  92.                state = regex.Groups[2].Value;
  93.            }
  94.            else
  95.            {
  96.                state = "Error";
  97.            }
  98.  
  99.            List<string> respuesta = new List<string> {};
  100.            respuesta.Add(city);
  101.            respuesta.Add(country);
  102.            respuesta.Add(state);
  103.            return respuesta;
  104.  
  105.        }
  106.  
  107.        public List<String> getdns(string ip)
  108.        {
  109.  
  110.            string code = "";
  111.  
  112.            WebClient nave = new WebClient();
  113.            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  114.            code = nave.DownloadString("http://www.ip-adress.com/reverse_ip/" + ip);
  115.  
  116.            List<string> respuesta = new List<string> {};
  117.  
  118.            Match regex = Regex.Match(code, "whois/(.*?)\">Whois", RegexOptions.IgnoreCase);
  119.  
  120.            while (regex.Success)
  121.            {
  122.                respuesta.Add(regex.Groups[1].Value);
  123.                regex = regex.NextMatch();
  124.            }
  125.  
  126.            return respuesta;
  127.        }
  128.  
  129.    }
  130. }
  131.  
  132. // The End ?
  133.  

Si lo quieren bajar lo pueden hacer de aca.


En línea

plexo

Desconectado Desconectado

Mensajes: 3


Ver Perfil
Re: [C#] LocateIP 0.2
« Respuesta #1 en: 7 Julio 2014, 16:02 pm »

Muy Buenoo!! Lo hiciste vos? Una pregunta... no se te complica si no le pones nombres a los controles y eventos?  :huh:


En línea

Eleкtro
Ex-Staff
*
Conectado Conectado

Mensajes: 9.788



Ver Perfil
Re: [C#] LocateIP 0.2
« Respuesta #2 en: 7 Julio 2014, 19:52 pm »

El "theme.cs" & "themebase.cs" está muy chulo xD

Saludos
En línea

BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
Re: [C#] LocateIP 0.2
« Respuesta #3 en: 7 Julio 2014, 20:23 pm »

si , Aeonhack es groso xD.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Perl] LocateIP 0.3
Scripting
BigBear 0 1,556 Último mensaje 19 Enero 2012, 20:35 pm
por BigBear
[Perl Tk] LocateIP 0.4
Scripting
BigBear 6 3,087 Último mensaje 1 Abril 2012, 01:02 am
por BigBear
[PyQT4] LocateIP 0.1
Scripting
BigBear 4 3,058 Último mensaje 29 Agosto 2012, 01:48 am
por -- KiLiaN --
[Java] LocateIP 0.1
Java
BigBear 0 1,435 Último mensaje 13 Enero 2013, 03:39 am
por BigBear
[Ruby] LocateIP 0.3
Scripting
BigBear 0 1,503 Último mensaje 27 Junio 2015, 01:18 am
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines