Jump to content

[x86 ASM] CMP strings help


rab

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.