home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / rcpm / wheel.asm < prev    next >
Assembly Source File  |  1994-07-13  |  10KB  |  387 lines

  1. ; WHEEL.ASM  -    Password access for ZCPR/ZCMD systems  -  05/20/86
  2. ;
  3. ;          copyrighted by Irv Hoff W6FFC
  4. ;
  5. ;
  6.     ASEG            ; For M80 and RMAC ignore error with MAC
  7. ;
  8. ; This program permits the SYSOP to activate the WHEEL byte.  This kicks
  9. ; in the drives and user areas set for the Sysop in place of those set
  10. ; for the remote user.
  11. ;
  12. ; There are several ways to change these allocations:
  13. ;
  14. ;    1) Using ZCMD or ZCPR without BYE5 for remote use
  15. ;    2) Using ZCMD or ZCPR with BYE5 for remote use
  16. ;    3) Using ZCMD or ZCPR with/without BYE5 with external flow path
  17. ;
  18. ; All of these cases are covered.  In the case of an external flow path
  19. ; be sure to set the EXTPATH equate below.
  20. ;
  21. ; This program is placed in A0: so the Sysop can request it without the
  22. ; WHEEL byte being activated.  Since any user could do the same, several
  23. ; levels of security are included:
  24. ;
  25. ;    1) Go to the 'special attention' area below and:
  26. ;        a) add your own password at PSSWD (use only upper-case)
  27. ;        b) select remote user's max drive/user
  28. ;        c) select Sysop's max drive/user
  29. ;        d) select external path (if used in ZCMD or ZCPR)
  30. ;
  31. ;    2) Assemble and load to get WHEEL.COM
  32. ;    3) Rename program for additional security, instead of WHEEL.COM
  33. ;    4) Place on A0: and 'hide' with STAT.COM as a .SYS file
  34. ;
  35. ;        A0>STAT    IRV.COM    $SYS    ; (So the name can't be seen)
  36. ;
  37. ;    5) Assuming for the example "HOFF" was chosen for a password:
  38. ;
  39. ;        A0>IRV HOFF    ; To enable the wheel byte mode
  40. ;        A0>IRV -    ; Resets for remote user, types msg.
  41. ;        A0>IRV
  42. ;           Password:    ; Requests password, which is not
  43. ;                ; displayed so nobody can see what you
  44. ;                ; are using
  45. ;
  46. ;-----------------------------------------------------------------------
  47. ;
  48. ; IRV.COM would be the first level of security.  Hiding it as a system
  49. ; file on A0: prevents others from knowing the initial program's name.
  50. ; HOFF in this case would be the second level of security.  Even if you
  51. ; type:  A0>IRV <ret> when some remote user is watching, and they see
  52. ; the request for a password, they will not see your answer.  If it is
  53. ; wrong, it wipes out the 'Password: ' and replaces it with the name of
  54. ; the program with a '?' as though CP/M doesn't know what you are asking
  55. ; for and there is no such program - another mild form of security.
  56. ;
  57. ; If some twit does attempt to find your initial password (name of pgm)
  58. ; and uses the correct name (IRV in this case), it resets for remote
  59. ; user (without displaying any message) and then shows IRV? indicating
  60. ; no such file exists.    (It really does, but this is an additional level
  61. ; of security to discourage twits.)
  62. ;
  63. ; SUMMARY:
  64. ; =======
  65. ;    There may be other programs existing with similar features but
  66. ;    none I ran across have as much security as this program, which
  67. ;    is why I wrote it.  I use it with ZCMD2x, BYE5 and KMD on two
  68. ;    different systems, one having a BBS and one without.  This is
  69. ;    also useful for giving friends access to your system when you
  70. ;    do not have a BBS that automatically asks their name and kicks
  71. ;    them in as a Sysop.  The primary use though, is so the Sysop
  72. ;    can kick in his own capability whenever he wishes, perhaps on
  73. ;    some occasion a particular user is on his system and the Sysop
  74. ;    needs more capability than the remote user is normally given.
  75. ;
  76. ;                    - Notes by Irv Hoff
  77.     ORG    0100H
  78. ;
  79.     JMP    START
  80. ;
  81. ;
  82. ;=======================================================================
  83. ;        (start of special attention area)
  84. ;
  85. ; NOTE: Set the following four values for your system's normal use:
  86. ;
  87. RDRIVE    EQU    2        ; Number of drives available to user
  88. RUSER    EQU    12        ; # of highest area for remote users
  89. SDRIVE    EQU    2        ; Number of drives available to SYSOP
  90. SUSER    EQU    15        ; # of highest area for SYSOP (0-15)
  91. ;.....
  92. ;
  93. ;
  94. ; Put your password here, end it with a '0', can be 15 characters or
  95. ; less, not including the 0.
  96. ;
  97. PSSWRD:    DB    'PASS'        ; Up to 15 characters, end with 0 below
  98.     DB    0
  99. ;
  100. ;
  101. ; If using an external path, set the following equate YES and check the
  102. ; address of the external path in the line following that, usually 40h.
  103. ;
  104. EXTPATH    EQU    0        ; 0 = NO, 1 = YES        
  105. PATHADR    EQU    40H        ; Change if needed
  106. ;
  107. ;        (end of special attention items)
  108. ;=======================================================================
  109. ;
  110. ; Tells the SYSOP the WHEEL byte is now activated
  111. ;
  112. WHLMSG:    DB    0DH,0AH,'   WHEEL is on',0DH,0AH,'$'
  113. WHLOFF:    DB    0DH,0AH,'   WHEEL is off',0DH,0AH,'$'
  114. ;.....
  115. ;
  116. ;
  117. ; Equates
  118. ;
  119. BDOS    EQU    0005H        ; BDOS location
  120. CR    EQU    0DH        ; Carriage return character
  121. DIRCON    EQU    0006H        ; Direct console call
  122. LF    EQU    0AH        ; Line feed character
  123. FCB    EQU    005CH        ; File control block
  124. DRVMAX    EQU    003DH        ; Location of MAXDRV byte
  125. PRINT    EQU    09H        ; BDOS print a string
  126. USRMAX    EQU    003FH        ; Location of MAXUSER byte
  127. WHEEL    EQU    003EH        ; Location of wheel byte
  128. WRCON    EQU    02H        ; Display a character on CRT
  129. ;
  130. ;
  131. START:    LDA    FCB+1        ; See what we are supposed to do
  132.     CPI    ' '
  133.     JZ    ASKFOR        ; Nothing typed, ignore request
  134.     CPI    '-'        ; Disable wheel mode
  135.     JZ    DISABLE
  136. ;
  137. CHECK:    LXI    H,FCB+1        ; Set up all the pointers
  138.     LXI    D,PSSWRD    ; Location of password buffer
  139. ;
  140. CHECK1:    LDAX    D        ; Actual password in 'A' register
  141.     ORA    A
  142.     JZ    OK        ; If zero, checks ok
  143.     CMP    M        ; Characters match?
  144.     JNZ    ABORT        ; No check, exit with no changes
  145.     INX    H        ; Address of next password address
  146.     INX    D        ; Address of next password typed entry
  147.     JMP    CHECK1        ; If not zero, check another character
  148. ;
  149. OK:    JMP    ENABLE
  150. ;
  151. ;
  152. ;-----------------------------------------------------------------------
  153. ;              subroutines
  154. ;-----------------------------------------------------------------------
  155. ;
  156. ; Aborts if a person happens to type to correct filename, reprints the
  157. ; name to throw him off, then resets the system for a remote user, as an
  158. ; added level of security.
  159. ;
  160. ABORT:    MVI    C,PRINT
  161.     LXI    D,ABTCLR
  162.     CALL    BDOS
  163. ;
  164.     LDA    0002H        ; MSP of BIOS address
  165.     SUI    22
  166.     MOV    H,A
  167.     MVI    L,8        ; Index into buffer
  168. ;
  169. ABORT1:    MOV    A,M        ; Get the character there
  170.     ORA    A        ; See if finished
  171.     JZ    ABORT2
  172.     CPI    ' '
  173.     JZ    ABORT2
  174.     CALL    SHOW
  175.     INX    H        ; Next location
  176.     JMP    ABORT1
  177. ;
  178. ABORT2:    MVI    A,'?'
  179.     CALL    SHOW
  180.     MVI    A,LF
  181.     CALL    SHOW
  182. ;
  183. ABORT3:    JMP    DISAB0        ; Go disable the drives
  184. ;...
  185. ;
  186. ;
  187. ABTCLR:    DB    CR,'                ',CR,'$' ; wipes out 'Password: '
  188. ;.....
  189. ;
  190. ;
  191. ; Asks for a password if none was given, allows typing so nobody can
  192. ; see what it is.  (Just the local typist.)
  193. ;
  194. ASKFOR:    MVI    C,PRINT
  195.     LXI    D,ASKPAS
  196.     CALL    BDOS
  197.     LXI    D,FCB+1        ; Location to put password for compare
  198. ;
  199. ASK1:    PUSH    D
  200.     MVI    C,6        ; Direct console I/O
  201.     MVI    E,0FFH        ; Ask for character
  202.     CALL    BDOS
  203.     POP    D        ; Get the address back
  204.     ORA    A
  205.     JZ    ASK1
  206. ;
  207.     CPI    'a'        ; Make sure character is upper case
  208.     JC    ASK2
  209.     CPI    'z'+1
  210.     JNC    ASK2
  211.     ANI    5FH        ; Change to upper-case
  212. ;
  213. ASK2:    CPI    CR
  214.     JZ    CHECK
  215.     STAX    D
  216.     INX    D
  217.     JMP    ASK1
  218. ;...
  219. ;
  220. ;
  221. ASKPAS:    DB    '   Password is: ','$'
  222. ;.....
  223. ;
  224. ;
  225. ; Change the external path from Sysop to remote or vice versa
  226. ;
  227. CHANGE:    MVI    C,7
  228. ;
  229. CHANG1:    LDAX    D
  230.     MOV    M,A
  231.     INX    D
  232.     INX    H
  233.     DCR    C
  234.     JNZ    CHANG1
  235.     RET
  236. ;.....
  237. ;
  238. ;
  239. ; See if BYE5 is active
  240. ;
  241. CKBYE:    MVI    C,32
  242.     MVI    E,0F1H
  243.     CALL    BDOS
  244.     CPI    4DH
  245.     RET
  246. ;.....
  247. ;
  248. ;
  249. ; Intentional disable shows the WHEEL is off, then resets the system
  250. ; for a normal remote user again.
  251. ;
  252. DISABLE:MVI    C,PRINT        ; WHEEL "OFF" message
  253.     LXI    D,WHLOFF
  254.     CALL    BDOS
  255. ;
  256. DISAB0:    XRA    A        ; Turn the WHEEL byte off
  257.     STA    WHEEL
  258.     CALL    CKBYE        ; See if BYE5 is active
  259.     JNZ    DISAB1        ; If yes exit
  260. ;...
  261. ;
  262. ;
  263. ; BYE5 is in use, so set things through it.  First get the BYE5 address
  264. ; and then increment into the program to the location of max user (+12_
  265. ; and max drive (+13).
  266. ;
  267.     CALL    SETBYE
  268. ;
  269. ; Now have the max user address
  270. ;
  271.     LDA    RUSER+1
  272.     MOV    M,A
  273.     INX    H        ; Address of max drive
  274.     LDA    RDRIVE
  275.     MOV    M,A
  276. ;
  277. ;
  278. ; No BYE5 in use, assume ZCMD or ZCPR is setting max drive and max user.
  279. ;
  280. DISAB1:    MVI    A,RUSER+1    ; Sysop maximum user area
  281.     STA    USRMAX
  282.     MVI    A,RDRIVE-1    ; Sysop number of drives
  283.     STA    DRVMAX
  284.     STA    DRVMAX
  285. ;
  286.      IF    EXTPATH
  287.     LXI    D,RPATH        ; Remote user external path, prevents
  288.     LXI    H,PATHADR    ;   his using A15:
  289.     CALL    CHANGE
  290.      ENDIF            ; EXTPATH
  291. ;
  292.     JMP    EXIT
  293. ;.....
  294. ;
  295. ;
  296. ; Set the WHEEL, max user, max drive but first check to see if BYE is
  297. ; active and handle accordingly.
  298. ;
  299. ENABLE:    MVI    A,0FFH        ; Turn the WHEEL byte on
  300.     STA    WHEEL
  301. ;
  302.     MVI    C,PRINT        ; WHEEL in use message
  303.     LXI    D,WHLMSG
  304.     CALL    BDOS
  305.     CALL    CKBYE        ; See if BYE5 is active
  306.     JNZ    ENAB1        ; Exit if BYE5 is in use
  307. ;
  308. ;
  309. ; BYE5 is in use, so set things through it.  First get the BYE5 address
  310. ; and then increment into the program to the location of max user (+12_
  311. ; and max drive (+13).
  312. ;
  313.     CALL    SETBYE
  314. ;
  315. ; Now have the max user address
  316. ;
  317.     LDA    SUSER+1
  318.     MOV    M,A
  319.     INX    H        ; Address of max drive
  320.     LDA    SDRIVE
  321.     MOV    M,A
  322. ;
  323. ;
  324. ; No BYE5 in use, assume ZCMD or ZCPR is setting max drive and max user.
  325. ;
  326. ENAB1:    MVI    A,SUSER+1    ; Sysop maximum user area
  327.     STA    USRMAX
  328.     MVI    A,SDRIVE-1    ; Sysop number of drives
  329.     STA    DRVMAX
  330. ;
  331.      IF    EXTPATH
  332.     LXI    D,SPATH        ; Sysop external path (includes user 15)
  333.     LXI    H,PATHADR
  334.     CALL    CHANGE
  335.      ENDIF            ; EXTPATH
  336. ;...
  337. ;
  338. ;
  339. EXIT:    RET            ; Jump back to original address
  340. ;.....
  341. ;
  342. ;
  343. ; Remote user's external path flow - WHEEL off - if any paths are added,
  344. ; alter the value at CHANGE: above.
  345. ;
  346. RPATH:    DB    '$','$'        ; Current drive, user area
  347.     DB    1,0        ; 'A' drive, 0 user area
  348.     DB    0,0        ; Skips additional checks
  349.     DB    0        ; Finished
  350. ;.....
  351. ;
  352. ;
  353. ; Sysop's external path flow - WHEEL off - if any paths are added,
  354. ; alter the value at CHANGE: above.
  355. ;
  356. SPATH:    DB    '$','$'        ; Current drive, user area
  357.     DB    1,0        ; 'A' drive, 0 user area
  358.     DB    1,15        ; 'A' drive, 15 user area
  359.     DB    0        ; Finished
  360. ;.....
  361. ;
  362. ;
  363. SETBYE:    LHLD    0000H+1        ; Warm boot vector address
  364.     DCX    H        ; MSP of cold boot vector
  365.     MOV    D,M        ; Put into 'D' register
  366.     DCX    H        ; LSP of cold boot vector
  367.     MOV    E,M        ; Put into the 'E' register
  368. ;
  369. ; Now have the BYE5 MCBOOT location, add 6 to find max user location.
  370. ;
  371.     LXI    H,6
  372.     DAD    D        ; Add to MCBOOT location
  373.     RET
  374. ;.....
  375. ;
  376. ;
  377. SHOW:    PUSH    H
  378.     MOV    E,A
  379.     MVI    C,WRCON
  380.     CALL    BDOS
  381.     POP    H
  382.     RET
  383. ;.....
  384. ;
  385. ;
  386.     END
  387.