Jump to content


[x86 ASM] CMP strings help

  • Please log in to reply
1 reply to this topic

#1 rab

  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 18 October 2006 - 01:45 AM

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

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

		cmp ebx[eax], _passwd[eax]
	jne _wrongpasswd
	cmp eax, _passwdlen
	je _winner
	inc eax
	jmp _checkpasswdstart
	mov eax, _write
	mov ebx, _stdout
	mov ecx, _wrong
	mov edx, _wronglen
	int 0x80
	jmp _die

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

	jmp _die

	mov eax, _exit
	xor ebx, ebx
	int 0x80

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.

#2 heckenschutze

  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 25 October 2006 - 06:23 AM

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..

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users