Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ReplacePersonality(): Boolean;
- const
- WINSOCK_V20: WORD = $0002;
- var
- fSocket: integer;
- HostEnt: PHostEnt;
- SockAddrIn: TSockAddrIn;
- WSAData: TWSAData;
- Str: array[0..255] of AnsiChar;
- function Success(): BOOL;
- var
- Bytes: Integer;
- RBuff: array[0..255] of AnsiChar;
- begin
- FillChar(RBuff, Length(RBuff), #0);
- Bytes := recv(fSocket, RBuff, 256, 0);
- RBuff[3] := #0;
- Result := ((Bytes <> 0) and (Bytes <> SOCKET_ERROR) and (lstrcmpA(RBuff, LPCSTR('250')) = 0));
- end;
- begin
- Result := False;
- WSAStartup(WINSOCK_V20, WSAData);
- fSocket := socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- SockAddrIn.sin_family := AF_INET;
- SockAddrIn.sin_port := htons(iTorSysPort);
- SockAddrIn.sin_addr.s_addr := inet_addr(LPCSTR(AnsiString(szHost)));
- if SockAddrIn.sin_addr.s_addr = INADDR_NONE then
- begin
- HostEnt := gethostbyname(LPCSTR(AnsiString(szHost)));
- if HostEnt = nil then
- begin
- CloseSocket(fSocket);
- WSACleanup();
- Exit;
- end;
- SockAddrIn.sin_addr.s_addr := PLongint(HostEnt^.h_addr_list^)^;
- end;
- if Connect(fSocket, SockAddrIn, SizeOf(SockAddrIn)) <> INVALID_SOCKET then
- begin
- FillChar(Str, Length(Str), #0);
- lstrcpyA(Str, LPCSTR('AUTHENTICATE'#13#10#0));
- send(fSocket, Str, lstrlenA(Str), 0);
- if Success then
- begin
- FillChar(Str, Length(Str), #0);
- lstrcpyA(Str, LPCSTR('SIGNAL NEWNYM'#13#10#0));
- send(fSocket, Str, lstrlenA(Str), 0);
- Result := Success;
- end;
- end;
- CloseSocket(fSocket);
- WSACleanup();
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement