Foro de elhacker.net

Programación => Programación General => Mensaje iniciado por: BigBear en 18 Octubre 2013, 18:00 pm



Título: [Delphi] DH PasteBin Manager 0.2
Publicado por: BigBear en 18 Octubre 2013, 18:00 pm
Un simple programa en delphi para subir y bajar codigos en pastebin.

Unas imagenes :

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

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

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

Los codigos :

Menu

Código
  1. // DH PasteBin Manager 0.2
  2. // (C) Doddy Hackman 2013
  3.  
  4. unit paste;
  5.  
  6. interface
  7.  
  8. uses
  9.  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  10.  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  11.  IdHTTP, IdMultipartFormData, PerlRegEx, sSkinManager, ComCtrls, sStatusBar,
  12.  sGroupBox, sMemo, sButton, sEdit, sLabel, sListBox, acPNG, ExtCtrls;
  13.  
  14. type
  15.  TForm1 = class(TForm)
  16.    sSkinManager1: TsSkinManager;
  17.    Image1: TImage;
  18.    sGroupBox1: TsGroupBox;
  19.    sButton1: TsButton;
  20.    sButton2: TsButton;
  21.    sButton3: TsButton;
  22.    sButton4: TsButton;
  23.  
  24.    procedure FormCreate(Sender: TObject);
  25.    procedure sButton3Click(Sender: TObject);
  26.    procedure sButton4Click(Sender: TObject);
  27.    procedure sButton1Click(Sender: TObject);
  28.    procedure sButton2Click(Sender: TObject);
  29.  
  30.  private
  31.    { Private declarations }
  32.  public
  33.    { Public declarations }
  34.  end;
  35.  
  36. var
  37.  Form1: TForm1;
  38.  
  39. implementation
  40.  
  41. uses formdown, formup;
  42. {$R *.dfm}
  43.  
  44. procedure TForm1.FormCreate(Sender: TObject);
  45. var
  46.  dir: string;
  47. begin
  48.  
  49.  sSkinManager1.SkinDirectory := ExtractFilePath(Application.ExeName) + 'Data';
  50.  sSkinManager1.SkinName := 'matrix';
  51.  sSkinManager1.Active := True;
  52.  
  53.  dir := ExtractFilePath(Application.ExeName) + '/downloads';
  54.  
  55.  if not(DirectoryExists(dir)) then
  56.  begin
  57.    CreateDir(dir);
  58.  end;
  59.  
  60.  ChDir(dir);
  61.  
  62. end;
  63.  
  64. procedure TForm1.sButton1Click(Sender: TObject);
  65. begin
  66.  Form3.Show;
  67. end;
  68.  
  69. procedure TForm1.sButton2Click(Sender: TObject);
  70. begin
  71.  Form2.Show;
  72. end;
  73.  
  74. procedure TForm1.sButton3Click(Sender: TObject);
  75. begin
  76.  ShowMessage('Contact to lepuke[at]hotmail[com]');
  77. end;
  78.  
  79. procedure TForm1.sButton4Click(Sender: TObject);
  80. begin
  81.  Form1.Close();
  82. end;
  83.  
  84. end.
  85.  
  86. // The End ?
  87.  

Uploader

Código
  1. // DH PasteBin Manager 0.2
  2. // (C) Doddy Hackman 2013
  3.  
  4. unit formup;
  5.  
  6. interface
  7.  
  8. uses
  9.  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  10.  Dialogs, StdCtrls, sButton, sEdit, sLabel, sGroupBox, acPNG, ExtCtrls,
  11.  ComCtrls, sStatusBar, PerlRegEx, IdBaseComponent, IdComponent,
  12.  IdTCPConnection, IdTCPClient, IdHTTP, IdMultipartFormData, sMemo;
  13.  
  14. type
  15.  TForm3 = class(TForm)
  16.    sGroupBox4: TsGroupBox;
  17.    sLabel3: TsLabel;
  18.    sLabel4: TsLabel;
  19.    sEdit3: TsEdit;
  20.    sEdit4: TsEdit;
  21.    sGroupBox5: TsGroupBox;
  22.    sButton3: TsButton;
  23.    sButton4: TsButton;
  24.    sButton5: TsButton;
  25.    Image1: TImage;
  26.    sStatusBar1: TsStatusBar;
  27.    OpenDialog1: TOpenDialog;
  28.    IdHTTP1: TIdHTTP;
  29.    PerlRegEx1: TPerlRegEx;
  30.    sMemo1: TsMemo;
  31.    procedure sButton4Click(Sender: TObject);
  32.    procedure sButton5Click(Sender: TObject);
  33.    procedure sButton3Click(Sender: TObject);
  34.  private
  35.    { Private declarations }
  36.  public
  37.    { Public declarations }
  38.  end;
  39.  
  40. var
  41.  Form3: TForm3;
  42.  
  43. implementation
  44.  
  45. {$R *.dfm}
  46.  
  47. procedure TForm3.sButton3Click(Sender: TObject);
  48. var
  49.  datos: TIdMultiPartFormDataStream;
  50.  code: string;
  51.  titulo: string;
  52.  contenido: string;
  53.  
  54.  archivo: TextFile;
  55.  texto: string;
  56.  
  57. begin
  58.  
  59.  titulo := ExtractFileName(sEdit3.Text);
  60.  
  61.  sMemo1.Lines.Clear;
  62.  
  63.  AssignFile(archivo, sEdit3.Text);
  64.  Reset(archivo);
  65.  
  66.  while not Eof(archivo) do
  67.  begin
  68.    ReadLn(archivo, texto);
  69.    sMemo1.Lines.Add(texto);
  70.  end;
  71.  
  72.  CloseFile(archivo);
  73.  
  74.  contenido := sMemo1.Lines.Text;
  75.  
  76.  datos := TIdMultiPartFormDataStream.Create;
  77.  
  78.  datos.AddFormField('api_dev_key', 'fuck you');
  79.  datos.AddFormField('api_option', 'paste');
  80.  datos.AddFormField('api_paste_name', titulo);
  81.  datos.AddFormField('api_paste_code', contenido);
  82.  
  83.  sStatusBar1.Panels[0].Text := '[+] Uploading ...';
  84.  Form3.sStatusBar1.Update;
  85.  
  86.  code := IdHTTP1.Post('http://pastebin.com/api/api_post.php', datos);
  87.  
  88.  PerlRegEx1.Regex := 'pastebin';
  89.  PerlRegEx1.Subject := code;
  90.  
  91.  if PerlRegEx1.Match then
  92.  begin
  93.    sStatusBar1.Panels[0].Text := '[+] Done';
  94.    Form3.sStatusBar1.Update;
  95.    sEdit4.Text := code;
  96.  end
  97.  else
  98.  begin
  99.    sStatusBar1.Panels[0].Text := '[-] Error Uploading';
  100.    Form3.sStatusBar1.Update;
  101.  end;
  102.  
  103. end;
  104.  
  105. procedure TForm3.sButton4Click(Sender: TObject);
  106. begin
  107.  OpenDialog1.InitialDir := GetCurrentDir;
  108.  
  109.  if OpenDialog1.Execute then
  110.  begin
  111.    sEdit3.Text := OpenDialog1.FileName;
  112.  end;
  113.  
  114. end;
  115.  
  116. procedure TForm3.sButton5Click(Sender: TObject);
  117. begin
  118.  sEdit4.SelectAll;
  119.  sEdit4.CopyToClipboard;
  120. end;
  121.  
  122. end.
  123.  
  124. // The End ?
  125.  

El downloader.

Código
  1. // DH PasteBin Manager 0.2
  2. // (C) Doddy Hackman 2013
  3.  
  4. unit formdown;
  5.  
  6. interface
  7.  
  8. uses
  9.  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  10.  Dialogs, StdCtrls, sListBox, sButton, sEdit, sLabel, sGroupBox, PerlRegEx,
  11.  IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, acPNG,
  12.  ExtCtrls, ComCtrls, sStatusBar, sMemo, acProgressBar;
  13.  
  14. type
  15.  TForm2 = class(TForm)
  16.    sGroupBox1: TsGroupBox;
  17.    sGroupBox2: TsGroupBox;
  18.    sLabel1: TsLabel;
  19.    sLabel2: TsLabel;
  20.    sEdit1: TsEdit;
  21.    sEdit2: TsEdit;
  22.    sButton1: TsButton;
  23.    sGroupBox3: TsGroupBox;
  24.    sListBox1: TsListBox;
  25.    sButton2: TsButton;
  26.    IdHTTP1: TIdHTTP;
  27.    PerlRegEx1: TPerlRegEx;
  28.    PerlRegEx2: TPerlRegEx;
  29.    Image1: TImage;
  30.    sStatusBar1: TsStatusBar;
  31.    sProgressBar1: TsProgressBar;
  32.  
  33.    procedure sButton1Click(Sender: TObject);
  34.    procedure sButton2Click(Sender: TObject);
  35.    procedure IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
  36.      AWorkCount: Int64);
  37.    procedure IdHTTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
  38.      AWorkCountMax: Int64);
  39.    procedure IdHTTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
  40.  private
  41.    { Private declarations }
  42.  public
  43.    { Public declarations }
  44.  end;
  45.  
  46. var
  47.  Form2: TForm2;
  48.  
  49. implementation
  50.  
  51. {$R *.dfm}
  52.  
  53. procedure TForm2.IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
  54.  AWorkCount: Int64);
  55. begin
  56.  sProgressBar1.Position := AWorkCount;
  57.  sStatusBar1.Panels[0].Text := '[+] Downloading ...';
  58.  Form2.sStatusBar1.Update;
  59. end;
  60.  
  61. procedure TForm2.IdHTTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
  62.  AWorkCountMax: Int64);
  63. begin
  64.  sProgressBar1.Max := AWorkCountMax;
  65.  sStatusBar1.Panels[0].Text := '[+] Starting download ...';
  66.  Form2.sStatusBar1.Update;
  67. end;
  68.  
  69. procedure TForm2.IdHTTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
  70. begin
  71.  sProgressBar1.Position := 0;
  72.  sStatusBar1.Panels[0].Text := '[+] Finished';
  73.  Form2.sStatusBar1.Update;
  74. end;
  75.  
  76. procedure TForm2.sButton1Click(Sender: TObject);
  77. var
  78.  url: string;
  79.  url2: string;
  80.  code: string;
  81.  i: integer;
  82.  viendo: string;
  83.  chau: TStringList;
  84.  
  85. begin
  86.  //
  87.  
  88.  chau := TStringList.Create;
  89.  
  90.  chau.Duplicates := dupIgnore;
  91.  chau.Sorted := True;
  92.  chau.Assign(sListBox1.Items);
  93.  sListBox1.Items.Clear;
  94.  sListBox1.Items.Assign(chau);
  95.  
  96.  url := sEdit1.Text;
  97.  url2 := sEdit2.Text;
  98.  
  99.  if not(url = '') then
  100.  begin
  101.    PerlRegEx1.Regex := 'pastebin';
  102.    PerlRegEx1.Subject := url;
  103.  
  104.    if PerlRegEx1.Match then
  105.    begin
  106.      sListBox1.Items.Add(url);
  107.    end;
  108.  end;
  109.  
  110.  if not(url2 = '') then
  111.  begin
  112.  
  113.    code := IdHTTP1.Get(url2);
  114.  
  115.    PerlRegEx1.Regex := '(.)(http://.+?)\1';
  116.    PerlRegEx1.Subject := code;
  117.  
  118.    while PerlRegEx1.MatchAgain do
  119.    begin
  120.      for i := 1 to PerlRegEx1.SubExpressionCount do
  121.      begin
  122.        viendo := PerlRegEx1.SubExpressions[i];
  123.  
  124.        PerlRegEx2.Regex := 'pastebin';
  125.        PerlRegEx2.Subject := viendo;
  126.  
  127.        if PerlRegEx2.Match then
  128.        begin
  129.          sListBox1.Items.Add(viendo);
  130.        end;
  131.      end;
  132.    end;
  133.  
  134.  end;
  135.  
  136. end;
  137.  
  138. procedure TForm2.sButton2Click(Sender: TObject);
  139. var
  140.  url: string;
  141.  urlabajar: string;
  142.  id: string;
  143.  code: string;
  144.  titulo: string;
  145.  i: integer;
  146.  archivobajado: TFileStream;
  147. begin
  148.  
  149.  for i := sListBox1.Items.Count - 1 downto 0 do
  150.  begin
  151.  
  152.    //
  153.  
  154.    url := sListBox1.Items[i];
  155.  
  156.    PerlRegEx1.Regex := 'http:\/\/(.*)\/(.*)';
  157.    PerlRegEx1.Subject := url;
  158.  
  159.    if PerlRegEx1.Match then
  160.    begin
  161.  
  162.      urlabajar :=
  163.        'http://pastebin.com/download.php?i=' + PerlRegEx1.SubExpressions[2];
  164.      // sMemo1.Lines.Add(urlabajar);
  165.  
  166.      code := IdHTTP1.Get(url);
  167.  
  168.      PerlRegEx2.Regex := '<div class="paste_box_line1" title="(.*)">';
  169.      PerlRegEx2.Subject := code;
  170.  
  171.      if PerlRegEx2.Match then
  172.      begin
  173.        titulo := PerlRegEx2.SubExpressions[1];
  174.        // sMemo1.Lines.Add(titulo);
  175.  
  176.        // Baja esto carajo
  177.  
  178.        // sStatusBar1.Panels[0].Text := '[+] Downloading :' + urlabajar;
  179.        // Form2.sStatusBar1.Update;
  180.  
  181.        archivobajado := TFileStream.Create(titulo + '.txt', fmCreate);
  182.  
  183.        try
  184.          begin
  185.            DeleteFile(titulo);
  186.            IdHTTP1.Get(urlabajar, archivobajado);
  187.            sStatusBar1.Panels[0].Text := '[+] File Dowloaded';
  188.            Form2.sStatusBar1.Update;
  189.            archivobajado.Free;
  190.          end;
  191.        except
  192.          sStatusBar1.Panels[0].Text := '[-] Failed download';
  193.          Form2.sStatusBar1.Update;
  194.          archivobajado.Free;
  195.          Abort;
  196.        end;
  197.  
  198.  
  199.        //
  200.  
  201.      end;
  202.  
  203.    end;
  204.  
  205.  
  206.  
  207.    //
  208.  
  209.  end;
  210.  
  211.  sStatusBar1.Panels[0].Text := '[+] Done';
  212.  Form2.sStatusBar1.Update;
  213.  
  214. end;
  215.  
  216. end.
  217.  
  218. // The End ?
  219.  

Si quieren bajar el proyecto y el ejecutable lo pueden hacer de aca (https://sourceforge.net/p/dhpastebinmanager/).