Monday, October 25, 2010

Simple password


title *** simple password by lluct ***
data segment; defined data segment
input db 100 dup (?)
; Definition of the input string, the string must be defined with db length is 100 bytes
cmpare db''5201314'',''$''
; Defined password
msg1 db''PASSWORD RIGHT !'',''$''
; Defined password is correct the information shown
msg2 db''PASSWORD ERROR !'',''$''
; Define a password error message displayed
headmsg db''ENTER YOUR PASSWORD :'',''$''
; Header
data ends; data segment at the end of

code segment; defined code
assume cs: code; provides the contents of cs
assume ds: data; provides the content of ds

start: mov ax, data; process from start start
mov ds, ax; ds set the initial value, data segment address
mov si, 0; index register can set the initial value 0

call enter; call display subroutine carriage return line feed
lea dx, headmsg; output offset of the first message string
call dispchs; call display string subroutine
repeat: mov ah, 01h
; Definition of repeat label, enter a single character for the cycle. Call 1 function: a character from the keyboard and echo
int 21h; finish echo
cmp al, 0dh; input characters and cr (carriage return) to compare
je finish; if equal to Enter to move to finish
mov input [si], al; to al the home sent to the address input of the si (as if this is right)
inc si; si + 1
jmp repeat; unconditional transfer to repeat
finish: mov input [si], 24h; to input completed by the end of the string plus sign ($)
call enter

mov si, 0; source index register can set the initial value 0
mov di, 0; purpose index register set the initial value 0
mov cx, 8; set a password check digit (also me another sign the end)
check: cmp cx, 0; set the median to 0.
je right; If the password checks completed, the transfer to the right
mov bl, input [si]; the input of si in the address data to the bl
mov dl, cmpare [di]; to cmpare of di address data to the dl
cmp dl, bl; dl and bl more
jne error; if not equal, the transfer to the error
inc si; si + 1
inc di; di + 1
dec cx; cx by 1
jmp check; unconditional transfer to check

right: call enter
lea dx, msg1
call dispchs
call enter
jmp exit

error: call enter
lea dx, msg2
call dispchs
mov dl, 07h; output ascii code of the alarm (bell) control character bel (07h)
call dispch
call enter
jmp exit
exit: mov ah, 4ch; 4c number function call: end the current program and returns
int 21h; return to dos

enter proc near; display carriage return line feed subroutine
mov dl, 0dh; output carriage return control character code ascii cr (odh)
call dispch
mov dl, 0ah; output ascii code for line control character lf (0ah)
call dispch
ret; Back
enter endp; subroutine at the end of

dispch proc near; display a single character subroutine
mov ah, 02h; 2 number function call: display output character
int 21h; the completion of the output display
ret
dispch endp

dispchs proc near; display string subroutine
mov ah, 09h; 9 number function call: Display string
int 21h; the completion of the output display
ret
dispchs endp

code ends; code at the end of
end start; end of the assembly

; The above code into a text program such as Notepad, and save. (Such as passwrod.asm)
; Compile: masm password.asm
; Link: link password.obj
; Executive: password.exe

================================================== ===============

With an asterisk password
title *** a simple password is Advanced by lluct ***


data segment; defined data segment
headmsg db'''', 0dh, 0ah
db''+---------------------------------------------- +'', 0dh, 0ah
db''| Simple input password system for asm program |'', 0dh, 0ah
db''| have a fun .^-^. |'', 0dh, 0ah
db''| Poor Programmer: lluct Date: march, 21 2004 |'', 0dh, 0ah
db''+---------------------------------------------- +'', 0dh, 0ah
db 0dh, 0ah,''PLEASE INPUT PASSWORD :'',''$''
; Defined group header
msg1 db''PASSWORD RIGHT !'',''$''
; Defined password information displayed is correct
msg2 db''PASSWORD ERROR !'',''$''
; Define a password error message displayed
cmpare db''5201314'',''$''
; Defined password
input db 100 dup (?)
; Definition of the input string, the string must be defined with db length is 100 bytes
data ends; data segment at the end of

code segment; defined code
assume cs: code; provides the contents of cs
assume ds: data; provides the content of ds

start_program:; program from here
mov ax, data; the data segment address assigned to ax
mov ds, ax; ds set the initial value, data segment address
mov si, 0; index register initial value is 0

call enter; call display subroutine carriage return line feed
lea dx, headmsg; output offset of the first information group
call dispchs; call display string subroutine

repeat_input:; cycle enter a single character
mov ah, 08h; call the 8 functions: keyboard input characters (no echo)
int 21h; finish
mov dl, 2ah; output ascii code * No.
push ax; protection of the original input character
call dispch; call a single character echo subroutine
pop ax; to restore the original input character
cmp al, 0dh; whether the carriage return
je finished_input; is to move to finished_input
mov input [si], al; save a single character
inc si; visit a relative address of the next
jmp repeat_input; unconditional transfer to repeat_input

finished_input:; complete output
mov input [si], 24h; to just enter the end of the string plus sign ($)
call enter

mov si, 0; si buy 0
mov di, 0; di buy 0
mov cx, 8; set the password length detection, to include the end marker
check_password:; detection code
cmp cx, 0; cx to whether 0
je right; is to shift to right
mov bl, input [si]; the input of the address si inside information to a bl
mov dl, cmpare [di]; to cmpare of di address the information to a dl
cmp dl, bl; check whether dl and bl as
jne error; is not transferred to the error on
inc si; si + 1
inc di; di + 1
dec cx; cx by 1
jmp check_password

right:
call enter
lea dx, msg1
call dispchs
call enter
jmp exit

error:
call enter
lea dx, msg2
call dispchs
mov dl, 07h; output ascii code of the alarm (bell) control character bel (07h)
call dispch
call enter
jmp exit

exit: mov ah, 4ch; 4c number function call: end the current program and returns
int 21h; return to dos

enter proc near; display carriage return line feed subroutines
mov dl, 0dh; output ascii carriage return control character code cr
call dispch
mov dl, 0ah; output ascii code for line control character lf
call dispch
ret; Back
enter endp

dispch proc near; display a single character subroutine
mov ah, 02h; 2 number function call: display output character
int 21h; the completion of the output display
ret
dispch endp

dispchs proc near; display string subroutine
mov ah, 09h; 9 number function call: Display string
int 21h
ret
dispchs endp

code ends; code at the end of
end start_program; end of the assembly


; The above code into a text program such as Notepad, and save. (Such as passwd2.asm)
; Compile: masm passwd2.asm
; Link: link passwd2.obj
; Executive: passwd2.exe








Recommended links:



Rising Drug war Kaspersky million reward



SINA Sohu blog moving again PK



Infomation File And DISK Management



Articles about Help Tools



illustrator in the super-powerful hybrid tool (blend-3)



what are THE best pink laptops



Advanced Traceability - to meet the argument



I pirated your personal fight Daolian Thunder Sohu



WMV to QT



My favorite ANTI-VIRUS Tools



IPSEC and SSL VPN are two



"Actual recruitment" Are you afraid of when the "free labor"?



Guide E-Mail Tools



3ds max cattle production throughout Korean beauty Song Hye Kyo



TOD to WMV



MTS to AVI



1 comment:

  1. i think there are errors in lines 33 & 44 ^^

    ReplyDelete