ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Mon Jul 16, 2018 12:46 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Encrypting via Blowfish?
PostPosted: Thu Sep 10, 2015 9:35 pm 

Joined: Wed Aug 13, 2014 6:43 pm
Posts: 22
Hey, it's me again! It's been a while.
So i'm currently working on game files that are encrypted via blowfish, to modify them and use them in the game again. The decryption works wonderfully painless, using just these 3 lines:

Code:
  Encryption blowfish KEY
  log MEMORY_FILE FILESTART FILESIZE MEMORY_FILE
  Encryption "" ""


However, it seems i can't ENcrypt with the same. If i use the above on an encrypted file once, it's plain, but when i use it on the file twice, the resulting file doesn't match the original.
I don't know much about encryptions, which is why i like using QuickBMS which supports tons of them natively, so i just assumed you could use the same command to encrypt a file again with a certain key. Is that not the case?


edit: Unrelated to this, but isn't there some kind of simple bytesum function somewhere in QuickBMS? I was looking for it, but didn't find anything. I somehow felt like there should have been, even though it's trivial to solve it with just 4 lines of code:
Code:
for i = 0 < FILESIZE
    get SBYTE byte
    math SUM + SBYTE
next i


Top
   
PostPosted: Thu Sep 10, 2015 10:02 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 8453
To encrypt use:
Encryption blowfish KEY "" 1

Where:
"" is the field for the ivec (in this case left empty)
1 is the mode: 0=decrypt 1=encrypt

Regarding the bytesum algo, take a look at Encryption crc that contains a complete engine to calculate many types of checksums, most of which are documented only in the crc.c source code.
In your case I guess you want the following:
Encryption crc "32 0 0 6"

Where:
32 is the size of the crc
0 is the initial value of the crc
0 is the final xor value
6 is the type corresponding to "MYCRC + MYBYTE" which is what you requested

The result is stored in the QUICKBMS_CRC variable.


Top
   
PostPosted: Thu Sep 10, 2015 10:38 pm 

Joined: Wed Aug 13, 2014 6:43 pm
Posts: 22
Oh wow, that was simple. I guess i missed the MODE parameter explanation at the end of that looooong list of algorithms. :lol: I mostly had to work with xor "encryption" so far, which works both ways.
Now that they work, i'll post the scripts on the forum for posterity, over in the "Savegames" section. :)

As for the bytesum thing, i had a feeling it was somewhere in that CRC encryption thing. I didn't take too hard a look at it, since it kinda felt overqualified, like cracking a nut with a sledgehammer.

Thanks for the quick response!


Top
   
PostPosted: Fri Sep 11, 2015 12:53 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 8453
Yeah, I agree, the list of encryption and comtype algorithms is really huge and confusing, and the lack of documentation for the CRC algorithms doesn't help too. Luckily crc.c should be enough easy to understand and, in case of problems to recognize the correct algorithm, an idea is to use the crc scanner that provides the parameters to use.

The idea of having CRC and HASH algorithms in the Encryption command was caused by the experimental nature of this feature, probably would be better to have a separate new command for that like CalcHash or similar with the same identical syntax and usage of the Encryption command.
But it's just an idea, I would like to avoid to add new commands to quickbms.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited