TOR + Delphi и нафиг нам прокси

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by ky_kask, 10 May 2014.

  1. ky_kask

    ky_kask Member

    Joined:
    18 Nov 2009
    Messages:
    73
    Likes Received:
    81
    Reputations:
    6
    TOR + Delphi + Synapse и нафиг нам прокси

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,Tlhelp32,shellapi,blckSock,httpsend,ExtCtrls,IdTCPClient;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    httpsend:Thttpsend; x,x2,my_dir:string; Data:TStringStream;
    implementation
    
    {$R *.dfm}
    procedure TorChangeIP(AHost: string; APort: integer);
      const ErrMsg = 'Tor ChangeIP Error: ';
      var tcp: TIdTCPClient;
    begin
      tcp:=TIdTCPClient.Create(nil);
      try
        tcp.Host:=AHost;
        tcp.Port:=APort;
        tcp.Connect;
        try
          tcp.SendCmd('AUTHENTICATE',-1);
          if tcp.LastCmdResult.TextCode<>'250' then
            raise Exception.Create(ErrMsg+tcp.LastCmdResult.TextCode);
          tcp.SendCmd('SIGNAL NEWNYM',-1);
          if tcp.LastCmdResult.TextCode <>'250' then
            raise Exception.Create(ErrMsg+tcp.LastCmdResult.TextCode);
        finally
          tcp.Disconnect;
        end;
      finally
        tcp.Free;
      end;
    end;
    
    
    
    
    function KillTask(ExeFileName: string): Integer; 
    const 
      PROCESS_TERMINATE = $0001; 
    var
      ContinueLoop: BOOL; 
      FSnapshotHandle: THandle; 
      FProcessEntry32: TProcessEntry32; 
    begin 
      Result := 0; 
      FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
      FProcessEntry32.dwSize := SizeOf(FProcessEntry32); 
      ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32); 
    
      while Integer(ContinueLoop) <> 0 do
      begin 
        if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
          UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = 
          UpperCase(ExeFileName))) then 
          Result := Integer(TerminateProcess(
                            OpenProcess(PROCESS_TERMINATE,
                                        BOOL(0),
                                        FProcessEntry32.th32ProcessID),
                                        0));
         ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
      end;
      CloseHandle(FSnapshotHandle);
    end;
    
    
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    TorChangeIP('127.0.0.1',9051);
    
    
    
    httpsend:=Thttpsend.Create;
    httpsend.Sock.SocksIP:='127.0.0.1';
    httpsend.Sock.SocksPort:='9050';
    httpsend.Sock.SocksType:=ST_Socks4;
    httpsend.Sock.SocksResolver:=false;
    
    HTTPSend.HTTPMethod('GET','http://www.ip-ping.ru/');
    Data:=TStringStream.Create('');
    httpsend.Document.SaveToStream(data);
    x:=Data.DataString;
    Data.Free;
    httpsend.free;
    Delete(x,1,pos('<div class="hc2">',x)+16);
    x2:=copy(x,1,pos('<',x)-1);
    Memo1.Text:=x2;
    
    end;
    
    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
    KillTask('tor.exe');
    
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    my_dir:=ExtractFilePath(ParamStr(0));
    ShellExecute(1, 'open',pchar(my_dir+'\tor.exe') , 'sockslistenaddress localhost socksport 9050 controlport 9051', nil, SW_HIDE);
    
    end;
    
    end.
    
    
     
    #1 ky_kask, 10 May 2014
    Last edited: 10 May 2014
    Invocker49 likes this.
  2. Invocker49

    Invocker49 New Member

    Joined:
    12 Apr 2018
    Messages:
    1
    Likes Received:
    0
    Reputations:
    0
    Thank you Mr : work good when have http but in https not work , how do it ? and how can get respence from post method ,Good work
     
  3. vasykas

    vasykas Banned

    Joined:
    7 Mar 2011
    Messages:
    963
    Likes Received:
    137
    Reputations:
    37
    http_s://pastebin.com/zBhJQJer