Author Topic: [C#] LocateIP 0.2  (Read 3509 times)

0 Members and 1 Guest are viewing this topic.

Offline Doddy

  • Serf
  • *
  • Posts: 30
  • Cookies: 20
    • View Profile
[C#] LocateIP 0.2
« on: July 04, 2014, 07:30:27 pm »
A program to locate the IP and DNS of a page made in C#.

An image :



Source :

Form1.cs

Code: [Select]
// LocateIP 0.2
// (C) Doddy Hackman 2014
// Credits :
// To locate IP : http://www.melissadata.com/lookups/iplocation.asp?ipaddress=
// To get DNS : http://www.ip-adress.com/reverse_ip/
// Theme Skin designed by Aeonhack
// Thanks to www.melissadata.com and www.ip-adress.com and Aeonhack

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace locateip
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void mButton2_Click(object sender, EventArgs e)
        {           
            funciones modulos = new funciones();

            if (textBox1.Text == "")
            {
                MessageBox.Show("Enter the target");
            }
            else
            {

                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                listBox1.Items.Clear();

                toolStripStatusLabel1.Text = "[+] Getting IP ...";
                this.Refresh();


                string ip = modulos.getip(textBox1.Text);
                if (ip == "Error")
                {
                    MessageBox.Show("Error getting IP ...");
                    toolStripStatusLabel1.Text = "[-] Error getting IP";
                    this.Refresh();
                }
                else
                {
                    textBox1.Text = ip;
                    toolStripStatusLabel1.Text = "[+] Locating ...";
                    this.Refresh();
                    List<String> localizacion = modulos.locateip(ip);
                    if (localizacion[0] == "Error")
                    {
                        MessageBox.Show("Error locating ...");
                        toolStripStatusLabel1.Text = "[-] Error locating";
                        this.Refresh();
                    }
                    else
                    {
                        textBox2.Text = localizacion[0];
                        textBox3.Text = localizacion[1];
                        textBox4.Text = localizacion[2];

                        toolStripStatusLabel1.Text = "[+] Getting DNS ...";
                        this.Refresh();

                        List<String> dns_found = modulos.getdns(ip);
                        if (dns_found[0] == "")
                        {
                            MessageBox.Show("Error getting DNS ...");
                            toolStripStatusLabel1.Text = "[-] Error getting DNS";
                            this.Refresh();
                        }
                        else
                        {

                            foreach (string dns in dns_found)
                            {
                                listBox1.Items.Add(dns);
                            }

                            toolStripStatusLabel1.Text = "[+] Finished";
                            this.Refresh();
                        }

                    }

               
                }
 
            }
           
        }

        private void mButton1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

// The End ?

funciones.cs

Code: [Select]
// Funciones for LocateIP 0.2
// (C) Doddy Hackman 2014

using System;
using System.Collections.Generic;
using System.Text;

//
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
//

namespace locateip
{
    class funciones
    {
        public string getip(string buscar)
        {

            String code = "";
            String url = "http://whatismyipaddress.com/hostname-ip";
            String par = "DOMAINNAME="+buscar;
            String ip = "";

            HttpWebRequest nave = (HttpWebRequest)WebRequest.Create(url);

            nave.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
            nave.Method = "POST";
            nave.ContentType = "application/x-www-form-urlencoded";

            Stream anteantecode = nave.GetRequestStream();

            anteantecode.Write(Encoding.ASCII.GetBytes(par), 0, Encoding.ASCII.GetBytes(par).Length);
            anteantecode.Close();

            StreamReader antecode = new StreamReader(nave.GetResponse().GetResponseStream());
            code = antecode.ReadToEnd();

            Match regex = Regex.Match(code, "Lookup IP Address: <a href=(.*)>(.*)</a>", RegexOptions.IgnoreCase);

            if (regex.Success)
            {
                ip = regex.Groups[2].Value;
            }
            else
            {
                ip = "Error";
            }

            return ip;
        }

        public List<String> locateip(string ip)
        {
            string code = "";

            string city = "";
            string country = "";
            string state = "";

            WebClient nave = new WebClient();
            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
            code = nave.DownloadString("http://www.melissadata.com/lookups/iplocation.asp?ipaddress=" + ip);

            Match regex = Regex.Match(code, "City</td><td align=(.*)><b>(.*)</b></td>", RegexOptions.IgnoreCase);

            if (regex.Success)
            {
                city = regex.Groups[2].Value;
            }
            else
            {
                city = "Error";
            }

            regex = Regex.Match(code, "Country</td><td align=(.*)><b>(.*)</b></td>", RegexOptions.IgnoreCase);

            if (regex.Success)
            {
                country = regex.Groups[2].Value;
            }
            else
            {
                country = "Error";
            }

            regex = Regex.Match(code, "State or Region</td><td align=(.*)><b>(.*)</b></td>", RegexOptions.IgnoreCase);

            if (regex.Success)
            {
                state = regex.Groups[2].Value;
            }
            else
            {
                state = "Error";
            }

            List<string> respuesta = new List<string> {};
            respuesta.Add(city);
            respuesta.Add(country);
            respuesta.Add(state);
            return respuesta;

        }

        public List<String> getdns(string ip)
        {

            string code = "";

            WebClient nave = new WebClient();
            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
            code = nave.DownloadString("http://www.ip-adress.com/reverse_ip/" + ip);

            List<string> respuesta = new List<string> {};

            Match regex = Regex.Match(code, "whois/(.*?)\">Whois", RegexOptions.IgnoreCase);

            while (regex.Success)
            {
                respuesta.Add(regex.Groups[1].Value);
                regex = regex.NextMatch();
            }

            return respuesta;
        }

    }
}

// The End ?

Available for download here
« Last Edit: July 04, 2014, 09:59:28 pm by Doddy »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [C#] LocateIP 0.2
« Reply #1 on: July 04, 2014, 09:07:48 pm »
By "loose the shitty interface" I meant to stop doing it, not don't post the screenshots... it seems you are making skiddy tools bro.

Offline Doddy

  • Serf
  • *
  • Posts: 30
  • Cookies: 20
    • View Profile
Re: [C#] LocateIP 0.2
« Reply #2 on: July 04, 2014, 09:59:39 pm »
I like them, but if you dislike deletes the post, I have no problem.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [C#] LocateIP 0.2
« Reply #3 on: July 05, 2014, 09:11:39 am »
I'm just saying... if you would make a NORMAL interface, more people might use it... but whatever.

Offline Architect

  • Sir
  • ***
  • Posts: 428
  • Cookies: 56
  • STFU
    • View Profile
    • Rootd IRC
Re: [C#] LocateIP 0.2
« Reply #4 on: July 05, 2014, 11:24:04 am »
Kulver is right, people would use this if you lost the GUI and kept it simple. This green hacker shit is just annoying and unprofessional.
« Last Edit: July 05, 2014, 11:24:27 am by Architect »

Offline iiCE

  • /dev/null
  • *
  • Posts: 8
  • Cookies: 6
    • View Profile
Re: [C#] LocateIP 0.2
« Reply #5 on: May 23, 2015, 05:35:09 pm »
Why do you keep looking at the design? It's programming, design is just and finishing touch - or in my case not really important. Does the program work? Yes? He shared the code? Yes? Than I'd be thankful for it's time. Also why not spend a few extra minutes on the interface if you really enjoy what you do. This is a programming niche not a designer one.

Offline iTpHo3NiX

  • EZ's Pirate Captain
  • Administrator
  • Titan
  • *
  • Posts: 2920
  • Cookies: 328
    • View Profile
    • EvilZone
Re: [C#] LocateIP 0.2
« Reply #6 on: May 23, 2015, 06:56:00 pm »
Idk myself liking dark colors, I kind of like the design, it seems clean and elegant to me. Bubzuru made several apps that way, but granted they were pretty skiddy (mail bomber, binder, cryptor, etc)
[09:27] (+lenoch) iTpHo3NiX can even manipulate me to suck dick
[09:27] (+lenoch) oh no that's voluntary
[09:27] (+lenoch) sorry

Offline x0nic

  • Peasant
  • *
  • Posts: 51
  • Cookies: 5
    • View Profile
Re: [C#] LocateIP 0.2
« Reply #7 on: May 28, 2015, 08:45:13 pm »
Why do you keep looking at the design? It's programming, design is just and finishing touch - or in my case not really important. Does the program work? Yes? He shared the code? Yes? Than I'd be thankful for it's time. Also why not spend a few extra minutes on the interface if you really enjoy what you do. This is a programming niche not a designer one.
^this.
haters gonna hate, +1 for op

Offline evolut1o

  • Serf
  • *
  • Posts: 43
  • Cookies: -20
  • the gif guy
    • View Profile
Re: [C#] LocateIP 0.2
« Reply #8 on: December 17, 2015, 11:43:33 pm »
Liked the Matrix Interface. "What's your IP, Neo?". Anyway, nice job Doddy, trying to learn C# myself, thanks for sharing your code with us.

Offline 0E 800

  • Not a VIP
  • VIP
  • Baron
  • *
  • Posts: 895
  • Cookies: 131
  • • тнε ιηтεяηεт ιs мү яεcүcℓε-вιη •
    • View Profile
Re: [C#] LocateIP 0.2
« Reply #9 on: December 18, 2015, 01:28:08 am »
FYI

The invariable mark of wisdom is to see the miraculous in the common.

Offline h4nn1b4L

  • NULL
  • Posts: 2
  • Cookies: -1
    • View Profile
Re: [C#] LocateIP 0.2
« Reply #10 on: January 30, 2016, 11:44:36 pm »
Wow great work. :) i really admire your work doddy. anyway i also made mine. simple and short code. :)

Screenshot:
 

Source Code:
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Xml;

/* <copyright file=xfrmMaim>
   Copyright (c) 2016 All Rights Reserved
   </copyright>
   <author>h4nn1b4L</author>
   <date>1/31/2016 6:26AM</date>
   <summary>Simple and Short Ip Tracer Code on c#</summary>*/

namespace TraceIP
{
    public partial class xfrmMain : Form
    {
        private IpInfo Info = new IpInfo();
        public xfrmMain()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            Invoke((MethodInvoker)delegate
               {
                   Parse(txtIpaddress.Text);
               });
        }
        private class IpInfo
        {
            public string CountryName { get; set; }
            public string RegionName { get; set; }
            public string City { get; set; }
            public double Latitude { get; set; }
            public double Longitude { get; set; }

        }
        private void Parse(string ip)
        {
            try
            {
                string url          = "http://freegeoip.net/xml/";
                string furl         = url + ip;

                XmlDocument doc = new XmlDocument();
                doc.Load(furl);
                XmlElement root     = doc.DocumentElement;
                XmlNode node        = root.SelectSingleNode("/Response");

                Info.CountryName    = node["CountryName"].InnerText;
                Info.RegionName     = node["RegionName"].InnerText;
                Info.City           = node["City"].InnerText;
                Info.Latitude       = Convert.ToDouble(node["Latitude"].InnerText);
                Info.Longitude      = Convert.ToDouble(node["Longitude"].InnerText);

                LoadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }

        private void LoadData()
        {
            txtCountry.Text         = Info.CountryName;
            txtCity.Text            = Info.City;
            txtRegion.Text          = Info.RegionName;
            txtLat.Text             = Info.Latitude.ToString();
            txtLng.Text             = Info.Longitude.ToString();
        }
    }
}