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

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

--解析三
上一篇文章解析了硬碟上有兩個分割槽的加密過程,下面的將允許有N個分割槽的加密過程:
Codes:

data segment
  FQB 512 dup(0);a buffer that will be used to store partition-table
  FIRSTP DB 40 dup(0);storing the first partition information
  SECONDP DB 00,01,00,00
  DB 512 dup(0)
  INFO1 DB "My Computer has the following drives:!$"
  INFO2 DB 0DH,0AH,"Please enter the drive needed to be locked!$"
  INFO3 DB 0DH,0AH,"Invalid Enter!$"
  ERROR DB 0DH,0AH,"Harddisk I/O error!$"
data ends
code segment
  assume cs:code,ds:data
  START:
  MOV AX,1000H
  MOV DS,AX
  MOV SI,OFFSET SECONDP;
  MOV DI,OFFSET FIRSTP;
  SUB DI,4
  READP:
  MOV AX,0201
  MOV BX,OFFSET FQB
  MOV CX, PTR [SI+1]
  MOV DX,0080
  INT 13
  JB ERROR
  ADD SI,4
  ADD DI,4
  ;The first partition
  ADD BX,1BE
  MOV AX,WORD PTR [BX+1]
  MOV [DI],AX
  MOV AX,WORD PTR [BX+3]
  MOV [DI+2],AX
  ;The second partition
  ADD BX,10H
  MOV AX,WORD PTR [BX+1]
  MOV [SI],AX
  MOV AX,WORD PTR [BX+3]
  MOV [SI+2],AX
  CMP WORD PTR [SI+1],0;Detene whether the header,sector is 0 or not
  JNZ READP
  LEA DX,INFO1
  MOV AH,9
  INT 21H
  MOV DL,43H
  MOV DI,OFFSET FIRSTP
  DISP:
  CMP WORD PTR [DI+1],0
  JZ ENCRYPT
  MOV AH,02
  INT 21H
  MOV CL,DL
  CMP BYTE PTR [DI+3],0
  JNZ NLOCK
  JMP ENCRYPT
  NLOCK:
  MOV DL,','
  INT 21
  MOV DL,CL
  INC DL
  ADD DI,4
  JMP DISP
  ENCRYPT:
  MOV AH,9
  LEA DX,INFO2
  INT 21
  MOV AH,1
  INT 21
  CMP AL,'A'
  JB ERROR1
  CMP AL,'Z'
  JA ERROR1
  SUB AL,43H
  XOR AH,AH;AH=0
  SHL AX,1
  SHL AX,1
  MOV SI,OFFSET SECONDP
  ADD SI,AX
  MOV AX,0201
  MOV BX,OFFSET FQB
  MOV CX,[SI+1];Sector,Cylinder
  MOV DH,[SI];Header
  MOV DL,80H;The first harddisk:80,the second:81
  INT 13
  JB ERROR
  ADD BX,1C1H
  MOV AX,[BX]
  XCHG [BX-20],AX
  MOV [BX],AX
  MOV AX,0301
  MOV BX,OFFSET FQB
  MOV CX,[SI+1]
  MOV DH,[SI]
  MOV DL,80H
  INT 13
  JB ERROR
  MOV AX,0040
  MOV DS,AX
  MOV SI,0072
  MOV AX,1234
  MOV [SI],AX
  JMP FFFF:0
  INT 20H
  ERROR1:
  LEA DX,INFO3
  MOV AH,9
  INT 21H
  JMP EXIT
  ERROR:
  LEA DX,INFO2
  MOV AH,9
  INT 21
  EXIT:
  MOV AH,4CH
  INT 21H
 code ends

  end start 

 

 
 


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

相關文章