Jump to content

How to Decrypt LUA files


Swagter123

6 posts in this topic

Recommended Posts

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

Link to comment
https://iosgods.com/topic/43719-how-to-decrypt-lua-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Our picks

    • Modded/Hacked App: 城の戦争防衛 By MOBIRIX
      Bundle ID: com.mobirix.dfpt
      iTunes Store Link: https://apps.apple.com/jp/app/%E5%9F%8E%E3%81%AE%E6%88%A6%E4%BA%89%E9%98%B2%E8%A1%9B/id6654911232?uo=4

      🤩 Hack Features

      - Currency [ Earn Some After Disable Hack ]

      - Units Unlocked

      - Unit Cost 0

      - Unit CD

      - Unit Limit No Unlimited Deploy [ Use Only When Enter The Battle ]

       

      ⬇️ iOS Hack Download Link


      Hidden Content

      Download Hack
        • Thanks
        • Like
      • 1 reply
    • Castle War Defense 城の戦争防衛 v1.2.0 [ +5 Jailed ] Currency Max
      Modded/Hacked App: 城の戦争防衛 By MOBIRIX
      Bundle ID: com.mobirix.dfpt
      iTunes Store Link: https://apps.apple.com/jp/app/%E5%9F%8E%E3%81%AE%E6%88%A6%E4%BA%89%E9%98%B2%E8%A1%9B/id6654911232?uo=4
       
      🤩 Hack Features

      - Currency [ Earn Some After Disable Hack ]

      - Units Unlocked

      - Unit Cost 0

      - Unit CD

      - Unit Limit No Unlimited Deploy [ Use Only When Enter The Battle ]

       

      ⬇️ iOS Hack Download IPA Link


      Hidden Content

      Download via the iOSGods App
      • 0 replies
    • Modded/Hacked App: Sweet Cube Blast By Puzzle1Studio,inc.
      Bundle ID: com.puzzle1studio.ap.sweetcubesmatchblast
      iTunes Store Link: https://apps.apple.com/us/app/sweet-cube-blast/id6444350503?uo=4


      🤩 Hack Features

      - Coins

      - Lives

      - Stars No Need [ Task ]

      - Booster

      - Auto Win

       

      ⬇️ iOS Hack Download IPA Link
        • Like
      • 0 replies
    • Sweet Cube Blast v25.0124.00 [ +5 Cheats ] Auto Win
      Modded/Hacked App: Sweet Cube Blast By Puzzle1Studio,inc.
      Bundle ID: com.puzzle1studio.ap.sweetcubesmatchblast
      iTunes Store Link: https://apps.apple.com/us/app/sweet-cube-blast/id6444350503?uo=4 

      🤩 Hack Features

      - Coins

      - Lives

      - Stars No Need [ Task ]

      - Booster

      - Auto Win

       

      ⬇️ iOS Hack Download Link


      Hidden Content

      Download Hack
      • 3 replies
    • Frost & Flame: King of Avalon Cheats v20.7 +2
      Modded/Hacked App: Frost & Flame: King of Avalon By FunPlus International AG
      Bundle ID: com.diandian.kingofavalon
      iTunes Store Link: https://apps.apple.com/us/app/frost-flame-king-of-avalon/id1084930849?uo=4


      Hack Features:
      - Multiply Attack
      - Multiply Defense

      NOTE: Cheat maybe buggy so make sure you have both features on. Don't ask me why cuz I have no idea

       

      Free Non-Jailbroken Hack: https://iosgods.com/topic/188621-frost-flame-king-of-avalon-v1990-jailed-cheats-2/


      iOS Hack Download Link: https://iosgods.com/topic/188620-frost-flame-king-of-avalon-cheats-v2000-2/
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 42 replies
    • Dream League Soccer 2024 v12.110 +12 Cheats
      Modded/Hacked App: Dream League Soccer 2024 By First Touch Games Ltd.
      Bundle ID: com.firsttouch.dls7
      iTunes Store Link: https://apps.apple.com/us/app/dream-league-soccer-2024/id1462911602?uo=4


      Hack Features:
      - Stupid AI
      - No Foul
      - No Injuries
      - No Offside
      - Freeze Stamina
      - No Substitutions Limit
      - No Forfeit Penalty
      - Custom Logo Unlocked
      - Custom Kit Unlocked
      - Unlock Customizations
      - Throw In to End Current Half
      - Freeze Match Clock

      Notes: Play offline if you get kicked out of match.


      Non-Jailbroken & No Jailbreak required hack(s): 
       

      iOS Hack Download Link: https://iosgods.com/topic/138633-dream-league-soccer-2024-v11230-12-cheats/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 2,096 replies
    • Candy Crush Soda Saga Cheats v1.287.3 +3
      Modded/Hacked App: Candy Crush Soda Saga By King.com Limited
      Bundle ID: com.midasplayer.apps.candycrushsodasaga
      iTunes Store Link: https://apps.apple.com/us/app/candy-crush-soda-saga/id850417475?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

      - Freeze Moves
      - Freeze Lives
      - Freeze Boosters


      🍏 For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/topic/191667-candy-crush-soda-saga-v12861-jailed-cheats-3/

       

      📥 iOS Hack Download Link: https://iosgods.com/topic/191666-candy-crush-soda-saga-cheats-v12873-3/
        • Agree
        • Like
      • 3 replies
    • Evil Hunter Tycoon Cheats v1.384 +10
      Modded/Hacked App: Evil Hunter Tycoon by SuperPlanet corp.
      Bundle ID: com.superplanet.evilhunter
      iTunes Store Link: https://apps.apple.com/us/app/evil-hunter-tycoon/id1493512288?uo=4&at=1010lce4


      Hack Features:
      - Hero Legendary when visit the village
      - God Mode PvE
      - Huge Damage PvE
      - Infinite Coin (Turn on before tap to enter the game, earn some or spend some)
      - Freeze Material (Upgrade, create new weapon, armor, etc ...)
      - Free Store  
      - Free iAP
      - Disabled Anti Cheat

      iOS Hack Download Link: https://iosgods.com/topic/121180-arm64-evil-hunter-tycoon-cheats-v124-10/

      Credit: Laxus
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 2,325 replies
    • Magical Girl Dungeon v1.1.6 +3 Jailed Cheats [ Damage ]
      Modded/Hacked App: Magical Girl Dungeon By Kenjirou Uesaka
      Bundle ID: com.KCG.MahoDungeon
      iTunes Store Link: https://apps.apple.com/us/app/magical-girl-dungeon/id6741759536?uo=4

       


      🤩 Hack Features

      - God Mode
      - Damage Multiplier
      -- No Ads
        • Winner
        • Like
      • 0 replies
    • Magical Girl Dungeon v1.1.6 +3 Cheats [ Damage ]
      Modded/Hacked App: Magical Girl Dungeon By Kenjirou Uesaka
      Bundle ID: com.KCG.MahoDungeon
      iTunes Store Link: https://apps.apple.com/us/app/magical-girl-dungeon/id6741759536?uo=4

       


      🤩 Hack Features

      - God Mode
      - Damage Multiplier
      -- No Ads
        • Agree
        • Like
      • 3 replies
    • Racing Kingdom v0.34.126 +2 Jailed Cheats [ Auto Win ]
      Modded/Hacked App: Racing Kingdom By SUPERGEARS OYUN YAZILIM TEKNOLOJI VE PAZARLAMA ANONIM SIRKETI
      Bundle ID: com.supergears.racingkingdom
      iTunes Store Link: https://apps.apple.com/us/app/racing-kingdom/id6468027706?uo=4

       


      🚀 Hack Features

      - Auto Win
      - Freeze Rival


      🍏 Jailbreak iOS hacks: [Mod Menu Hack] Racing Kingdom v0.33.6 +2 Cheats [ Auto Win ] - ViP Cheats - iOSGods
      🤖 Modded Android APK(s): https://iosgods.com/forum/68-android-section/
        • Informative
        • Like
      • 6 replies
    • Racing Kingdom v0.34.126 +2 Cheats [ Auto Win ]
      Modded/Hacked App: Racing Kingdom By SUPERGEARS OYUN YAZILIM TEKNOLOJI VE PAZARLAMA ANONIM SIRKETI
      Bundle ID: com.supergears.racingkingdom
      iTunes Store Link: https://apps.apple.com/us/app/racing-kingdom/id6468027706?uo=4

       
       

      🚀 Hack Features

      - Auto Win
      - Freeze Rival


      🍏 For Non-Jailbroken & No Jailbreak required hacks: [IPA Mod Menu] Racing Kingdom v0.33.6 +2 Jailed Cheats [ Auto Win ] - ViP Non-Jailbroken Hacks & Cheats - iOSGods
      🤖 Modded Android APK(s): https://iosgods.com/forum/68-android-section/
        • Agree
        • Winner
        • Like
      • 27 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