Foro de elhacker.net

Programación => Programación General => Mensaje iniciado por: BigBear en 25 Abril 2013, 22:46 pm



Título: [Delphi] LocateIP 0.1
Publicado por: BigBear en 25 Abril 2013, 22:46 pm
Traduccion a Delphi de este programa para localizar una IP.

Una imagen :

(http://doddyhackman.webcindario.com/images/locateipdelphi.jpg)

El codigo :

Código
  1. // LocateIP 0.1
  2. // Coded By Doddy H in the year 2013
  3. // Based on the services :
  4. // To get IP -- http://whatismyipaddress.com/
  5. // To locate IP -- http://www.melissadata.com/
  6. // To get DNS -- http://www.ip-adress.com/
  7.  
  8. unit locateip;
  9.  
  10. interface
  11.  
  12. uses
  13.  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  14.  Dialogs, sSkinManager, jpeg, ExtCtrls, StdCtrls, sLabel, sGroupBox, sButton,
  15.  sEdit, sListBox, ComCtrls, sStatusBar, IdBaseComponent, IdComponent,
  16.  IdTCPConnection, IdTCPClient, IdHTTP, PerlRegEx, IdMultipartFormData;
  17.  
  18. type
  19.  TForm1 = class(TForm)
  20.    sSkinManager1: TsSkinManager;
  21.    Image1: TImage;
  22.    sGroupBox1: TsGroupBox;
  23.    sLabel1: TsLabel;
  24.    sEdit1: TsEdit;
  25.    sButton1: TsButton;
  26.    sGroupBox2: TsGroupBox;
  27.    sLabel2: TsLabel;
  28.    sEdit2: TsEdit;
  29.    sLabel3: TsLabel;
  30.    sEdit3: TsEdit;
  31.    sLabel4: TsLabel;
  32.    sEdit4: TsEdit;
  33.    sGroupBox3: TsGroupBox;
  34.    sListBox1: TsListBox;
  35.    PerlRegEx1: TPerlRegEx;
  36.    IdHTTP1: TIdHTTP;
  37.    sStatusBar1: TsStatusBar;
  38.    procedure sButton1Click(Sender: TObject);
  39.    procedure FormCreate(Sender: TObject);
  40.  
  41.  private
  42.    { Private declarations }
  43.  public
  44.    { Public declarations }
  45.  end;
  46.  
  47. var
  48.  Form1: TForm1;
  49.  
  50. implementation
  51.  
  52. {$R *.dfm}
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. begin
  56.  sSkinManager1.SkinDirectory := ExtractFilePath(Application.ExeName) + 'Data';
  57.  sSkinManager1.SkinName := 'matrix';
  58.  sSkinManager1.Active := True;
  59. end;
  60.  
  61. procedure TForm1.sButton1Click(Sender: TObject);
  62. var
  63.  rta: string;
  64.  z: integer;
  65.  par: TIdMultiPartFormDataStream;
  66. begin
  67.  
  68.  if sEdit1.text = '' then
  69.  begin
  70.    ShowMessage('Write the target');
  71.  end
  72.  else
  73.  begin
  74.    sStatusBar1.Panels[0].text := '[+] Getting IP ...';
  75.    Form1.sStatusBar1.Update;
  76.  
  77.    par := TIdMultiPartFormDataStream.Create;
  78.    par.AddFormField('DOMAINNAME', sEdit1.text);
  79.  
  80.    rta := IdHTTP1.Post('http://whatismyipaddress.com/hostname-ip', par);
  81.  
  82.    PerlRegEx1.Regex := 'Lookup IP Address: <a href=(.*)>(.*)<\/a>';
  83.    PerlRegEx1.Subject := rta;
  84.  
  85.    if PerlRegEx1.Match then
  86.    begin
  87.      sEdit1.text := PerlRegEx1.SubExpressions[2];
  88.  
  89.      // Locating ...
  90.  
  91.      sStatusBar1.Panels[0].text := '[+] Locating ...';
  92.      Form1.sStatusBar1.Update;
  93.  
  94.      rta := IdHTTP1.Get(
  95.        'http://www.melissadata.com/lookups/iplocation.asp?ipaddress=' +
  96.          sEdit1.text);
  97.  
  98.      PerlRegEx1.Regex := 'City<\/td><td align=(.*)><b>(.*)<\/b><\/td>';
  99.      PerlRegEx1.Subject := rta;
  100.  
  101.      if PerlRegEx1.Match then
  102.      begin
  103.        sEdit2.text := PerlRegEx1.SubExpressions[2];
  104.      end
  105.      else
  106.      begin
  107.        sEdit2.text := 'Not Found';
  108.      end;
  109.  
  110.      PerlRegEx1.Regex := 'Country<\/td><td align=(.*)><b>(.*)<\/b><\/td>';
  111.      PerlRegEx1.Subject := rta;
  112.  
  113.      if PerlRegEx1.Match then
  114.      begin
  115.        sEdit3.text := PerlRegEx1.SubExpressions[2];
  116.      end
  117.      else
  118.      begin
  119.        sEdit3.text := 'Not Found';
  120.      end;
  121.  
  122.      PerlRegEx1.Regex :=
  123.        'State or Region<\/td><td align=(.*)><b>(.*)<\/b><\/td>';
  124.      PerlRegEx1.Subject := rta;
  125.  
  126.      if PerlRegEx1.Match then
  127.      begin
  128.        sEdit4.text := PerlRegEx1.SubExpressions[2];
  129.      end
  130.      else
  131.      begin
  132.        sEdit4.text := 'Not Found';
  133.      end;
  134.  
  135.      //
  136.  
  137.      // Get DNS
  138.  
  139.      sStatusBar1.Panels[0].text := '[+] Getting DNS ...';
  140.      Form1.sStatusBar1.Update;
  141.  
  142.      sListBox1.Items.Clear;
  143.  
  144.      rta := IdHTTP1.Get('http://www.ip-adress.com/reverse_ip/' + sEdit1.text);
  145.  
  146.      PerlRegEx1.Regex := 'whois\/(.*?)\">Whois';
  147.      PerlRegEx1.Subject := rta;
  148.  
  149.      while PerlRegEx1.MatchAgain do
  150.      begin
  151.        for z := 1 to PerlRegEx1.SubExpressionCount do
  152.          sListBox1.Items.Add(PerlRegEx1.SubExpressions[z]);
  153.      end;
  154.  
  155.      //
  156.  
  157.    end
  158.    else
  159.    begin
  160.      sStatusBar1.Panels[0].text := '[-] Error';
  161.      Form1.sStatusBar1.Update;
  162.    end;
  163.  
  164.    sStatusBar1.Panels[0].text := '';
  165.    Form1.sStatusBar1.Update;
  166.  
  167.  end;
  168. end;
  169.  
  170. end.
  171.  
  172. // The End ?
  173.  

Si lo quieren bajar lo pueden hacer de aca (https://sourceforge.net/projects/locateipx/).



Título: Re: [Delphi] LocateIP 0.1
Publicado por: WarZ0n3 en 26 Abril 2013, 07:47 am
Saludos colega!.
Bueno debo decir que me gusta mucho tu codigo, y que es bueno ver que hay mas programadores de pascal...
Mi pregunta es la siguiente, ¿no seria mejor hacerlo con el API Wininet?
Ya que las indys son muy buenas pero nunca como hacerlo con un api. Y sin limitaciones, Saludos!  ;-)


Título: Re: [Delphi] LocateIP 0.1
Publicado por: BigBear en 3 Mayo 2013, 19:07 pm
no le eh intentado con el API , pero usar indy me parece facil.



Título: Re: [Delphi] LocateIP 0.1
Publicado por: Bomb-P en 10 Mayo 2013, 04:30 am
Man eres mi idolo!!!
Y mi objetio ahora es superarte :)
jajajaj ;D


Salu2  ;)


Título: Re: [Delphi] LocateIP 0.1
Publicado por: BigBear en 12 Mayo 2013, 15:13 pm
no creo que sea dificil superarme.

parece que a softpedia le intereso este programa porque lo publicaron  aca (http://www.softpedia.es/mas-programas-de-Doddy-Hackman-94358.html).


Título: Re: [Delphi] LocateIP 0.1
Publicado por: 0xFer en 12 Mayo 2013, 21:35 pm
Algún día publicaran también mis programas xDD  :D

Doddy yo también te quiero superar brou

por cierto publique en este foro el GMail Bomber que hice, pero lo borraron por que es bastante malévolo jaja xDD