Jump to content

6 posts in this topic

Recommended Posts

Posted

Intro:
There's a bunch of tries to to decrypting lua but none of it isnt clear enough how to do it. I'm aware that this approach isnt good enough, because too much step that you'll not need to do but i'm still write it instead. Code in this tutorial ofcourse just bunch of copy-pasta stackoverflow.

Prerequisites
1. Frida (optional)
2. Disassembler (IDA, r2, ..)
3. Python (optional) (I'll use python in this tutorial)
4. A little knowledge about this

What will you need to do?
1. Get the KEY for decryption,
2. Write a script for decryption,
3. Edit the lua (Self explanation),
4. Encrypt back the file (Self explaination) (Same as step 2, but you'll encrypt instead of decrypt),
5. PROFIT.

---- Step by step ----

Get the KEY for decryption
There's bunch of way to do it, some of them:
1. XREFS for XXTeaLuaLoader::setXXTeaKey(string), and you can see it clearly. Most used methods among many games.
nJX33Yr.png
2. Use Frida. I'll explain it on 2nd post.
3. http://forum.xda-developers.com/showthread.php?p=12853986#post12853986
4. etc.. You get the idea.

Write a script for decryption
This is an example of use for XXTEA encryption, requirements(xxtea-py)

 
Code (Text):





#!/usr/bin/env python
import xxtea

chiper = open("assets/script/fund.lua", "rb").read()

out = open("out.lua", "wb")

key = b'mrgj'

out.write(xxtea.encrypt(chiper, key))

out.close()END

Example of use of frida (https://github.com/antojoseph/frida-android-hooks)

As described here, 

Opening the lua files with hex editor reveals that they use XXTEA block cipher.

Analyze libjinqu.so and it blatantly shows the following decryption subroutines:
xxtea_decrypt
cocos2d::extra::CCCrypto::decryptXXTEA

Get a pseudocode generator and copy the program in C++.

. We need to put a hook either at xxtea_decrypt or cocos2d::extra::CCCrypto::decryptXXTEA. Then prints out the arguments passed.
We know that args[2] is the one holding the pointer to key from decompile xxtea_decrypt lib.so
Oh5SCFC.png 
Explaination, v9 is the one holding the chiper text, v30 chipertext len(?), v13 pointer to key, v14 is key.length.
Its obvious if we want to leak the key we need to print args[3] bytes at args[2]. This is an example of use for it.

 

#!/usr/bin/env python
import frida
import sys

package_name = "com.gamebau.pq"

def get_messages_from_js(message, data):
            print(message)

jsc = """
Interceptor.attach (Module.findExportByName( "libgame.so", "xxtea_decrypt"), {
    onEnter: function (args) {
        console.log("----------------BEGIN----------------");
        console.log(hexdump(Memory.readByteArray(args[2], 12),{
         offset: 0,
         length: 12,
         header: true,
         ansi: true
        }));
    },
    onLeave: function (retval) {
        console.log("Decrypt:");
        console.log(hexdump(Memory.readByteArray(retval, 16),{
         offset: 0,
         length: 16,
         header: true,
         ansi: true
        }));
        console.log("-----------------END-----------------");   
    }
});
"""

process = frida.get_usb_device().attach(package_name)
script = process.create_script(jsc)
script.on('message',get_messages_from_js)
script.load()
sys.stdin.read()

profit,
gohBm09.png
 
--Update, forgot to mention about this. Another note, some games tries to pack the assets with common file compressor. While loading it, it tries to unpack the assets on stream. As you can see on the image, its PK file header. With simple google search you can deduce its a zip alike compression. Try to extract the decrypted file with 7zip/Winrar/etc.. and you could see the unpacked file.

Image:
gohBm09.png
 
 
Credits: Wobm And Stack Overflow

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Our picks

    • Pal Go: Tower Defense TD v0.3.64 [+7 Cheats]
      Modded/Hacked App: Pal Go: Tower Defense TD By Playwind Ltd
      Bundle ID: com.playwindgames.freedefender
      iTunes Store Link: https://apps.apple.com/us/app/pal-go-tower-defense-td/id6479316663?uo=4


       

      🚀 Hack Features

      - [VIP] Freeze Currency (Currency will not decrease when used)

      - [VIP] Currency Always Enough (Buy even when you don't have enough currency)

      - [Free] Higher Recruit Energy (Gives 500 Recruit Energy Every Wave)

      - [Free] Always Can Drag Hero

      - [Free] Skip Ads

      - [Free] No Attack Cooldown

      - [Free] Global Speed Multiplier (Enable Inside Battle)

       

      Warning


      Do not use on main account. There is a chance of ban. Not responsible for any bans.

       


      🍏 For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/forum/79-no-jailbreak-section/
      🤖 Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      • 39 replies
    • Pal Go: Tower Defense TD v0.3.64 [+7 Jailed Cheats]
      Modded/Hacked App: Pal Go: Tower Defense TD By Playwind Ltd
      Bundle ID: com.playwindgames.freedefender
      iTunes Store Link: https://apps.apple.com/us/app/pal-go-tower-defense-td/id6479316663?uo=4


       

      Hack Features

      - [VIP] Freeze Currency (Currency will not decrease when used)

      - [VIP] Currency Always Enough (Buy even when you don't have enough currency)

      - [Free] Higher Recruit Energy (Gives 500 Recruit Energy Every Wave)

      - [Free] Always Can Drag Hero

      - [Free] Skip Ads

      - [Free] No Attack Cooldown

      - [Free] Global Speed Multiplier (Enable Inside Battle)

       

      Warning


      Do not use on main account. There is a chance of ban. Not responsible for any bans.

       

      Jailbreak required iOS hacks: https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APKs: https://iosgods.com/forum/68-android-section/
      • 64 replies
    • NETHER MONSTERS v1.03 [+4 Cheats]
      Modded/Hacked App: NETHER MONSTERS By ARAKUMA STUDIO S.A.
      Bundle ID: com.ArakumaStudio.NetherMonsters
      iTunes Store Link: https://apps.apple.com/us/app/nether-monsters/id6742568029?uo=4

       

      🤩 Hack Features

      - Never Die
      - Get IAP Products  
      - Add Currency
      - Auto Win (Enable inside battle)
      • 4 replies
    • NETHER MONSTERS v1.03 [+4 Jailed Cheats]
      Modded/Hacked App: NETHER MONSTERS By ARAKUMA STUDIO S.A.
      Bundle ID: com.ArakumaStudio.NetherMonsters
      iTunes Store Link: https://apps.apple.com/us/app/nether-monsters/id6742568029?uo=4



      🤩 Hack Features

      - Never Die
      - Get IAP Products  
      - Add Currency
      - Auto Win (Enable inside battle)
      • 3 replies
    • [ FFBE WoTV Japan ] FFBE幻影戦争 WAR OF THE VISIONS Cheats v12.0.2 +3
      Modded/Hacked App: FFBE幻影戦争 戦略RPG/シミュレーションゲーム By SQUARE ENIX Co., Ltd.
      Bundle ID: com.square-enix.WOTVffbejp
      iTunes Store Link: https://apps.apple.com/jp/app/ffbe%E5%B9%BB%E5%BD%B1%E6%88%A6%E4%BA%89-%E6%88%A6%E7%95%A5rpg-%E3%82%B7%E3%83%9F%E3%83%A5%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%B2%E3%83%BC%E3%83%A0/id1443703517?uo=4


      Hack Features:
      - Multiply Attack
      - Multiply Defense
      - Full Map Movement


      iOS Hack Download Link: https://iosgods.com/topic/173484-ffbe-wotv-japan-ffbe%E5%B9%BB%E5%BD%B1%E6%88%A6%E4%BA%89-war-of-the-visions-cheats-v916-3/
      • 89 replies
    • Treasure Party: Puzzle Fun! v2.34.3 [ +3 Jailed ] Coins Max
      Modded/Hacked App: Treasure Party: Puzzle Fun! By PlayQ Inc.
      Bundle ID: net.playq.treasureparty4
      iTunes Store Link: https://apps.apple.com/us/app/treasure-party-puzzle-fun/id1668898401?uo=4

       
      Hack Features

      - Coins
      - Lives
      - Moves



      Jailbreak required iOS hacks: https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APKs: https://iosgods.com/forum/68-android-section/
      • 14 replies
    • Treasure Party: Puzzle Fun! v2.34.3 [ +3 Cheats ] Coins Max
      Modded/Hacked App: Treasure Party: Puzzle Fun! By PlayQ Inc.
      Bundle ID: net.playq.treasureparty4
      iTunes Store Link: https://apps.apple.com/us/app/treasure-party-puzzle-fun/id1668898401?uo=4

       

      Hack Features

      - Coins
      - Lives
      - Moves



      For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/

       

      iOS Hack Download Link


      Hidden Content

      Download Hack
      • 10 replies
    • Dream Resort - Match 3 Games v1.3.2 [ +7 Jailed ] Auto Win
      Modded/Hacked App: Dream Resort - Match 3 Games By F.O.G LIMITED
      Bundle ID: com.dream.resort.candy.match.mania.ios
      iTunes Store Link: https://apps.apple.com/us/app/dream-resort-match-3-games/id6737011572?uo=4
       

      🚀 Hack Features

      - Auto ADS Disable

      - Coins

      - Diamonds

      - Lives Cost

      - Moves Freeze

      - Booster [ Buy Get Unlimited After use Then work ]

      - Auto win 


      🍏 Jailbreak iOS hacks: https://iosgods.com/forum/5-game-cheats-hack-requests/
      🤖 Modded Android APKs: https://iosgods.com/forum/68-android-section/
      • 9 replies
    • Dream Resort - Match 3 Games v1.3.2 [ +7 Cheats ] Auto Win
      Modded/Hacked App: Dream Resort - Match 3 Games By F.O.G LIMITED
      Bundle ID: com.dream.resort.candy.match.mania.ios
      iTunes Store Link: https://apps.apple.com/us/app/dream-resort-match-3-games/id6737011572?uo=4

       

      🔧 Mod Requirements

      - Jailbroken iPhone or iPad.
      - iGameGod / Filza / iMazing.
      - Cydia Substrate, ElleKit, Substitute or libhooker depending on your jailbreak (from Cydia, Sileo or Zebra).

       

      🚀 Hack Features

      - Auto ADS Disable

      - Coins

      - Diamonds

      - Lives Cost

      - Moves Freeze

      - Booster [ Buy Get Unlimited After use Then work ]

      - Auto win 


      🍏 For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/forum/79-no-jailbreak-section/
      🤖 Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      • 10 replies
    • Plant Power - Fruit Showdown! v7.5 [ +20++ Cheats ] Currency Max
      Modded/Hacked App: Plant Power - Fruit Showdown! By Ka Chun CHEUNG
      Bundle ID: com.CHEUNG.plant
      iTunes Store Link: https://apps.apple.com/us/app/plant-power-fruit-showdown/id6657962632?uo=4

       

      🤩 Hack Features

      - ADS NO [ Rewards Free ]

      - Speed UP Card Active

      - Gems

      - Gold

      - Energy

      - Golden Keys

      - Silver Keys

      - Hero Basic [ Unlocked ]

      - Hero Legendary [ Unlocked Just Tap Card ]

      - Weapons Unlocked

      - Walls Unlocked

      - GamePlay Unlocked [ Play Free Any ]

      - Weapon LvL UP Cards

      - Basic Hero LvL UP Cards

      - Wave Faster Skip [ Kill 1 Monster ]

      - Weapon LvL & Status [ ATK SKILL CD CRITI HP ETC ]

      - Basic Hero LvL & Status [ ATK CD CRITI ETC ]

      - Legendary Hero LvL & Status [ ATK CD CRITI ETC ]
      • 6 replies
    • Plant Power - Fruit Showdown! v7.5 [ +20++ Jailed ] Currency Max
      Modded/Hacked App: Plant Power - Fruit Showdown! By Ka Chun CHEUNG
      Bundle ID: com.CHEUNG.plant
      iTunes Store Link: https://apps.apple.com/us/app/plant-power-fruit-showdown/id6657962632?uo=4
       

      🤩 Hack Features

      - ADS NO [ Rewards Free ]

      - Speed UP Card Active

      - Gems

      - Gold

      - Energy

      - Golden Keys

      - Silver Keys

      - Hero Basic [ Unlocked ]

      - Hero Legendary [ Unlocked Just Tap Card ]

      - Weapons Unlocked

      - Walls Unlocked

      - GamePlay Unlocked [ Play Free Any ]

      - Weapon LvL UP Cards

      - Basic Hero LvL UP Cards

      - Wave Faster Skip [ Kill 1 Monster ]

      - Weapon LvL & Status [ ATK SKILL CD CRITI HP ETC ]

      - Basic Hero LvL & Status [ ATK CD CRITI ETC ]

      - Legendary Hero LvL & Status [ ATK CD CRITI ETC ]
      • 2 replies
    • BASEBALL 9 v3.7.0 +9 Cheats for Jailed iDevices!
      Modded/Hacked App: BASEBALL 9 By playus soft
      Bundle ID: us.kr.baseballnine
      iTunes Store Link: https://apps.apple.com/us/app/baseball-9/id1340866223?uo=4


      Hack Features:
      - Unlimited Coins
      - Unlimited Stamina
      - Unlimited Gems
      - Unlimited Recruit Tickets
      - Unlimited Gold Badges
      - Unlimited Silver Badges
      - Unlimited Platinum Badges
      - Unlimited XP Drinks
      - Unlimited Condition Drinks


      Jailbreak required hack(s): https://iosgods.com/topic/136094-baseball-9-cheats-all-versions-1/


      Hack Download Link: https://iosgods.com/topic/82460-baseball-9-v333-9-cheats-for-jailed-idevices/
        • Informative
        • Like
      • 1,451 replies
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines