ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Fri Jun 23, 2017 12:01 pm

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Jul 04, 2016 5:28 pm 

Joined: Sat Aug 09, 2014 2:34 pm
Posts: 713
Part of code for decrypt RAS archives from game Max Payne 1/2 (Android / PC). Maybe usefull for someone :)

Code:
struct RASHeader
{
   DWORD dwID;
   DWORD dwSeed;
};


Code:
void DecryptWithSeed(unsigned char *pBuffer, int dwSize, int dwSeed)
{
   if (!dwSeed)
      dwSeed = 1;

   if (dwSize > 0)
   {
      char wSeed = 18;
      char pTemp;
      for (int i = 0; i < dwSize; ++i)
      {
         dwSeed = -2 * (dwSeed / 177) + 171 * (dwSeed % 177);
         pTemp = ((pBuffer[i] << i % 5) | ((signed int)pBuffer[i] >> (8 - i % 5))) ^ wSeed;
         wSeed += 6;
         pBuffer[i] = pTemp + dwSeed;
      }
   }
}


Top
   
PostPosted: Tue Jul 05, 2016 3:12 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 6163
Well done:
http://aluigi.org/bms/max_payne_ras.bms

The header is visible but now the last step will be to undertand that decrypted data that probably has a second pass of encryption or it's encrypted using a different seed.


Top
   
PostPosted: Tue Jul 05, 2016 6:30 pm 

Joined: Sat Aug 09, 2014 2:34 pm
Posts: 713
Here my test tool for decrypt header and file table + sample of archive inside. In the fact header must be 0x2C bytes and encrypted only 0x24 bytes from 0x8 position.

Edited: Attached variant 2 :)


Attachments:
MPRASDecrypt-v2-src.rar [1.11 KiB]
Downloaded 343 times
MPRASDecrypt-src-bin.rar [129.79 KiB]
Downloaded 98 times
Top
   
PostPosted: Tue Jul 05, 2016 10:37 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 6163
Script 0.2, complete extraction :D


Top
   
PostPosted: Tue Jul 05, 2016 11:30 pm 

Joined: Sat Aug 09, 2014 2:34 pm
Posts: 713
Cool :D


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 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