flat assembler
Message board for the users of flat assembler.
Index
> Main > Problem with syntax |
Author |
|
OzzY 17 Apr 2004, 19:33
Well I have done it:
Code: org 100h jmp start ;buffer for Keyboard Input, formatted for easy reference: MaxKbLength db 05h KbLength db 00h KbBuffer dd 00h ;strings: note the password is not encrypted, though it should be... szGuessIt db 'Care to guess the super-secret password?',0Dh,0Ah,'$' szString1 db 'Congratulations! You solved it!',0Dh,0Ah, '$' szString2 db 'Ah, damn, too bad eh?',0Dh,0Ah,'$' secret_word db "this" start: call Query ; prompt user for password mov ah, 0Ah ; DOS 'Get Keyboard Input' function mov dx, MaxKbLength ; start of buffer int 21h call Compare ; compare passwords and patch exit: mov ah,4ch ; 'Terminate to DOS' function int 21h ;=========================================== Query: mov dx, szGuessIt ; Prompt string mov ah, 09h ; 'Display String' function int 21h ret ;=========================================== Reply: PatchSpot: mov dx, szString2 ; 'You failed' string mov ah, 09h ; 'Display String' function int 21h ret ;=========================================== Compare: mov cx, 4 ; # of bytes in password mov si, KbBuffer ; start of password-input in Buffer mov di, secret_word ; location of real password rep cmpsb ; compare them or cx, cx ; are they equal? jnz bad_guess ; nope, do not patch mov word ptr cs:PatchSpot[1], szString1 ;patch to GoodString bad_guess: call Reply ; output string to display result ret end start ; EOF ======================================================================= but still don't work... Please help!! Thanks... |
|||
17 Apr 2004, 19:33 |
|
OzzY 17 Apr 2004, 19:40
Oh yeah!! I've found the answer by myself....
here it is: Code: org 100h jmp start ;buffer for Keyboard Input, formatted for easy reference: MaxKbLength db 05h KbLength db 00h KbBuffer dd 00h ;strings: note the password is not encrypted, though it should be... szGuessIt db 'Care to guess the super-secret password?',0Dh,0Ah,'$' szString1 db 'Congratulations! You solved it!',0Dh,0Ah, '$' szString2 db 'Ah, damn, too bad eh?',0Dh,0Ah,'$' secret_word db "this" start: call Query ; prompt user for password mov ah, 0Ah ; DOS 'Get Keyboard Input' function mov dx, MaxKbLength ; start of buffer int 21h call Compare ; compare passwords and patch exit: mov ah,4ch ; 'Terminate to DOS' function int 21h ;=========================================== Query: mov dx, szGuessIt ; Prompt string mov ah, 09h ; 'Display String' function int 21h ret ;=========================================== Reply: PatchSpot: mov dx, szString2 ; 'You failed' string mov ah, 09h ; 'Display String' function int 21h ret ;=========================================== Compare: mov cx, 4 ; # of bytes in password mov si, KbBuffer ; start of password-input in Buffer mov di, secret_word ; location of real password rep cmpsb ; compare them or cx, cx ; are they equal? jnz bad_guess ; nope, do not patch mov word ptr PatchSpot+1, szString1 ;patch to GoodString bad_guess: call Reply ; output string to display result ret ; EOF ======================================================================= This shows that FASM can produce polymorphic code!! If anyone likes polymorphic code, please contact me in this forum to let us change ideas... Thanks anyway, and thanks for the very good (the best) assembler!! OzzY |
|||
17 Apr 2004, 19:40 |
|
Madis731 25 Apr 2004, 18:04
But there still seems to be something wrong:
"thi" and "thi*" are valid passwords where * is whatever character |
|||
25 Apr 2004, 18:04 |
|
Posetf 26 Apr 2004, 01:43
replace
rep cmpsb or cx,cx with repe cmpsb |
|||
26 Apr 2004, 01:43 |
|
Madis731 26 Apr 2004, 14:31
Nice, its working now. I'm trying to loose that limit of same character buffer as password length right now.
|
|||
26 Apr 2004, 14:31 |
|
Posetf 26 Apr 2004, 22:36
Madis731 wrote: Nice, its working now. I'm trying to loose that limit of same character buffer as password length right now. I fixed that but deleted the code . I think it was just changing the Max Length constant and adding ,0x0D after the password. Oh, beware that first string will get overwritten since you've only declared a one byte buffer, not that it should be a problem. |
|||
26 Apr 2004, 22:36 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.