LaptoniC
December 28th, 2007, 09:55
Hi,
I think I am rusted,my brain stopped for simple encryption.
I am reversing a dictionary application.Dictionary use below code to decrypt its database.So, I made a program to decrypt database and changed it.I have also disabled this process so I can use plain text database for dictionary. My problem is what is the code that makes reverse of this ? The division part struggles me maybe it is to obvious to write in simple code.Thanks
arg_0=length of text
arg_4=pointer to encrypted text
I think I am rusted,my brain stopped for simple encryption.
I am reversing a dictionary application.Dictionary use below code to decrypt its database.So, I made a program to decrypt database and changed it.I have also disabled this process so I can use plain text database for dictionary. My problem is what is the code that makes reverse of this ? The division part struggles me maybe it is to obvious to write in simple code.Thanks
arg_0=length of text
arg_4=pointer to encrypted text
Code:
decryptit proc
arg_0 = dword ptr 4
arg_4 = dword ptr 8
push ebx
mov ebx, [esp+4+arg_0]
push ebp
push esi
push edi
mov edi, [esp+10h+arg_4]
test ebx, ebx
jl short loc_401089
loc_401050:
xor ecx, ecx
mov esi, ebx
loc_401054:
cmp ecx, ebx
jge short loc_4010CF
mov al, [ecx+edi]
cmp al, 1Fh ;skip some chars
jbe short loc_401085
lea edx, [esi-1] ;len-1 variable
and eax, 0FFh
xor edx, 0FFFFFFAAh
mov ebp, 0E0h
and edx, 0FFh
sub eax, edx
add eax, 0C0h
cdq
idiv ebp
add dl, 20h
mov [ecx+edi], dl
loc_401085:
inc ecx
dec esi
jmp short loc_401054
loc_401089:
lea eax, [ebx-1]
test eax, eax
jl short loc_401050
mov esi, ebx
lea ecx, [eax+edi]
sub esi, edi
lea ebp, [eax+1]
loc_40109A:
mov al, [ecx]
cmp al, 7Ah
jnb short loc_4010C9
lea edx, [esi+ecx-1]
and eax, 0FFh
and edx, 80h
xor edx, 55h
sub eax, edx
sub eax, 20h
cdq
xor eax, edx
sub eax, edx
and eax, 0FFh
xor eax, edx
sub eax, edx
add al, 20h
mov [ecx], al
loc_4010C9:
dec ecx
dec ebp
jnz short loc_40109A
jmp short loc_401050
loc_4010CF:
pop edi
pop esi
pop ebp
pop ebx
retn
decryptit endp