Difference between revisions of "Example 1"

From SkullSecurity
Jump to navigation Jump to search
Line 1: Line 1:
{{Infobox assembly}}
{{Infobox assembly}}
Welcome to the first example assembly1 If you've read and understood all the sections up to here, there won't be any surprises here.
That way you should approach this is to to do the following:
# Copy all the assembly code to your IDE or somewhere safe.
# Go through each line, and make a note of what it does (typically, by putting a ; at the end and adding a comment works well). Try and understand what the code is doing.
# Go through each line, and convert it to the equivalent C code (or Java, if you're more comfortable with that).
# Try and combine and reduce the code to make it as simple as possible.
I'll go through those steps here, to hopefully give you an idea of how to approach a function like this. I highly recommend you try it yourself first, though.


<pre>
<pre>
  ; Note: ecx is a pointer to a 13-digit Starcraft cdkey
  ; This is a function that returns 1 if it's a valid key, or 0 if it's invalid
   mov    eax, 3
   mov    eax, 3
   mov    esi, ecx
   mov    esi, ecx

Revision as of 01:08, 13 March 2007

Assembly Language Tutorial
Please choose a tutorial page:

Welcome to the first example assembly1 If you've read and understood all the sections up to here, there won't be any surprises here.

That way you should approach this is to to do the following:

  1. Copy all the assembly code to your IDE or somewhere safe.
  2. Go through each line, and make a note of what it does (typically, by putting a ; at the end and adding a comment works well). Try and understand what the code is doing.
  3. Go through each line, and convert it to the equivalent C code (or Java, if you're more comfortable with that).
  4. Try and combine and reduce the code to make it as simple as possible.

I'll go through those steps here, to hopefully give you an idea of how to approach a function like this. I highly recommend you try it yourself first, though.

   ; Note: ecx is a pointer to a 13-digit Starcraft cdkey
   ; This is a function that returns 1 if it's a valid key, or 0 if it's invalid
   mov     eax, 3
   mov     esi, ecx
   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]
   add     edx, 30h
   cmp     eax, edx
   jnz     bottom

   mov     eax, 1
   ret

 bottom:
   xor     eax, eax
   ret