Clan x86
Technical (Development, Security, etc.) => General Programming => Botdev => Topic started by: Joe on August 20, 2005, 02:53:14 am
-
Yep! iago found the function, but I did all the porting. I actually tested it and it returned true on my key.
Option Explicit
' mov eax, 3
' mov esi, ecx
' mov ebp, edx
' xor ecx, ecx
'Top:
' movsx edx, byte ptr [ecx+esi]
' sub edx, 30h
' lea edi, [eax+eax]
' xor edx, edi
' add eax, edx
' inc ecx
' cmp ecx, 0Ch
' jl short Top
' xor edx, edx
' mov ecx, 0Ah
' div ecx
'
' movsx eax, byte ptr [esi+0Ch]
' movsx edx, dl
' add edx, 30h
' cmp eax, edx
' jnz bottom
' mov eax, 1
' retn 8
'bottom:
' xor eax, eax
' retn 8
Public Function VerifyKey(Key As String) As Boolean
Dim eax&, esi&, ecx&, ebp&, edx&, dl&
Let eax = 3
Let esi = 0 'it should be ecx, the pointer to the key, but we obviously dont need that
Let ebp = edx
Let ecx = ecx Xor ecx
Top:
Let edx = Asc(Mid(Key, ecx + 1, 1))
Let edx = edx - &H30
Let eax = eax + edx
Let ecx = ecx + 1
If ecx = &HC Then _
GoTo Top
Let edx = edx Xor edx
Let ecx = &HA
Let dl = ecx Mod 10
Let eax = Asc(Mid(Key, &HC))
Let edx = dl
Let edx = edx + &H30
If eax <> edx Then _
GoTo Bottom
Let VerifyKey = True: Exit Function
Bottom:
Let VerifyKey = True
End Function
-
Hmm, did you notice that you always return true no matter the result?
...
Let VerifyKey = True: Exit Function
...
Let VerifyKey = True
End Function
-
No wonder it worked ^^
Also, Let is entirely useless
With the correction (return false), it does not work.
-
Option Explicit
Private Sub Form_Load()
Call MsgBox(VerifyKey("0000000000003")) '// <-- Valid Key
End
End Sub
' mov eax, 3
' mov esi, ecx
' mov ebp, edx
' xor ecx, ecx
'Top:
' movsx edx, byte ptr [ecx+esi]
' sub edx, 30h
' lea edi, [eax+eax]
' xor edx, edi
' add eax, edx
' inc ecx
' cmp ecx, 0Ch
' jl short Top
' xor edx, edx
' mov ecx, 0Ah
' div ecx
'
' movsx eax, byte ptr [esi+0Ch]
' movsx edx, dl
' add edx, 30h
' cmp eax, edx
' jnz bottom
' mov eax, 1
' retn 8
'bottom:
' xor eax, eax
' retn 8
Public Function VerifyKey(Key As String) As Boolean
Dim eax&, esi&, ecx&, ebp&, edx&, edi&, dl&
Let eax = 3
Let esi = 1 '// Key pointer
'Let ebp = edx '// No clue what this does, but its not needed
Let ecx = ecx Xor ecx '// Key position
Top:
Let edx = Asc(Mid(Key, (ecx + esi), 1))
Let edx = edx - &H30 '// Move from the ASCII value of the number, to the numerical value
Let edi = eax + eax
Let edx = edx Xor edi
Let eax = eax + edx
Let ecx = ecx + 1
If Not ecx = &HC Then GoTo Top
Let edx = 0
Let edx = &HA
Let dl = eax Mod edx
Let eax = Asc(Mid(Key, (esi + &HC), 1))
Let edx = dl
Let edx = edx + &H30
If Not eax = edx Then GoTo Bottom
Let VerifyKey = True: Exit Function
Bottom:
Let VerifyKey = False: Exit Function
End Function
Fixed. I left the broken code so people can have a good laugh.
EDIT -
It was still always returning true. This time I actually did fix it.