[29] | 1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
---|
| 2 | ;
|
---|
| 3 | ; This file is part of AiR-BOOT
|
---|
| 4 | ;
|
---|
| 5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
---|
| 6 | ; the terms of the GNU General Public License as published by the Free
|
---|
| 7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
---|
| 8 | ; any later version.
|
---|
| 9 | ;
|
---|
| 10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
| 13 | ; details.
|
---|
| 14 | ;
|
---|
| 15 | ; You should have received a copy of the GNU General Public License along with
|
---|
| 16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | ;
|
---|
[8] | 18 | ;---------------------------------------------------------------------------
|
---|
| 19 | ; AiR-BOOT / PASSWORD
|
---|
| 20 | ;---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
[51] | 22 | IFDEF MODULE_NAMES
|
---|
[30] | 23 | DB 'PASSWORD',0
|
---|
| 24 | ENDIF
|
---|
| 25 |
|
---|
| 26 |
|
---|
[8] | 27 | ; Don't ask me, what I'm doing in here to encode the passwords. I don't even
|
---|
| 28 | ; know by myself anymore. It's some kind of hash and I hope that it isn't weak
|
---|
[29] | 29 | ; and some mad uber-hacker-god will laugh about it - but i bet so ;-)
|
---|
[8] | 30 |
|
---|
| 31 | PASSWORD_AskSystemPwd Proc Near Uses ax bx si di
|
---|
| 32 | ; Asks System Password, if set...
|
---|
[46] | 33 | test byte ptr [CFG_PasswordSystem], 1
|
---|
[8] | 34 | jz PASP_NoPassword
|
---|
| 35 | mov ax, 0ABABh
|
---|
| 36 | mov si, offset TXT_ProtectedSystem
|
---|
| 37 | xor di, di ; May Access With ANY correct password
|
---|
| 38 | call PASSWORD_AskSpecifiedPassword
|
---|
| 39 | PASP_NoPassword:
|
---|
| 40 | ret
|
---|
| 41 | PASSWORD_AskSystemPwd EndP
|
---|
| 42 |
|
---|
| 43 | PASSWORD_AskChangeBootPwd Proc Near Uses ax bx si di
|
---|
| 44 | ; Asks System Password, if set...
|
---|
[46] | 45 | test byte ptr [CFG_PasswordChangeBoot], 1
|
---|
[8] | 46 | jz PACBP_NoPassword
|
---|
[46] | 47 | test byte ptr [TimedBootUsed], 1
|
---|
[8] | 48 | jnz PACBP_NoPassword
|
---|
| 49 | mov ax, 0ABABh
|
---|
| 50 | mov si, offset TXT_ProtectedBootUp
|
---|
| 51 | xor di, di ; May Access With ANY correct password
|
---|
| 52 | call PASSWORD_AskSpecifiedPassword
|
---|
| 53 | PACBP_NoPassword:
|
---|
| 54 | ret
|
---|
| 55 | PASSWORD_AskChangeBootPwd EndP
|
---|
| 56 |
|
---|
[29] | 57 | ;CFG_MasterPassword dw 0101Fh ; Encoded Password (this is just CR)
|
---|
| 58 | ; dw 07A53h
|
---|
| 59 | ; dw 0E797h
|
---|
| 60 | ; dw 0A896h
|
---|
| 61 | ; BUGBUG - If unspecified password to ask, check if one of our two are CR
|
---|
| 62 | ; And if that's the case, we need to skip over checking that one.
|
---|
| 63 | ; If both are CR, return to caller
|
---|
| 64 |
|
---|
| 65 |
|
---|
[8] | 66 | ; In: ax - Magic for AskPassword Subroutine
|
---|
| 67 | ; si - Text to show, when asking for password
|
---|
| 68 | ; di - which password to check, use 0 to check any of both
|
---|
| 69 | ; Destroyed: None
|
---|
| 70 | PASSWORD_AskSpecifiedPassword Proc Near Uses cx dx ds si es di bp
|
---|
| 71 | local AskPasswordMiss:byte, AskPasswordText:word, AskPasswordMagic:word, AskPasswordWhich:word
|
---|
[46] | 72 | mov [AskPasswordMagic], ax
|
---|
| 73 | mov [AskPasswordText], si
|
---|
| 74 | mov [AskPasswordWhich], di
|
---|
[8] | 75 | mov ax, cs
|
---|
| 76 | mov ds, ax
|
---|
| 77 | mov es, ax
|
---|
| 78 | mov di, offset TempPasswordEntry
|
---|
| 79 | mov al, 32
|
---|
| 80 | mov cx, 8
|
---|
| 81 | rep stosb ; Generates empty password
|
---|
[46] | 82 | mov byte ptr [AskPasswordMiss], 0
|
---|
| 83 | mov ax, [AskPasswordWhich]
|
---|
[8] | 84 | or ax, ax
|
---|
| 85 | jnz PASP_BadBoyRetry ; Only check one
|
---|
| 86 | ; Encode empty Password...
|
---|
| 87 | mov si, offset TempPasswordEntry
|
---|
| 88 | call PASSWORD_Encode
|
---|
| 89 | mov di, offset CFG_MasterPassword
|
---|
| 90 | mov si, offset PasswordSpace ; Check Thiz Out
|
---|
| 91 | mov cx, 8
|
---|
| 92 | repe cmpsb
|
---|
| 93 | je PASP_DualCorrect1
|
---|
| 94 | jmp PASP_LetUserGuessPassword
|
---|
| 95 | PASP_DualCorrect1:
|
---|
| 96 | mov si, offset PasswordSpace ; Check Thiz Out
|
---|
| 97 | mov cx, 8
|
---|
| 98 | repe cmpsb
|
---|
| 99 | je PASP_CorrectPass
|
---|
| 100 | jmp PASP_LetUserGuessPassword
|
---|
| 101 |
|
---|
| 102 | PASP_BadBoyRetry:
|
---|
| 103 | ; Encode given Password...
|
---|
| 104 | mov si, offset TempPasswordEntry
|
---|
| 105 | call PASSWORD_Encode
|
---|
| 106 |
|
---|
| 107 | ; ...and compare it to the specified on-board one
|
---|
[46] | 108 | mov di, [AskPasswordWhich]
|
---|
[8] | 109 | or di, di
|
---|
| 110 | jnz PASP_OnlyCheckSpecified
|
---|
| 111 | mov di, offset CFG_MasterPassword
|
---|
| 112 | mov si, offset PasswordSpace ; Check Thiz Out
|
---|
| 113 | mov cx, 8
|
---|
| 114 | repe cmpsb
|
---|
| 115 | je PASP_CorrectPass
|
---|
| 116 | mov di, offset CFG_BootPassword
|
---|
| 117 | PASP_OnlyCheckSpecified:
|
---|
| 118 | mov si, offset PasswordSpace ; Check Thiz Other Thingie Out
|
---|
| 119 | mov cx, 8
|
---|
| 120 | repe cmpsb
|
---|
| 121 | je PASP_CorrectPass
|
---|
| 122 |
|
---|
| 123 | PASP_LetUserGuessPassword: ; ;-)))
|
---|
[46] | 124 | mov ax, [AskPasswordMagic]
|
---|
| 125 | mov si, [AskPasswordText]
|
---|
[8] | 126 | mov di, offset TempPasswordEntry
|
---|
| 127 | call SETUP_LetEnterPassword
|
---|
[46] | 128 | inc byte ptr [AskPasswordMiss]
|
---|
| 129 | cmp byte ptr [AskPasswordMiss], 10
|
---|
[8] | 130 | jae PASP_BadBoyAlert
|
---|
| 131 | jmp PASP_BadBoyRetry
|
---|
| 132 |
|
---|
| 133 | PASP_BadBoyAlert: ; Whaddayawant ;)
|
---|
| 134 | mov ax, 0ABABh
|
---|
| 135 | mov cx, 0B03h
|
---|
| 136 | mov si, offset TXT_TooManyTries
|
---|
| 137 | call SETUP_ShowErrorBox
|
---|
| 138 | jmp MBR_HaltSystem
|
---|
| 139 |
|
---|
| 140 | PASP_CorrectPass:
|
---|
| 141 | ret
|
---|
| 142 | PASSWORD_AskSpecifiedPassword EndP
|
---|
| 143 |
|
---|
[40] | 144 | PasswordSpace db 16 dup (0) ; Space for Password-Encoding...
|
---|
[8] | 145 | dw 0BABEh ; All of these 8 bytes are insider
|
---|
| 146 | dw 0FC77h ; jokes. I bet no one will solve
|
---|
| 147 | dw 0632Fh ; all of them =) they are used by
|
---|
| 148 | dw 0CD09h ; the algo, so don't remove them.
|
---|
| 149 |
|
---|
| 150 | ; In: SI - Pointer to Password, fixed len (8 bytes)
|
---|
| 151 | ; Out: Password-Space filled with encoded password
|
---|
| 152 | ; Destroyed: None
|
---|
| 153 | PASSWORD_Encode Proc Near Uses ax cx ds si es di
|
---|
| 154 | mov ax, cs
|
---|
| 155 | mov es, ax
|
---|
| 156 | mov di, offset PasswordSpace
|
---|
| 157 | mov cx, 8
|
---|
| 158 | PE_HashLoop:
|
---|
| 159 | lodsb
|
---|
| 160 | mov es:[di], al
|
---|
| 161 | xor al, 0ABh
|
---|
| 162 | and al, 7
|
---|
| 163 | mov es:[di+8], al ; Init Hash Table
|
---|
| 164 | inc di
|
---|
| 165 | loop PE_HashLoop
|
---|
| 166 |
|
---|
| 167 | mov si, offset PasswordSpace
|
---|
| 168 | mov cx, 8
|
---|
| 169 | PE_ContinueLoop:
|
---|
| 170 | mov al, ds:[si]
|
---|
[30] | 171 | ;movzx bx, ds:[si+8]
|
---|
| 172 | mov bl,ds:[si+8]
|
---|
| 173 | mov bh,0
|
---|
| 174 |
|
---|
[8] | 175 | add bl, 16
|
---|
| 176 | mov ah, ds:[si+bx]
|
---|
| 177 |
|
---|
| 178 | xor al, ds:[si-1]
|
---|
| 179 | xor al, ah
|
---|
| 180 | mov ds:[si], al
|
---|
| 181 |
|
---|
| 182 | inc si
|
---|
| 183 | loop PE_ContinueLoop
|
---|
| 184 | ret
|
---|
| 185 | PASSWORD_Encode EndP
|
---|