Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Trang 2 của 2 Đầu tiênĐầu tiên 12
Kết quả 11 đến 18 của 18
  1. #11
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Sẵn tiện cho mình hỏi. Có bạn nào hook được các gói dữ liệu trong WinSock (MSWINSCK.OCX) không (Xác định dữ liệu bên trong các gói và replace). Bên madshi.net có bàn về vấn đề này nhưng code nó viết = Dephi đọc ko hiểu gì cả

  2. #12
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    mấy hôm trước có thử hook hàm send() để bắt dữ liệu. Dữ liệu của hàm send() và recv() là kiểu char* mà bạn có thể chỉnh sửa được chứ
    int send(Socket s, char* Buf, int len,int flag) nếu chỉ replace bạn chỉ cần sửa cái Buf nếu mà chỉnh sửa mà kích thước gói tin thay đổi bạn phải sửa cái len nữa, với hàm recv cũng tương tự vậy. Đây là 2 hàm để nhận và gửi dữ liệu với giao thức tcp.

  3. #13
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi sovietw0rm
    mấy hôm trước có thử hook hàm send() để bắt dữ liệu. Dữ liệu của hàm send() và recv() là kiểu char* mà bạn có thể chỉnh sửa được chứ
    int send(Socket s, char* Buf, int len,int flag) nếu chỉ replace bạn chỉ cần sửa cái Buf nếu mà chỉnh sửa mà kích thước gói tin thay đổi bạn phải sửa cái len nữa, với hàm recv cũng tương tự vậy. Đây là 2 hàm để nhận và gửi dữ liệu với giao thức tcp.
    dữ liệu của nó còn được mã hóa cơ mà bạn,muốn sửa trước hết phải decode nó đã

  4. #14
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    nếu nó dùng ssl thì khác còn nếu bình thường có mã hóa gì đâu?

  5. #15
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    có ví dụ nè. Nhưng viết bằng Delphi


    Mã:
      Delphi Winsock Hooking Example by Aphex  {   Delphi Winsock Hooking Example by Aphex   http://www.iamaphex.cjb.net   unremote@knology.net   This example shows you how to hook winsock functions   of a target process and control incomming and outgoing   data. It is based on send and recv but it will work the   same way applied to sendto and recvfrom.   The output file is a CPL (Control Panel Extension) which   is simply a special DLL that is loaded when it is double   clicked. This saves us from having to write a seperate   loader for the hook library.   The example shows how to hook the needed functions and   perform some simple manipulation of the data, using two   different methods of accessing the data. The second, which   uses pointers, is more flexible but also more complex.  }  library Project1;  uses   Windows,   Winsock,   SysUtils,   madCodeHook;  {$R *.RES}  {$E CPL}  var   sendNextHook: function(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;   recvNextHook: function(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;   DataSocket: TSocket;  const   szTargetExe: string = 'GAME.EXE';  function ConvertDataToAscii(Buffer: pointer; Length: Word): string;  var   Iterator: integer;   AsciiBuffer: string;  begin   AsciiBuffer := '';   for Iterator := 0 to Length - 1 do   begin   if char(pointer(integer(Buffer) + Iterator)^) in [#32..#127] then   AsciiBuffer := AsciiBuffer + ' ' + char(pointer(integer(Buffer) + Iterator)^) + ' '   else   AsciiBuffer := AsciiBuffer + ' . ';   end;   Result := AsciiBuffer;  end;  function ConvertDataToHex(Buffer: pointer; Length: Word): string;  var   Iterator: integer;   HexBuffer: string;  begin   HexBuffer := '';   for Iterator := 0 to Length - 1 do   begin   HexBuffer := HexBuffer + IntToHex(Ord(char(pointer(integer(Buffer) + Iterator)^)), 2) + ' ';   end;   Result := HexBuffer;  end;  function recvHookProc(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;  var   AsciiBuffer: string;   HexBuffer: string;   DataBuffer: pchar;  begin   //call the real winsock function   Result := recvNextHook(s, Buf, len, flags);   //allocate memory for our copy of the data   GetMem(DataBuffer, Result);   try   //get our copy of the data   CopyMemory(DataBuffer, @Buf, Result);   //using the data as a byte array   DataBuffer[0] := chr(10); //changing first byte   DataBuffer[1] := chr(20); //changing second byte   DataBuffer[2] := chr(30); //changing thrid byte   //using the data as a pointer to other data sizes   word(pointer(DataBuffer)^) := 10; //changing first 2 bytes   dword(pointer(integer(DataBuffer) + 2)^) := 20; //changing next 4 bytes   word(pointer(integer(DataBuffer) + 6)^) := 30; //changing next 2 bytes   //overwrite the original data with our new data   CopyMemory(@Buf, DataBuffer, Result);   finally   FreeMem(DataBuffer);   end;   //convert data to readable ascii suitable for logging   AsciiBuffer := ConvertDataToAscii(@Buf, Result);   //convert data to readable hex suitable for logging   HexBuffer := ConvertDataToHex(@Buf, Result);  end;  function sendHookProc(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;  var   AsciiBuffer: string;   HexBuffer: string;   DataBuffer: pchar;  begin   Result := 0;   //save the socket so we can send data too   DataSocket := s;   //allocate memory for our copy of the data   GetMem(DataBuffer, Result);   try   //get our copy of the data   CopyMemory(DataBuffer, @Buf, Result);   //using the data as a byte array   DataBuffer[0] := chr(10); //changing first byte   DataBuffer[1] := chr(20); //changing second byte   DataBuffer[2] := chr(30); //changing thrid byte   //using the data as a pointer to other data sizes   word(pointer(DataBuffer)^) := 10; //changing first 2 bytes   dword(pointer(integer(DataBuffer) + 2)^) := 20; //changing next 4 bytes   word(pointer(integer(DataBuffer) + 6)^) := 30; //changing next 2 bytes   //overwrite the original data with our new data   CopyMemory(@Buf, DataBuffer, Result);   finally   FreeMem(DataBuffer);   end;   //convert data to readable ascii suitable for logging   AsciiBuffer := ConvertDataToAscii(@Buf, Result);   //convert data to readable hex suitable for logging   HexBuffer := ConvertDataToHex(@Buf, Result);   //call the real winsock function   Result := sendNextHook(s, Buf, len, flags);  end;  procedure EntryPoint(Reason: dword); stdcall;  var   lpFileName: array [0..MAX_PATH - 1] of char;   StartInfo: TStartupInfo;   ProcInfo: TProcessInformation;  begin   if Reason = DLL_PROCESS_ATTACH then   begin   //check if we are injected inside the target   if lstrcmpi(pchar(Copy(ParamStr(0), Length(ParamStr(0)) - Length(szTargetExe) + 1, Length(szTargetExe))), pchar(szTargetExe)) = 0 then   begin   //if we are then we hook the needed functions   DataSocket := 0;   HookCode(@send, @sendHookProc, @sendNextHook);   HookCode(@recv, @recvHookProc, @recvNextHook);   end   else   begin   //if not then load the target and inject ourself   GetModuleFileName(hInstance, @lpFileName, MAX_PATH);   ZeroMemory(@StartInfo, SizeOf(TStartupInfo));   ZeroMemory(@ProcInfo, SizeOf(TProcessInformation));   StartInfo.dwFlags := STARTF_USESHOWWINDOW;   StartInfo.wShowWindow := SW_SHOW;   CreateProcess(PChar(ExtractFilePath(lpFileName) + szTargetExe), nil, nil, nil, False, 0, nil, nil, StartInfo, ProcInfo);   Sleep(3000);   InjectLibrary(ProcInfo.hProcess, lpFileName);   end;   end;  end;  begin   DLLProc := @EntryPoint;   EntryPoint(DLL_PROCESS_ATTACH);  end.

  6. #16
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    như conficker nó chặn 3 hàm sau
    DnsQuery_A--> chặn vào các trang web tên miền virus,ms...
    DnsQuery_UTF8--> chặn vào các trang web tên miền virus,ms...
    DnsQuery_W--> chặn vào các trang web tên miền virus,ms...

  7. #17
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Anh AlexF có thể share code C++ được không ak.
    Em mới bắt đầu nghiên cứu nên không dành lắm

  8. #18
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Chuẩn luôn [IMG]images/smilies/opacli.gif[/IMG][IMG]images/smilies/opacli.gif[/IMG], có đợt mình thử hook mấy hàm kia thì ko ngon, nhưng sau hook mấy hàm DnsQuery thì được hết. gethostbyname cũng đi qua bạn này.

    Trích dẫn Gửi bởi RadiRadic
    như conficker nó chặn 3 hàm sau
    DnsQuery_A--> chặn vào các trang web tên miền virus,ms...
    DnsQuery_UTF8--> chặn vào các trang web tên miền virus,ms...
    DnsQuery_W--> chặn vào các trang web tên miền virus,ms...

 

 
Trang 2 của 2 Đầu tiênĐầu tiên 12

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •