this might help you a bit. its in a different syntax though and i made it for d2jsp crack me thread i made which is now dead but it should help you. i would personally use 3 registers. 1 for your std input from user or w/e, 1 for the character array and 1 for the size of the character array.
from there i would loop byte to byte xoring to check for like-ness of the two characters. although in my application i am simply displaying a message if the values are different or the same and exiting but the logic behind this would be if the values ARE the same to jump to a new label in which to do a char replace. (or even a asm function.)
since you would have the current position in the array you should be able to quickly goto that position and make a change. hopefully that helped you a bit.
if all else fails you can compile your C++ program and run objdump on it in linux to see its asm output
Code
.section .data
enter_pass:
.ascii "Enter the password\n\0"
password:
.ascii "abgirl"
.equ password_len, . - password
corr_pass:
.ascii "Password is right\n\0"
incorr_pass:
.ascii "Password is wrong\n\0"
.section .bss
.equ in_pass_size, 500
.lcomm in_pass, in_pass_size
.section .text
.global _start
_start:
movl $1, %ebx
movl $enter_pass, %ecx
movl $20, %edx
movl $4, %eax
int $0x80 #linux print to stdout
movl $0, %ebx
movl $in_pass, %ecx
movl $in_pass_size, %edx
movl $3, %eax
int $0x80 #linux get line stdin
movl $password, %ebx
movl $in_pass, %edx
movl $password_len, %ecx #moving the values into the registers
loop: #the checking loop (dont mind the registers this is 32bit but the logic is there (this is also at&t syntax so it looks a bit different)
movb (%ebx), %al #move first byte of ascii array into %al (to be checked)
xorb (%edx), %al #xors the first entered byte to the hard coded byte
cmpb $0, %al #if 0 is stored in %al (review xor and how it works if you dont understand why 0 is there)
jg incorr #if the output is greater than 0 its incorrect (aka letters are different. you can change this line to jump to a label to do a replace then add a label after the jg call to jump back into the checking.)
inc %ebx
inc %edx #increase the position of the stdin input as well as character array
dec %ecx #decrease the length of the character array
cmpl $0, %ecx #if there are still bytes to be read
jg loop #loop again (sicne we increased the addresses by 1 byte when the loop loops again it will be moving and checking the next bye in teh array)
jmp corr #else if there is no bytes and we havent jumped to incorrect we are good.
incorr:
movl $1, %ebx
movl $incorr_pass, %ecx
movl $19, %edx
movl $4, %eax
int $0x80 #print incorrect to stdout then exit
jmp return
corr:
movl $1, %ebx
movl $corr_pass, %ecx
movl $19, %edx
movl $4, %eax
int $0x80 #print correct to stdout
return:
movl $0, %ebx
movl $1, %eax
int $0x80 %linux exit
This post was edited by AbDuCt on Feb 15 2013 01:48pm