硬碟加密--解析二 (轉)

worldblog發表於2007-12-13
硬碟加密--解析二 (轉)[@more@]

在對主開機記錄熟悉之後,就可以編出很多種硬碟(完全取決於你自已的需要),隨著硬碟容量越來越大,其實我們可以將硬碟分為兩個盤,一個是C盤,一個是D盤,平時將C盤重要的複製至D盤,並將D盤加鎖,這樣當C盤受到破壞時,就可以解鎖D盤,將D盤上的檔案恢復過來,我下面的程式就是以這一原理來編寫的,請看程式碼:
Announcement:You can use any editor to edit codes,such as Notepad,QE,Edit and so on.
Source Codes:
  data segment
  FQB 512 dup(0);To define a buffer,which will be used to store harddisk's MBR
  MESSAGE1 DB 0DH,0AH,"C------------LOCK C"
  DB 0DH,0AH,"D------------LOCK D"
  DB 0DH,0AH,"E------------Exit"
  DB 0DH,0AH,"Enter your ion!$"
  MESSAGE2 DB 0DH,0AH,"OK!$"
  MESSAGE3 DB "NOT FOUND DRIVE D!$"
  ERROR  DB "ENTER ERROR!$"
  IOERROR  DB "HARDDISK I/O ERROR!$"
  CXD  DW 0
  data ends
  stack segment
  DB 512 dup(0)
  stack ends
  code segment
  assume cs:code,ds:data,ss:stack
  START:
  mov AX,0201
  mov BX,OFFSET FQB
  mov CX,0001
  mov CXD,CX
  mov DX,0080
  INT 13;Read Main Boot Record,which is in 0 Header,0 Cylinder,1 Sector
  JB ERR
  MOV DX,OFFSET MESS1
  MOV AH,9
  INT 21
  AA0: ;Accept user's enter
  MOV AH,1
  INT 21 
  CMP AL,'E';Exit
  JZ EXIT
  CMP AL,'e';Exit
  JZ EXIT
  CMP AL,'C';Lock Drive C
  JZ LockC
  CMP AL,'c';Lock Drive C
  JZ LockC
  CMP AL,'D'
  JZ LockD;//Lock Drive D
  CMP AL,'d'
  JZ LockD;//Lock Drive D
  LEA DX,ERROR;Enter Error
  MOV AH,9
  INT 21
  JMP EXIT
  LockC:
  MOV AH,55H
  CLD
  MOV SI,OFFSET FQB
  MOV DI,SI
  MOV CX,01FE
  AA1:
  LOADSB
  XOR AL,AH
  ROL AH,1
  STOSB;//Encrypt Partition-Table
  L AA1
  AA3:
  MOV AX,0301
  MOV BX,OFFSET BUF
  MOV CX,CXD
  MOV DX,0080
  INT 13
  JB ERR
  LEA DX,MESSAGE2
  MOV AH,9
  INT 21
  MOV AX,0040;Reset
  MOV DS,AX
  MOV AX,1234
  MOV SI,0072
  MOV [SI],AX
  JMP FFFF:0000
  INT 20
  LockD:
  CMP BYTE PTR [BUF+1D0],0
  JNZ AA2
  MOV DX,MESSAGE3;No Drive D
  MOV AH,9
  INT 21
  JMP EXIT
  AA2:
  MOV AX,0201
  MOV BX,OFFSET BUF
  MOV CX, PTR [BUF+1D0];Read Logic Drive D Partition-Table
  MOV DX,0080
  INT 13
  JB ERR
  JMP LockC
  ERR:
  MOV DX,OFFSET IOERROR
  MOV AH,9
  INT 21
  EXIT:
  MOV AH,4CH
  INT 21

code ends
end start

上面的程式適合於只有兩個分割槽的硬碟,不過程式也可以改進成多個分割槽的硬碟。在註釋RESET處是熱啟動的程式碼,即交1234送至偏移地址0040:0072處,然後再跳轉到FFFF:0處,即可以進行熱啟動。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-992487/,如需轉載,請註明出處,否則將追究法律責任。

相關文章