GoldStar611
December 13th, 2010, 02:08
Hello all, I've been mostly a lurker for some number of years, studying assembly at my own slow pace, but I enjoy teasing my brain from time to time. One such protection that has always held some curiosity is called HexaLock. It's not too common but among document protection.
I wrote a bypass tool which fooled HexaLock into thinking that an authorized program (acrord32.exe) was opening an encrypted file and it would do all the hard work for me. A simple call to an unhooked WriteFile easily saves the plaintext.
But that wasn't enough for me, learning is the best part I beleive. So I've taken a stab at the decryption process using ollydbg and believe to have found a weakness on what I'll call the inner layer.
AL set with "initial condition"
ESI set with pointer to decryption block
EDI set with pointer to encrypted file contents
EBX set to 0
Loop:
MOV CL, BYTE [ESI] ;take byte from decryption block
XOR CL, AL
XOR BYTE [EDI], CL
INC ESI, EDI, EBX
is EBX > 2047?
if No goto loop
if yes do some other stuff
The proposed weakness: Given known plaintext since all valid pdf files start with %PDF and given decryption block, and given initial condition byte (or maybe given ALL possible conditions) it is possible to find the 2048 byte block of memory to decrypt the file given the file is "random enough" This won't however be much help to the outer blocks as they have also initial conditions which do not have much in common with the rest of the loop. This is what I'm having problems with how to go about solving.
I wrote a bypass tool which fooled HexaLock into thinking that an authorized program (acrord32.exe) was opening an encrypted file and it would do all the hard work for me. A simple call to an unhooked WriteFile easily saves the plaintext.
But that wasn't enough for me, learning is the best part I beleive. So I've taken a stab at the decryption process using ollydbg and believe to have found a weakness on what I'll call the inner layer.
AL set with "initial condition"
ESI set with pointer to decryption block
EDI set with pointer to encrypted file contents
EBX set to 0
Loop:
MOV CL, BYTE [ESI] ;take byte from decryption block
XOR CL, AL
XOR BYTE [EDI], CL
INC ESI, EDI, EBX
is EBX > 2047?
if No goto loop
if yes do some other stuff
The proposed weakness: Given known plaintext since all valid pdf files start with %PDF and given decryption block, and given initial condition byte (or maybe given ALL possible conditions) it is possible to find the 2048 byte block of memory to decrypt the file given the file is "random enough" This won't however be much help to the outer blocks as they have also initial conditions which do not have much in common with the rest of the loop. This is what I'm having problems with how to go about solving.