This is the AMP version of this page.
If you want to load the real page instead, click this text.

Tutorial How to find decryption key for cocos2djs

AndnixSH

PMT Elite Modder
Staff member
Modding-Team
Rarely seen games based on cocos2djs, the game is compiled and encrypted to .jsc files. I think Cocos2d would come out encrypted by default with it's hardcoded key. Finding decryption key is pretty easy

This is not for all cocos2djs games. Some games may hide the decryption key, making it hard to find, so you would need to reverse deeper and debug it

Let's get started!

In this tutorial, I use this game Download LifeSimulator - Chinese Life APK for Android (Free)

Extract jsc files from assets folder of APK file

Now we gonna look after the key

Method 1: Hex editor
Use any hex eidtor that support string search. I use 010 editor

Search for jsb-adapter, jsb-builtin.js or main.js

The key should be located between Game. and .jsb-adapter . In my case the key is e07a4d47-b82e-4f



If it's blank like this, or you can't find the key, it must have been encoded or encrypted. Use IDA Pro instead



Method 2: IDA Pro
It is highly recommended to use IDA Pro 7.5 and later which can display string correctly. Older version may not be able to display string correctly

I WILL NOT SHARE LINK TO IDA PRO. HOWEVER IT IS EASIER TO FIND IF YOU USE BRAVE OR DUCKDUCKGO SEARCH


Load the libcoco2djs.so to IDA Pro

Search for AppDelegate::applicationDidFinishLaunching

Press F5 to view pseduocode, and tada!, here is the decryption key



Tools to decrypt and encrypt
You can use any xxtea tools to decrypt and encrypt, like Mika's Tool Encryption & Decryption JSC Files to Modded Games Based Cocos2djs - Platinmods.com - Android & iOS MODs, Mobile Games & Apps

I successfully decrypted .jsc to .js

 
Last edited:
Why waste so much time in loading the Lib in IDA ? Follow this instead:
1. open the libcoco2djs.so in HxD
2. search for "jsb-adapter" (ignore quotes)

the key is located between two dots and the second dot is just before "jsb-adapter"
Here's a screenshot:



In my case the key is "e7-a4d47-b82e-4f".
I hope it saves time :)
 
I know this method, but i forgot to update the tutorial
However, you can't do this on some games due to string being encrypted or encoded but IDA Pro can decrypt it
 
I know this method, but i forgot to update the tutorial
However, you can't do this on some games due to string being encrypted or encoded but IDA Pro can decrypt it
Yes, but people can try this first :) and if they cannot find it then they can proceed with IDA.
 
Thank you verry much for help, but with a decryption tool for pc games, can u help me?
Every game has their own encryption system.
The one in this tutorial is for most games which use cocos2d engine and rely on jsc files (which is just a possibility of many)
You will have to reverse which encryption the game you are working has and find a way to decrypt it.
 
Even if i analyze the file the options still remain the same as i have shown on screenshot, just that they are not greyed out anymore. Pressing f5 or shift f5 does not show me the pseudocode.
You nust open a function in order to use it.
It seems you are totally new to IDA, please refer to online tutorial howto use it