Hard disk encryption - Analysis Three Previous article parsing the encryption process of two partitions on the hard disk, the following program will allow N-partition encryption processes: Source Codes:
Data Segment FQB DB 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 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 Endscode 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, Word 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], 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; DETERMINE WH Ether 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 DINCRYPT: 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 endsend Start