Advertisement
HEX0x29A

TOR+NewPerson

Sep 3rd, 2018 (edited)
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.56 KB | None | 0 0
  1. function ReplacePersonality(): Boolean;
  2. const
  3.   WINSOCK_V20: WORD = $0002;
  4. var
  5.   fSocket: integer;
  6.   HostEnt: PHostEnt;
  7.   SockAddrIn: TSockAddrIn;
  8.   WSAData: TWSAData;
  9.   Str: array[0..255] of AnsiChar;
  10.  
  11.   function Success(): BOOL;
  12.   var
  13.     Bytes: Integer;
  14.     RBuff: array[0..255] of AnsiChar;
  15.   begin
  16.     FillChar(RBuff, Length(RBuff), #0);
  17.     Bytes := recv(fSocket, RBuff, 256, 0);
  18.     RBuff[3] := #0;
  19.     Result := ((Bytes <> 0) and (Bytes <> SOCKET_ERROR) and (lstrcmpA(RBuff, LPCSTR('250')) = 0));
  20.   end;
  21.  
  22. begin
  23.   Result := False;
  24.   WSAStartup(WINSOCK_V20, WSAData);
  25.   fSocket := socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  26.   SockAddrIn.sin_family := AF_INET;
  27.   SockAddrIn.sin_port := htons(iTorSysPort);
  28.   SockAddrIn.sin_addr.s_addr := inet_addr(LPCSTR(AnsiString(szHost)));
  29.   if SockAddrIn.sin_addr.s_addr = INADDR_NONE then
  30.   begin
  31.     HostEnt := gethostbyname(LPCSTR(AnsiString(szHost)));
  32.     if HostEnt = nil then
  33.     begin
  34.       CloseSocket(fSocket);
  35.       WSACleanup();
  36.       Exit;
  37.     end;
  38.     SockAddrIn.sin_addr.s_addr := PLongint(HostEnt^.h_addr_list^)^;
  39.   end;
  40.   if Connect(fSocket, SockAddrIn, SizeOf(SockAddrIn)) <> INVALID_SOCKET then
  41.   begin
  42.     FillChar(Str, Length(Str), #0);
  43.     lstrcpyA(Str, LPCSTR('AUTHENTICATE'#13#10#0));
  44.     send(fSocket, Str, lstrlenA(Str), 0);
  45.     if Success then
  46.     begin
  47.       FillChar(Str, Length(Str), #0);
  48.       lstrcpyA(Str, LPCSTR('SIGNAL NEWNYM'#13#10#0));
  49.       send(fSocket, Str, lstrlenA(Str), 0);
  50.       Result := Success;
  51.     end;
  52.   end;
  53.   CloseSocket(fSocket);
  54.   WSACleanup();
  55. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement