Jump to content

Archived

This topic is now archived and is closed to further replies.

rab

[x86 ASM] CMP strings help

Recommended Posts

[code]
section .data
_execve equ 59
_passwd db 'hi', 0x00
_passwdlen equ $-_passwd
_wrong db 'WRONG',10,0
_wronglen equ $-_wrong
_right db 'RIGHT!!!',10,0
_rightlen equ $-_right
_write equ 4
_stdout equ 1
_exit equ 1

section .text
global _start

_start:
pop eax
pop ebx
pop ebx

cmp eax, 2
jne _die
mov eax, 0
jmp _checkpasswdstart

_checkpasswdstart:
cmp ebx[eax], _passwd[eax]
jne _wrongpasswd
cmp eax, _passwdlen
je _winner
inc eax
jmp _checkpasswdstart

_wrongpasswd:
mov eax, _write
mov ebx, _stdout
mov ecx, _wrong
mov edx, _wronglen
int 0x80

jmp _die

_winner:
mov eax, _write
mov ebx, _stdout
mov ecx, _right
mov edx, _rightlen
int 0x80

jmp _die

_die:
mov eax, _exit
xor ebx, ebx
int 0x80
[/code]

I've tried google, but found nothing on what im trying to do.
I want to compare byte by byte to see if the passwords are right. I'm just starting out on ASM so constructive criticism and useful pointers will be much appriciated.

Share this post


Link to post
Share on other sites
Perhaps compare each byte of the string, using a loop (with an conditional jmp)... If the byte matches the byte of the password...

Basically go through each byte of the password checking if it matches... Rather than trying to compar strings..

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.