Jump to content

x86 Assembler ASM "Encryption program" - need Ugrent HELP please!

- - - - -

  • Please log in to reply
3 replies to this topic

#1
thunderbird

thunderbird

    Newbie

  • Members
  • Pip
  • 3 posts
hi everyone!
this is my encryption routine (using standard call) in x86 Assembler

__ASM{

encrypt: 
           push ebp
           mov ebp,esp
           mov  eax, [ebp+8]
           mov  ecx, [ebp+12]

           push eax            
                   and eax,0xAA            
                   not al                
                   mov edx,eax            
                   pop eax                
                   and eax,0x55            
                   xor ecx,edx            
                   xor ecx,eax            
                   rol cl,1                
                   rol cl,1            
                   mov eax,ecx    
        
                   sub al,0x20            
           pop ebp
           ret                    
    }
all im trying to do now is Reverse the "encrypt" Algorithms Effect (need to create a DECRYPT routine)
if anyone can help me, it would be much appreciated!
thanks :) x

ps..if you need any more information, let me know .

Edited by Alexander, 02 April 2011 - 03:42 AM.
Added code tags (# button)


#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
Shouldn't you "mov esp, ebp", before you "pop ebp", at the end of the routine?

And another thing, can you at least try to do that and then if you get stuck, or if you have a question, you can ask here?

Edited by dargueta, 11 April 2011 - 01:36 PM.


#3
thunderbird

thunderbird

    Newbie

  • Members
  • Pip
  • 3 posts
hey, yeah i could do that to be safe so the stack pointer is pointing at EBP before i hit return. thanks for that. its just that im finding it difficult to reverse the effect of this encryption routine.

push eax    
and eax,0xAA    
not al    
mov edx,eax    
pop eax    
and eax,0x55    
xor ecx,edx    
xor ecx,eax    
rol cl,1    
rol cl,1    
mov eax,ecx    
sub al,0x20

basically the program im writing asks users for 5 characters(alphanumeric), these are then put through the "encryption routine" (code as shown above).
the program then outputs the "encrypted string" in ASCII
all im trying to do now is Reverse the encryption routine so the program can OUTPUT the 5 characters initially entered by the user.

if you have any idea of how i can go about this, it would be really helpful

thanks

Edited by Alexander, 02 April 2011 - 03:42 AM.


#4
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
Well, first of all we would want to add 0x20.
Then we need to rotate right by 2.

And then we get the output, d (for an example), of the equation.
d= a ^ (a & 0xAA) ^ (a & 0x55) 

If this was algebra, with regular operations, then I think I would have been able to solve the equation, probably.
But I don't really know what to do with the equation.

According to what I came up with, after looking at that equation a little more:
d= a ^ (a & 0xAA) ^ (a & 0x55) = -1

no matter what 'a' is; if anyone else on this forum got something different, you can post, but that's what I got.

So I don't know how to convert -1 back to whatever value 'a' was.

Edited by dargueta, 11 April 2011 - 01:35 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users