flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
OzzY
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... |
|||
![]() |
|
OzzY
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 |
|||
![]() |
|
Madis731
But there still seems to be something wrong:
"thi" and "thi*" are valid passwords where * is whatever character ![]() |
|||
![]() |
|
Posetf
replace
rep cmpsb or cx,cx with repe cmpsb |
|||
![]() |
|
Madis731
Nice, its working now. I'm trying to loose that limit of same character buffer as password length right now.
|
|||
![]() |
|
Posetf
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. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.