ЕК
Size: a a a
ЕК
d
format PE
use32
include 'C:\fasm\INCLUDE\win32ax.inc'
section '.bss' readable writable
HMBR rd 1
buf rb 512
var1 rd 1
count1 rb 1
bytesread rd 1
section '.text' readable executable
entry _start
filename db '\\.\PhysicalDrive0',0
error_read db '[-] Error read MBR',0x0a,0x00
complete_read db '[+] Complete read mbr',0x0a,'[*] MBR: ',0x00,0x0a
msg db '%002X ',0x00
_start:
invoke CreateFile,filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0
test eax,eax
jz error_open
mov dword ptr HMBR,eax
invoke SetFilePointer,HMBR,0x00,0x00,FILE_BEGIN
invoke ReadFile,[HMBR],buf,512,bytesread,0x00
cmp eax,0x00
jnz Comp_read
invoke printf,error_read
jmp near return
Comp_read:
invoke printf,complete_read
cld
lea esi,[buf]
mov bx,512
mov byte ptr count1,0x00
.lp:
lodsb
movzx eax,al
mov dword [var1],eax
cmp byte ptr count1,0x0c
jnz .continue
mov byte ptr count1,0x00
invoke putchar,0x0a
.continue:
inc byte ptr count1
dec bx
mov eax,dword [var1]
cinvoke printf,msg,eax
test bx,bx
jnz .lp
jmp short return
error_open:
jmp short continue
error_open_msg db '[-] Error open PhysicalDriver0',0x0a,0x00
continue:
invoke printf,error_open_msg
return:
invoke CloseHandle,[HMBR]
invoke ExitProcess,0x00
section '.code' import data readable executable
library Kernel32,'Kernel32.dll',\
msvcrt,'msvcrt.dll',\
user32,'user32.dll'
import Kernel32,\
ExitProcess,'ExitProcess',\
CreateFile,'CreateFileA',\
CloseHandle,'CloseHandle',\
ReadFile,'ReadFile',\
WriteFile,'WriteFile',\
SetFilePointer,'SetFilePointer'
import msvcrt,printf,'printf',putchar,'putchar'ЕК
ЕК
test eax,eaxвот!
jz error_open
cmp eax,INVALID_HANDLE_VALUE
je error_open
ЕК
invoke SetFilePointer,HMBR,0x00,0x00,FILE_BEGINздесь тоже
[HMBR] надоЕК
dec ebxэто избыточно (и почему bx?)...
...
test bx,bx
jnz .lp
dec ebx
jnz .lp
ЕК
d
dec ebxэто избыточно (и почему bx?)...
...
test bx,bx
jnz .lp
dec ebx
jnz .lp
ЕК