Author Topic: [Delphi] LocateIP 0.5  (Read 1843 times)

0 Members and 1 Guest are viewing this topic.

Offline Doddy

  • Serf
  • *
  • Posts: 30
  • Cookies: 20
    • View Profile
[Delphi] LocateIP 0.5
« on: April 04, 2014, 08:19:48 pm »
Final version of the program to locate the IP and DNS of a page.

An image :



Source :

Code: [Select]
// LocateIP 0.5
// (C) Doddy Hackman 2014
// Credits :
// Based on the services :
// To get IP -- http://whatismyipaddress.com/
// To locate IP -- http://www.melissadata.com/
// To get DNS -- http://www.ip-adress.com/
// Thanks to whatismyipaddress.com , www.melissadata.com , www.ip-adress.com

unit locate;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls,
  IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, PerlRegEx,
  IdMultipartFormData, Vcl.Imaging.pngimage, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Button1: TButton;
    GroupBox2: TGroupBox;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    StatusBar1: TStatusBar;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    IdHTTP1: TIdHTTP;
    Image1: TImage;
    GroupBox3: TGroupBox;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  regex: TPerlRegEx;
  par: TIdMultiPartFormDataStream;
  rta: string;
  z: integer;

begin

  regex := TPerlRegEx.Create();

  par := TIdMultiPartFormDataStream.Create;
  par.AddFormField('DOMAINNAME', Edit1.text);

  StatusBar1.Panels[0].text := '[+] Getting IP ...';
  Form1.StatusBar1.Update;

  rta := IdHTTP1.Post('http://whatismyipaddress.com/hostname-ip', par);

  regex.regex := 'Lookup IP Address: <a href=(.*)>(.*)<\/a>';
  regex.Subject := rta;

  if regex.Match then
  begin
    Edit1.text := regex.Groups[2];

    StatusBar1.Panels[0].text := '[+] Locating ...';
    Form1.StatusBar1.Update;

    rta := IdHTTP1.Get
      ('http://www.melissadata.com/lookups/iplocation.asp?ipaddress=' +
      Edit1.text);

    regex.regex := 'City<\/td><td align=(.*)><b>(.*)<\/b><\/td>';
    regex.Subject := rta;

    if regex.Match then
    begin
      Edit2.text := regex.Groups[2];
    end
    else
    begin
      Edit2.text := 'Not Found';
    end;

    regex.regex := 'Country<\/td><td align=(.*)><b>(.*)<\/b><\/td>';
    regex.Subject := rta;

    if regex.Match then
    begin
      Edit3.text := regex.Groups[2];
    end
    else
    begin
      Edit3.text := 'Not Found';
    end;

    regex.regex := 'State or Region<\/td><td align=(.*)><b>(.*)<\/b><\/td>';
    regex.Subject := rta;

    if regex.Match then
    begin
      Edit4.text := regex.Groups[2];
    end
    else
    begin
      Edit4.text := 'Not Found';
    end;

    StatusBar1.Panels[0].text := '[+] Getting DNS ...';
    Form1.StatusBar1.Update;

    ListBox1.Items.Clear;

    rta := IdHTTP1.Get('http://www.ip-adress.com/reverse_ip/' + Edit1.text);

    regex.regex := 'whois\/(.*?)\">Whois';
    regex.Subject := rta;

    while regex.MatchAgain do
    begin
      for z := 1 to regex.GroupCount do
        ListBox1.Items.Add(regex.Groups[z]);
    end;

  end
  else
  begin
    StatusBar1.Panels[0].text := '[-] Error';
    Form1.StatusBar1.Update;
  end;

  StatusBar1.Panels[0].text := '[+] Finished';
  Form1.StatusBar1.Update;

  regex.Free;

end;

end.

// The End ?

Available for download here

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Delphi] LocateIP 0.5
« Reply #1 on: April 04, 2014, 08:33:24 pm »
Not bad, but a command line tool of this would be much more useful...

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: [Delphi] LocateIP 0.5
« Reply #2 on: April 04, 2014, 08:50:19 pm »
Not bad, but a command line tool of this would be much more useful...
Yeah indeed, gui's have there uses but not for this stuff.
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage