马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
经过上一次的改进,已经支持输入自定义密码了。
使用方法和原来一样
原帖:
硬盘逻辑锁 - 只有输入密码硬盘才会被解锁
http://bbs.fishc.com/thread-43343-1-1.html
自动加锁原理:http://bbs.pediy.com/showthread.php?p=1263142
org 0x7c00 ;原MBR内容位于 逻辑3扇区 密码4扇区
;密码加密方式 所有字符ASCLL相加
start:
mov ax,cs
mov ds,ax
mov ss,ax
mov es,ax
mov sp,0x100
mov bx,0
main:
;读取原内容
mov ax,0x7e00
mov ds,ax
mov bx,0
mov dx,0x1f2
mov al,0x01
out dx,al
mov dx,0x1f3
mov al,0x3 ;3扇区
out dx,al
inc dx ;8-15
mov al,0
out dx,al
inc dx ;16-23
out dx,al
inc dx ;24-27
mov al,0xe0
out dx,al
mov dx,0x1f7 ;读命令
mov al,0x20
out dx,al
mov dx,0x1f7
.waits:
in al,dx
and al,0x88
cmp al,0x08
jnz .waits
mov cx,256
mov dx,0x1f0
.read:
in ax,dx
mov [bx],ax
add bx,2
loop .read
;显示字符串
mov bp,msg1
mov cx,msg2-msg1
mov ax,0x1301
mov bx,0x0c
mov dl,0
int 0x10
;检测按键
GetKey:
mov bx,0
mov si,0
GetKey_:
mov ax,0xb800
mov ds,ax
mov ax,0
int 0x16
cmp al,0x1b ;Esc键
je Esc_
cmp al,0x8 ;退格键
je BackSpace
cmp al,0x0d ;回车键
jne GetKey_q
next:
;判断密码
mov cx,si
mov bx,0
mov dx,0
mov si,0
key_js:
mov al,[ds:si]
mov ah,0
add dx,ax
add si,2
loop key_js
mov ax,[cs:y_key]
cmp ax,dx
je Ks
jne Esc_
Esc_:
mov ch,0
mov cl,0x4e
mov al,0x00
mov ah,0x07
mov bx,0
_esc:
mov [bx],ax
add bx,2
loop _esc
mov bx,0
mov si,0
mov [bx],al
mov [bx+1],ah
jmp GetKey
;解除硬盘逻辑锁
Ks:
mov ax,0x7e00
mov ds,ax
mov bx,0
mov dx,0x1f2
mov al,0x01
out dx,al
mov dx,0x1f3
mov al,0x0 ;0扇区
out dx,al
inc dx ;8-15
mov al,0
out dx,al
inc dx ;16-23
out dx,al
inc dx ;24-27
mov al,0xe0
out dx,al
mov dx,0x1f7 ;写命令
mov al,0x30
out dx,al
mov dx,0x1f7
.waits_wr:
in al,dx
and al,0x88
cmp al,0x08
jnz .waits_wr
mov cx,256
mov dx,0x1f0
.write:
mov ax,[bx]
out dx,ax
add bx,2
loop .write
;重启计算机
.REST:
mov ax,0xb800
mov ds,ax
mov bx,0
mov byte [bx],'a'
mov ax,0xffff
push ax
mov ax,0
push ax
retf
GetKey_q:
mov byte [bx],al
add bx,2
inc si
jmp GetKey_
BackSpace:
mov byte [bx],0
sub si,1
sub bx,2
jmp GetKey_
msg1 db 'Please Input Password'
msg2 db '.'
msg3 db '*'
msg4 db 'KeyTag'
y_key dw 0x019E ;密码的ASCLL和 需要替换。
times 510-($-$$) db 0
dw 0xAA55
|