home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 165 / SYSLOCK.ZIP / SYSLOCK.ASM < prev    next >
Assembly Source File  |  1985-08-24  |  15KB  |  318 lines

  1.           PAGE    61,132  ; (Ctrl-O) <--- Insert ASCII 15 for Condensed Print
  2.           TITLE   SYSLOCK.ASM  (Creates SYSLOCK.SYS Device Driver)
  3. ;                         Version 1.1, 8/24/85
  4. ;   All Rights Reserved: J. C. Kilday Associates, Peaks Island, ME 04108
  5.  
  6. ; SYSLOCK.SYS is a device driver for use with PC DOS & MS DOS releases 2.x and
  7. ; 3.x to implement a "BREAKproof" password security system for IBM PC's and
  8. ; compatibles.  When installed on an XT (or possibly another hard disk system),
  9. ; it provides the basis for absolute protection against unauthorized use of the
  10. ; PC and access to its hard disk data.
  11.  
  12. ; If a simple, reversible hardware modification is made to an XT, use of the
  13. ; machine becomes impossible without entering the system password you have
  14. ; chosen.  The modification prevents the attempted boot operation from the
  15. ; floppy drive.  See the documentation provided with this program for more
  16. ; on this.
  17.  
  18. ; This system is also useful for a measure of protection on floppy-based
  19. ; systems if installed on all boot/system diskettes.
  20.  
  21. ; The companion program RELOCK.COM allows the user to disable the PC by typing
  22. ; RELOCK at the DOS prompt.  Normal use may be resumed by entering the requested
  23. ; password.
  24.  
  25. ; After assembling SYSLOCK.ASM:
  26.  
  27. ;             1) LINK SYSLOCK  (ignore "no STACK" error)
  28. ;             2) EXE2BIN SYSLOCK SYSLOCK.SYS
  29. ;             3) Enter DEVICE=SYSLOCK.SYS in CONFIG.SYS file
  30. ;             4) Copy SYSLOCK.SYS into the root directory of the boot disk
  31. ;             5) Reboot the system with Ctrl-Alt-Del
  32. ;             6) Respond to prompt with: password <ENTER>
  33.  
  34. ; Note: The password matching is case-sensitive.  You must enter letters of
  35. ;       the same case used in defining the password.  If entering upper case
  36. ;       letters or shifted symbols after RELOCK has been invoked,  only the left
  37. ;       shift key is active.  The CTRL, ALT, and right shift keys are disabled
  38. ;       while RELOCK is awaiting password entry, so that certain resident
  39. ;       utilities (e.g., SideKick) cannot be used to bypass the system.
  40.  
  41. DEV_DRVR SEGMENT  PARA  PUBLIC 'CODE'
  42.  
  43. SLCK_DEVICE PROC FAR
  44.           ASSUME CS:DEV_DRVR, DS:DEV_DRVR
  45.  
  46. BEGIN:
  47.  
  48. ;                       D E V I C E    H E A D E R
  49.  
  50. NEXT_DEV  DD      -1                    ;Pointer to next device
  51. ATTRIBUTE DW      8000H                 ;Character device
  52. STRATEGY  DW      DEV_STRATEGY          ;Pointer to device strategy
  53. INTERRUPT DW      DEV_INT               ;Pointer of device interrupt handler
  54. DEV_NAME  DB      'SLCK_JCK'            ;8-byte device name
  55.  
  56.           PAGE
  57.  
  58. ;                     P A S S W O R D    S T O R A G E
  59.  
  60. PW_LEN    EQU     4 ;<======================== INSERT PASSWORD LENGTH HERE
  61.  
  62. PW_AREA   DB      PW_LEN,'test';<============= INSERT PASSWORD HERE
  63.  
  64.           DB      15-PW_LEN DUP(' ') ;leaves space for 15 characters
  65.                                      ; (allows password changes directly to
  66.                                      ; object code using DEBUG, Norton
  67.                                      ; Utilities, or other zapper.)
  68.  
  69. ;                  O T H E R   S T O R A G E   A R E A S
  70.  
  71. KB_BUF_MAX DB     15                    ;Max length of local input buffer
  72. KB_BUF_LEN DB     ?                     ;Number password characters keyed in
  73. KB_BUF     DB     15 DUP(?)             ;Local keyboard input buffer
  74.  
  75. BREAK_SEG  DW     ?                     ;Store for segment  of old BREAK vector
  76. BREAK_OFF  DW     ?                     ;Store for offset of old BREAK vector
  77.  
  78. TVEC_STORE DW     6 DUP (?)             ;Store for 3 time-related interrupt
  79.                                         ; vectors 08H, 1AH, and 1CH
  80.  
  81. READ_CNT   DB     0                     ;Read control counter.
  82.  
  83. REQHDR_PTR LABEL DWORD
  84. RH_PTR_OFF DW     ?                     ;Offset portion of Request Hdr pointer
  85. RH_PTR_SEG DW     ?                     ;Segment portion of Request Hdr pointer
  86.  
  87. ;                M E S S A G E   S T O R A G E   A R E A
  88.  
  89. MSG_1     DB      13,10                 ;CR,Linefeed
  90.           DB      'Please enter system password: $'
  91. MSG_2     DB      13,10
  92.           DB      'Password accepted.',13,10,'$'
  93. BEEP      DB      7,'$'
  94.  
  95. ;                      D E V I C E   S T R A T E G Y
  96.  
  97. ;Saves the pointer to the Request Header
  98.  
  99. DEV_STRATEGY PROC  FAR
  100.           ASSUME  CS:DEV_DRVR
  101.           MOV     CS:RH_PTR_OFF,BX      ;Save offset of Req Hdr
  102.           MOV     CS:RH_PTR_SEG,ES      ;Save segment of Req Hdr
  103.           RET                           ;Return to DOS
  104. DEV_STRATEGY ENDP
  105.  
  106. ;               P R I M A R Y    L O C A L    P R O C E D U R E
  107.  
  108. GET_PWRD  PROC NEAR
  109.  
  110. ; This code prompts the user for the correct password
  111.  
  112. ASK:      LEA     DX, MSG_1             ;Point DX to "Enter Password" prompt
  113.           MOV     AH,9                  ;Print message
  114.           INT     21H
  115.           MOV     CH,0                  ;Set CX = length of input buffer
  116.           MOV     CL,KB_BUF_MAX
  117.           MOV     DI,0                  ;Initialize the controlling index reg.
  118. IN_LOOP:  MOV     AH,07                 ;Set up to get keyboard input w/o echo
  119.           INT     21H                   ;Call DOS input handler
  120.           CMP     AL,13                 ;Was <ENTER> pressed?
  121.           JE      DONE                  ;Jump if yes
  122.           MOV     KB_BUF[DI],AL         ;Put keyed character into buffer
  123.           INC     DI                    ;Advance index reg to next buffer loc.
  124.           LOOP    IN_LOOP               ;Loop back if buffer not full
  125.  
  126. DONE:     MOV     AX,DI                 ;Move number of keystrokes to
  127.           MOV     KB_BUF_LEN,AL         ;  control field for testing
  128.           MOV     AX,CS                 ;Set up ES for string comparison to come
  129.           MOV     ES,AX
  130.           LEA     SI,KB_BUF_LEN         ;Initialize index registers for the
  131.           LEA     DI,PW_AREA            ;  string comparison
  132.           MOV     CH,0                  ;Initialize CX to number of characters
  133.           MOV     CL,[SI]               ; to be involved in string compare
  134.           CMP     CL,[DI]               ;Is number of characters entered the
  135.           JNE     ASK_AGAIN             ;  same as password length? Jump if no.
  136.           INC     DI                    ;Step index regs to start char.-by-
  137.           INC     SI                    ;  char. comparison against password
  138.           REP     CMPSB                 ;Do the comparison
  139.           JNE     ASK_AGAIN             ;Jump if they don't match
  140.           LEA     DX,MSG_2              ;Point DX to "Password accepted" msg
  141.           MOV     AH,9
  142.           INT     21H                   ;Print message
  143.           RET                           ;Return to calling routine
  144.  
  145. ASK_AGAIN:
  146.           LEA     DX,BEEP               ;Point DX to the "BEEP" string
  147.           MOV     AH,9
  148.           INT     21H                   ;Beep
  149.           JMP     ASK                   ;Go back and try again
  150. GET_PWRD  ENDP
  151.  
  152. ;             D E V I C E   I N T E R R U P T   H A N D L E R
  153.  
  154. ;Processes the command indicated in the request header.
  155.  
  156. DEV_INT   PROC    FAR
  157.  
  158.           PUSH    DS                    ;Save everything in sight
  159.           PUSH    ES
  160.           PUSH    AX
  161.           PUSH    BX
  162.           PUSH    CX
  163.           PUSH    DX
  164.           PUSH    DI
  165.           PUSH    SI
  166.           PUSHF
  167.           MOV     AX,CS                 ;Establish addressability of data
  168.           MOV     DS,AX
  169.           LES     BX,REQHDR_PTR         ;Set ES:BX = pointer to Req Hdr
  170.           MOV     AL,ES:[BX+2]          ;Get command byte from Req Hdr
  171.           CMP     AL,4                  ;Check for INPUT command
  172.           JE      INPUT_CHAR            ;If yes, jump to dummy input routine
  173.           CMP     AL,0                  ;Check for INITIALIZE command
  174.           JE      INIT_FN               ;If yes, go do initialize functions
  175.                                         ; otherwise fall thru to error exit
  176.           OR      WORD PTR ES:[BX+3],8003H  ;Set Req Hdr status word=error,
  177.                                             ;                unknown command.
  178.           JMP     DO_POPS
  179. NORMAL_EXIT:
  180.           OR      WORD PTR ES:[BX+3],100H ;Set Req Hdr status word=done
  181. DO_POPS:
  182.           POPF                          ;Restore everything saved earlier
  183.           POP     SI
  184.           POP     DI
  185.           POP     DX
  186.           POP     CX
  187.           POP     BX
  188.           POP     AX
  189.           POP     ES
  190.           POP     DS
  191.           RET                           ;Return to DOS
  192.  
  193. ;The interrupt handler treats only 2 commands as valid commands: the read
  194. ;command which is implemented as a dummy operation only to re-enter the
  195. ;ask-for-password process from RELOCK.COM;  and the initialize command which
  196. ;consists of code which will be discarded after being used at driver
  197. ;installation time.
  198.  
  199. ;The INPUT_CHAR routine is executed from RELOCK.COM which issues dummy
  200. ;requests to read a character from this device.  The first read request
  201. ;results in transfer of timer interrupt vectors as initialized at boot time.
  202. ;RELOCK.COM uses this information to temporarily "disconnect" resident
  203. ;utilities.  The second read request results in SYSLOCK.SYS asking for
  204. ;the password as done during initialization.
  205.  
  206. INPUT_CHAR:
  207.  
  208.           CMP     READ_CNT,0            ;Check for 1st of 2 read commands
  209.                                         ; from RELOCK
  210.           JNZ     PWRD_TST              ;Jump if 2nd read command
  211.           XOR     READ_CNT,1            ;During 1st read set count to 1
  212.           PUSH    ES                    ;Save ES for later use
  213.           CLD                           ;Set forward string operations
  214.           MOV     SI,OFFSET TVEC_STORE  ;Set index registers to control
  215.           MOV     DI,WORD PTR ES:[BX+0EH]; move of time-related interrupt
  216.                                         ;  vectors which were saved during
  217.                                         ;  driver initilization
  218.           MOV     AX,WORD PTR ES:[BX+10H] ;Point ES to RELOCK's buffer segment
  219.           MOV     ES,AX
  220.           MOV     CX,12                 ;Move 12 bytes (3 DWORD vectors)
  221.           REP     MOVSB                 ;Move vectors to buffer in RELOCK.COM
  222.           POP     ES                    ;Restore ES to point to request header
  223.           MOV     WORD PTR ES:[BX+12H],12 ;Report 12 bytes input
  224.           JMP     NORMAL_EXIT
  225.  
  226. PWRD_TST: PUSH    ES                    ;Save this before GET_PWRD destroys
  227.           CALL    GET_PWRD              ;Perform the request for password, etc.
  228.           POP     ES                    ;Restore ES
  229.           MOV     READ_CNT,0            ;Clear read control counter
  230.           MOV     WORD PTR ES:[BX+12H],1  ;Indicate 1 byte xferred (a lie, but
  231.                                           ;  it makes DOS happy)
  232.           JMP     NORMAL_EXIT           ;So as to return to RELOCK.COM
  233.  
  234. ;The INIT_FN routine performs the initial installation functions, asks for
  235. ;password, and then informs the device driver installation portion of the
  236. ;operating system that all code beginning at INIT_FN is to be discarded.
  237.  
  238. INIT_FN:
  239.           PUSH    ES                    ;Save this before it is lost
  240.           CLI                           ;Disable interrupts
  241.           CALL    NO_BREAK              ;Disable Ctrl-Break
  242.           CALL    GET_VECS              ;Save time-related interrupt vectors
  243.                                         ; 08H, 1AH, and 1CH for use by RELOCK
  244.           STI                           ;Enable interrupts
  245.           CALL    GET_PWRD              ;Perform request for password, etc.
  246.           CLI                           ;Disable interrupts
  247.           CALL    BREAK_ON              ;Restore Ctrl-Break operation
  248.           STI                           ;Enable interrupts
  249.           POP     ES                    ;Restore ES=segment of Req Hdr pointer
  250.           MOV     WORD PTR ES:[BX+0EH],OFFSET INIT_FN-1 ;Inform DOS that the
  251.                                         ; last byte to be retained as part of
  252.                                         ; installed device driver is the one
  253.                                         ; immediately preceding INIT_FN.
  254.           MOV     WORD PTR ES:[BX+10H],CS ;And this identifies the segment
  255.           JMP     NORMAL_EXIT           ;Go to finish housekeeping and
  256.                                         ;  to return to DOS.
  257. DEV_INT   ENDP
  258.  
  259. ;            S E C O N D A R Y   L O C A L   P R O C E D U R E S
  260.  
  261. ;         (These are discarded after device driver initialization.)
  262.  
  263. NO_BREAK  PROC    NEAR
  264.  
  265. ;The following prevents Ctrl-Break from having any effect.
  266.  
  267.           MOV     AX,0                  ;Point ES to segment 0
  268.           MOV     ES,AX
  269.           MOV     AX,WORD PTR ES:[1BH*4] ;Save offset portion of present
  270.           MOV     BREAK_OFF,AX          ;   Ctrl-Preak vector
  271.           MOV     AX,WORD PTR ES:[1BH*4+2] ;Save segment portion
  272.           MOV     BREAK_SEG,AX
  273.           MOV     WORD PTR ES:[1BH*4],OFFSET DO_NOTHING ;Set up new vector to
  274.           MOV     WORD PTR ES:[1BH*4+2],CS  ;point to IRET below.
  275.           RET
  276.  
  277. DO_NOTHING:                             ; Break vector pointed here so
  278.           IRET                          ; nothing happens on Ctrl-Break.
  279.  
  280. NO_BREAK  ENDP
  281.  
  282. ; The following saves 3 timer interrupt vectors as setup during system boot.
  283.  
  284. GET_VECS  PROC    NEAR
  285.           MOV     AX,WORD PTR ES:[08H*4]
  286.           MOV     TVEC_STORE,AX
  287.           MOV     AX,WORD PTR ES:[08H*4+2]
  288.           MOV     TVEC_STORE[2],AX
  289.           MOV     AX,WORD PTR ES:[1AH*4]
  290.           MOV     TVEC_STORE[4],AX
  291.           MOV     AX,WORD PTR ES:[1AH*4+2]
  292.           MOV     TVEC_STORE[6],AX
  293.           MOV     AX,WORD PTR ES:[1CH*4]
  294.           MOV     TVEC_STORE[8],AX
  295.           MOV     AX,WORD PTR ES:[1CH*4+2]
  296.           MOV     TVEC_STORE[10],AX
  297.           RET
  298. GET_VECS  ENDP
  299.  
  300. BREAK_ON  PROC    NEAR
  301.  
  302. ; The following restores the Ctrl-Break vector.
  303.  
  304.           MOV     AX,0                  ;Point ES to segment 0
  305.           MOV     ES,AX
  306.           MOV     AX,BREAK_OFF          ;Restore offset portion
  307.           MOV     WORD PTR ES:[1BH*4],AX
  308.           MOV     AX,BREAK_SEG          ;Restore segment portion
  309.           MOV     WORD PTR ES:[1BH*4+2],AX
  310.           RET
  311. BREAK_ON  ENDP
  312.  
  313. SLCK_DEVICE  ENDP
  314.  
  315. DEV_DRVR  ENDS
  316.  
  317.           END     BEGIN
  318.