'Reversing an encryption routine in asm
I am having a really hard time trying to reverse this encryption routine, and honestly understanding it as well. Any help would be appreciated.
encrypt_22:
push ebp // save call site base pointer to the stack
mov ebp, esp // new stack frame base
// // // // // // // // // // // ///
push edi // free up register
push ecx // copy original character and free up register
and byte ptr[eax], 0x0F // substract 12 bits from the value of og Ekey
cmp byte ptr[eax], 0x00 // condition, Ekey != 0
jnz x22 // if condition true jump to x22
mov edi, 0x02 // store 2 in here
jmp z22 // if condition, Ekey = 0, jump to z22
x22 : movzx edi, byte ptr[eax] // start counter
z22 : add byte ptr[eax], 0x0A // add to Ekey
pop eax // get original character
y22 : dec eax // mangle Ekey
dec edi // condition, if edi = 0; edi--
jnz y22 // jump to y22
not al // mangle by flipping
dec eax // mangle by substracting by one
pop edi // restore Ekey
xor al, 0x0A // substract by ten to mangle
mov edx, eax // put mangled result in output
// // // // // // // // // // // ///
mov esp, ebp // point stack pointer at base pointer
pop ebp // restore call site base pointer
ret 8 // return and scrub the stack
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
