0
我试图做一个简单的小密码程序(为了进一步扩展我的知识),我只是无法得到它的工作。问题是即使我输入正确的密码,它也不会跳转到标签“good”。ASM(at&t系统V 32位异或)
我的验证密码的方式是将用户提交的密码与内置密码进行异或,如果它返回0表示它们是相同的。 (因为任何异或者是0)
所以我的错误很可能在cmpl和je命令或我的xoring本身内。任何帮助将是很好,我根本无法找到我的错误。
.section .data
hmm:
.ascii "Enter the password\n\0"
password:
.ascii "abgirl"
success:
.ascii "Password is right\n\0"
bad:
.ascii "password is wrong\n\0"
.section .bss
.equ buffer_size, 500
.lcomm buffer_data, buffer_size
.section .text
.global _start
_start:
pushl $hmm
call printf #print $hmm
movl $0, %ebx
movl $buffer_data, %ecx
movl $buffer_size, %edx
movl $3, %eax
int $0x80 #get user input
movl $password, %eax
xorl $buffer_data, %eax #xor the passwords (value stored in eax)
cmpl $0, %eax #compare
je good #jump if equal
pushl $bad
call printf #print bad pass if not equal
jmp end #jump to exit
good:
pushl $success
call printf #print $success
end:
movl $0, %ebx
movl $1, %eax
int $0x80 #cleanup and exit
非常感谢我得到它与您的帮助。虽然有一种方法来一次完整的密码,因为我听说过超时强制攻击:如果密码是“布鲁斯”,你可以尝试“a”需要0.2ms尝试“b”需要0.4ms,所以你知道b是在通过然后尝试所有“r”(每个取0.4ms)然后它需要0.6ms,所以你知道r是它的一部分,等等(比喻时间) – abduct 2011-06-08 21:47:53
不,没有。在剩余4个字节的情况下,您可以比较长时间,这意味着只有在前4个字符正确时才会更改时间。您也可以尝试对其进行编程,以便检查每个字符,即使第一个字符是错误的。 – ughoavgfhw 2011-06-09 00:46:27