To save time Many game-developer are trying to make unity game with some third-part lua plugin such as Slua or Xlua In this developing mode the source code are not in Ida but in lua script compressed in unity bundle asset.I found that many hackers dont know much about how to crack such game.so i decided to make a tut for that in detail and share my own lua tool to help you read rua bytecode.you cant find such tool anywhere except here.
Slua github:https://github.com/leinlin/slua
Xlua:https://github.com/Tencent/xLua
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Luajit wiki:http://wiki.luajit.org/Bytecode-2.0 ;explaining how the luajit Vm bytecode work is complicated so please study it on your own
Luajit dis-asm tool: https://armconverter.com/luatools/ or https://iosddl.net/2d385e1427003585/jit.rar Usage:luajit -blg XXX
Luajit example:https://imgur.com/vKWVyrZ
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The lua dis-asm tool are only work on lua version 5.3.5 The lastest version is 5.4 i will keep updating and sharing it to public
Lua5.3.5 wiki:https://the-ravi-programming-language.readthedocs.io/en/latest/lua_bytecode_reference.html
Lua5.3.5 dis-asm tool:https://iosddl.net/82d5111f913c37bc/luac.exe
Lua5.3.5 example:https://imgur.com/JsjfWdm
Usage:
-l list bytecode
-d decompile bytecode
-i dump instruction
-o name output to file 'name' (default is "luac.out")
-p parse only
-s strip debug information
-v show version information
-- stop handling options
- stop handling options and process stdin
-iABC make a iABC instruction
-iABx make a ABx instruction
-iAsBx make a AsBx instruction
-iAx make a iAx instruction
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//inject code example
#include <Foundation/Foundation.h>
#include "Config.h"
#include <sys/socket.h>
#import <AudioToolbox/AudioToolbox.h>
#include <sys/sysctl.h>
#import <AdSupport/ASIdentifierManager.h>
#import "MediaPlayer/MPVolumeView.h"
#import "AudioToolbox/AudioToolbox.h"
#include <sys/stat.h>
#include <mach-o/dyld.h>
#include <mach-o/dyld.h>
#include <mach-o/ldsyms.h>
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#include <vector>
# include <stdio.h>
# include <stdlib.h>
//modified lua script with winhex
unsigned char data[3410] = {
0x2D, 0x2D, 0x20, 0xE4, 0xBC, 0xA4, 0xE5, 0xAE, 0xB3, 0xE8, 0xAE, 0xA1, 0xE7, 0xAE, 0x97, 0x0D,
0x0A, 0x66, 0x75, 0x6E, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x63, 0x61, 0x6C, 0x63, 0x75, 0x6C,
0x61, 0x74, 0x65, 0x44, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x28, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B,
0x5F, 0x74, 0x79, 0x70, 0x65, 0x2C, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x2C, 0x20, 0x64,
0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x2C, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x29, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x2D, 0x2D,
0x5B, 0x5B, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x3D,
0x20, 0x30, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x20, 0x64, 0x61,
0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x30, 0x2E, 0x38, 0x0D,
0x0A, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x5F, 0x74,
0x79, 0x70, 0x65, 0x20, 0x3D, 0x3D, 0x20, 0x42, 0x41, 0x54, 0x54, 0x4C, 0x45, 0x5F, 0x41, 0x54,
0x54, 0x41, 0x43, 0x4B, 0x5F, 0x54, 0x59, 0x50, 0x45, 0x5F, 0x50, 0x48, 0x59, 0x53, 0x49, 0x43,
0x41, 0x4C, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64,
0x61, 0x6D, 0x61, 0x67, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x70, 0x68, 0x79, 0x73,
0x69, 0x63, 0x61, 0x6C, 0x5F, 0x64, 0x65, 0x66, 0x65, 0x6E, 0x73, 0x65, 0x20, 0x2F, 0x20, 0x64,
0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x2E, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63,
0x61, 0x6C, 0x5F, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x65,
0x6C, 0x73, 0x65, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x61, 0x6D,
0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x64, 0x65,
0x66, 0x65, 0x6E, 0x73, 0x65, 0x20, 0x2F, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72,
0x6F, 0x6D, 0x2E, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x0D,
0x0A, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20,
0x69, 0x66, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3E,
0x20, 0x30, 0x2E, 0x38, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D,
0x20, 0x30, 0x2E, 0x38, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D,
0x0A, 0x20, 0x20, 0x20, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x3D, 0x20, 0x61, 0x74,
0x74, 0x61, 0x63, 0x6B, 0x20, 0x2A, 0x20, 0x28, 0x31, 0x20, 0x2D, 0x20, 0x64, 0x61, 0x6D, 0x61,
0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x29, 0x0D, 0x0A, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20,
0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5D, 0x5D, 0x0D,
0x0A, 0x09, 0x0D, 0x0A, 0x09, 0x2D, 0x2D, 0x20, 0xE6, 0x94, 0xBB, 0xE5, 0x87, 0xBB, 0xE5, 0x8A,
0x9B, 0xE5, 0x80, 0xBC, 0xE4, 0xBF, 0xAE, 0xE5, 0xA4, 0x8D, 0xEF, 0xBC, 0x8C, 0xE9, 0x98, 0xB2,
0xE6, 0xAD, 0xA2, 0xE5, 0x87, 0xBA, 0xE7, 0x8E, 0xB0, 0x30, 0x2F, 0x30, 0xE7, 0x9A, 0x84, 0xE6,
0x83, 0x85, 0xE5, 0x86, 0xB5, 0x0D, 0x0A, 0x09, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x20, 0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0xE9, 0x80, 0x8F, 0xE7, 0x99, 0xBE,
0xE5, 0x88, 0x86, 0xE6, 0xAF, 0x94, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x2D, 0x2D, 0x20, 0xE6, 0x94,
0xBB, 0xE5, 0x87, 0xBB, 0xE6, 0x96, 0xB9, 0xE7, 0x9A, 0x84, 0xE6, 0x83, 0x85, 0xE5, 0x86, 0xB5,
0x0D, 0x0A, 0x09, 0x69, 0x66, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D,
0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x09, 0x70, 0x68, 0x79, 0x73, 0x69,
0x63, 0x61, 0x6C, 0x5F, 0x69, 0x6E, 0x67, 0x6F, 0x72, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D,
0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x2E, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C,
0x5F, 0x64, 0x65, 0x66, 0x65, 0x6E, 0x73, 0x65, 0x5F, 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x5F,
0x76, 0x61, 0x6C, 0x75, 0x65, 0x0D, 0x0A, 0x09, 0x09, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x69,
0x6E, 0x67, 0x6F, 0x72, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72,
0x6F, 0x6D, 0x2E, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x64, 0x65, 0x66, 0x65, 0x6E, 0x73, 0x65,
0x5F, 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x0D, 0x0A, 0x09,
0x09, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x69, 0x6E, 0x67, 0x6F, 0x72, 0x65,
0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72,
0x6F, 0x6D, 0x2E, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x64, 0x65, 0x66, 0x65,
0x6E, 0x73, 0x65, 0x5F, 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20,
0x2D, 0x2D, 0x20, 0xE6, 0x8A, 0xA4, 0xE7, 0x94, 0xB2, 0xE7, 0xA9, 0xBF, 0xE9, 0x80, 0x8F, 0xE7,
0x99, 0xBE, 0xE5, 0x88, 0x86, 0xE6, 0xAF, 0x94, 0x0D, 0x0A, 0x09, 0x09, 0x6D, 0x61, 0x67, 0x69,
0x63, 0x5F, 0x69, 0x6E, 0x67, 0x6F, 0x72, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20,
0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x2E, 0x6D, 0x61, 0x67, 0x69, 0x63,
0x5F, 0x64, 0x65, 0x66, 0x65, 0x6E, 0x73, 0x65, 0x5F, 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x5F,
0x72, 0x61, 0x74, 0x65, 0x20, 0x2D, 0x2D, 0x20, 0xE6, 0xB3, 0x95, 0xE6, 0x9C, 0xAF, 0xE7, 0xA9,
0xBF, 0xE9, 0x80, 0x8F, 0xE7, 0x99, 0xBE, 0xE5, 0x88, 0x86, 0xE6, 0xAF, 0x94, 0x0D, 0x0A, 0x09,
0x09, 0x0D, 0x0A, 0x09, 0x09, 0x69, 0x66, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x5F, 0x74,
0x79, 0x70, 0x65, 0x20, 0x3D, 0x3D, 0x20, 0x42, 0x41, 0x54, 0x54, 0x4C, 0x45, 0x5F, 0x41, 0x54,
0x54, 0x41, 0x43, 0x4B, 0x5F, 0x54, 0x59, 0x50, 0x45, 0x5F, 0x50, 0x48, 0x59, 0x53, 0x49, 0x43,
0x41, 0x4C, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09, 0x09, 0x09, 0x63, 0x68, 0x61, 0x6E,
0x67, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61,
0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x2E, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F,
0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x0D, 0x0A, 0x09, 0x09,
0x09, 0x63, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72,
0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D,
0x2E, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65,
0x5F, 0x72, 0x61, 0x74, 0x65, 0x0D, 0x0A, 0x09, 0x09, 0x65, 0x6C, 0x73, 0x65, 0x0D, 0x0A, 0x09,
0x09, 0x09, 0x63, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20,
0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x2E, 0x6D, 0x61, 0x67,
0x69, 0x63, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x0D,
0x0A, 0x09, 0x09, 0x09, 0x63, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46,
0x72, 0x6F, 0x6D, 0x2E, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65,
0x5F, 0x72, 0x61, 0x74, 0x65, 0x0D, 0x0A, 0x09, 0x09, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D, 0x0A,
0x09, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x69, 0x66, 0x20, 0x61, 0x74,
0x74, 0x61, 0x63, 0x6B, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3D, 0x3D, 0x20, 0x42, 0x41, 0x54,
0x54, 0x4C, 0x45, 0x5F, 0x41, 0x54, 0x54, 0x41, 0x43, 0x4B, 0x5F, 0x54, 0x59, 0x50, 0x45, 0x5F,
0x50, 0x48, 0x59, 0x53, 0x49, 0x43, 0x41, 0x4C, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09,
0x09, 0x09, 0x09, 0x0D, 0x0A, 0x09, 0x20, 0x20, 0x20, 0x20, 0x2D, 0x2D, 0x20, 0xE5, 0x87, 0x8F,
0xE5, 0x85, 0x8D, 0x62, 0x75, 0x66, 0x66, 0xE6, 0x83, 0x85, 0xE5, 0x86, 0xB5, 0x0D, 0x0A, 0x09,
0x09, 0x2D, 0x2D, 0x20, 0xE7, 0x99, 0xBE, 0xE5, 0x88, 0x86, 0xE6, 0xAF, 0x94, 0x0D, 0x0A, 0x09,
0x09, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72,
0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54, 0x61, 0x72, 0x67,
0x65, 0x74, 0x2E, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63,
0x61, 0x6C, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x0D, 0x0A,
0x0D, 0x0A, 0x09, 0x09, 0x2D, 0x2D, 0x20, 0x0D, 0x0A, 0x09, 0x09, 0x69, 0x66, 0x20, 0x64, 0x61,
0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x6E, 0x6F, 0x74,
0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x3A, 0x69, 0x73, 0x4A, 0x69,
0x6E, 0x5A, 0x68, 0x61, 0x6E, 0x28, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09, 0x09,
0x09, 0x2D, 0x2D, 0x20, 0xE8, 0xBF, 0x9C, 0xE7, 0xA8, 0x8B, 0x20, 0x20, 0x0D, 0x0A, 0x09, 0x09,
0x09, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72,
0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D,
0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x2A, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x73,
0x68, 0x6F, 0x6F, 0x74, 0x65, 0x72, 0x5F, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F,
0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x2F, 0x20, 0x31, 0x30,
0x30, 0x0D, 0x0A, 0x09, 0x09, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x09, 0x69, 0x66,
0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x72, 0x65,
0x64, 0x75, 0x63, 0x65, 0x5F, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x64, 0x61,
0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x3D, 0x20, 0x30, 0x20, 0x74,
0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09, 0x09, 0x09, 0x2D, 0x2D, 0x20, 0xE7, 0x89, 0xA9, 0xE7, 0x90,
0x86, 0xE5, 0x85, 0x8D, 0xE7, 0x96, 0xAB, 0x0D, 0x0A, 0x09, 0x09, 0x09, 0x64, 0x61, 0x6D, 0x61,
0x67, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x3A, 0x61, 0x64, 0x64, 0x53, 0x68, 0x6F, 0x77,
0x57, 0x6F, 0x72, 0x64, 0x28, 0x33, 0x2C, 0x20, 0x34, 0x37, 0x30, 0x30, 0x30, 0x33, 0x29, 0x0D,
0x0A, 0x09, 0x09, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x09, 0x2D, 0x2D, 0x20, 0xE6,
0x95, 0xB0, 0xE5, 0x80, 0xBC, 0x0D, 0x0A, 0x09, 0x09, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F,
0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54,
0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x70, 0x68, 0x79,
0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x76, 0x61, 0x6C,
0x75, 0x65, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x09, 0x2D, 0x2D, 0x20, 0xE7, 0xA9, 0xBF, 0xE9, 0x80,
0x8F, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x20, 0x3D, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x20, 0x2A, 0x20, 0x61, 0x74, 0x74,
0x61, 0x63, 0x6B, 0x20, 0x2F, 0x20, 0x28, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x20, 0x2B, 0x20,
0x6D, 0x61, 0x74, 0x68, 0x2E, 0x6D, 0x61, 0x78, 0x28, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54,
0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x64,
0x65, 0x66, 0x65, 0x6E, 0x73, 0x65, 0x20, 0x2A, 0x20, 0x28, 0x31, 0x30, 0x30, 0x20, 0x2D, 0x20,
0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x69, 0x6E, 0x67, 0x6F, 0x72, 0x65, 0x5F,
0x72, 0x61, 0x74, 0x65, 0x20, 0x29, 0x20, 0x2F, 0x20, 0x31, 0x30, 0x30, 0x20, 0x2D, 0x20, 0x70,
0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6C, 0x5F, 0x69, 0x6E, 0x67, 0x6F, 0x72, 0x65, 0x2C, 0x30,
0x29, 0x29, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6C, 0x73, 0x65, 0x0D, 0x0A, 0x09, 0x09,
0x20, 0x2D, 0x2D, 0x20, 0xE5, 0x87, 0x8F, 0xE5, 0x85, 0x8D, 0x62, 0x75, 0x66, 0x66, 0xE6, 0x83,
0x85, 0xE5, 0x86, 0xB5, 0x0D, 0x0A, 0x09, 0x09, 0x20, 0x2D, 0x2D, 0x20, 0xE7, 0x99, 0xBE, 0xE5,
0x88, 0x86, 0xE6, 0xAF, 0x94, 0x0D, 0x0A, 0x09, 0x09, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F,
0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61,
0x6D, 0x61, 0x67, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x72, 0x65, 0x64, 0x75, 0x63,
0x65, 0x5F, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72,
0x61, 0x74, 0x65, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x09, 0x69, 0x66, 0x20, 0x64, 0x61, 0x6D, 0x61,
0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x64,
0x61, 0x6D, 0x61, 0x67, 0x65, 0x46, 0x72, 0x6F, 0x6D, 0x3A, 0x69, 0x73, 0x4A, 0x69, 0x6E, 0x5A,
0x68, 0x61, 0x6E, 0x28, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09, 0x09, 0x09, 0x2D,
0x2D, 0x20, 0xE8, 0xBF, 0x9C, 0xE7, 0xA8, 0x8B, 0x20, 0x20, 0x0D, 0x0A, 0x09, 0x09, 0x09, 0x72,
0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74,
0x65, 0x20, 0x3D, 0x20, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x2A, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54,
0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x73, 0x68, 0x6F,
0x6F, 0x74, 0x65, 0x72, 0x5F, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x2F, 0x20, 0x31, 0x30, 0x30, 0x0D, 0x0A, 0x09, 0x09,
0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x09, 0x2D, 0x2D, 0x20, 0xE6, 0x95, 0xB0, 0xE5,
0x80, 0xBC, 0x0D, 0x0A, 0x09, 0x09, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D,
0x61, 0x67, 0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54, 0x61, 0x72, 0x67,
0x65, 0x74, 0x2E, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F,
0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x0D, 0x0A, 0x0D, 0x0A,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x3D,
0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x20, 0x2A, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B,
0x20, 0x2F, 0x20, 0x28, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x20, 0x2B, 0x20, 0x6D, 0x61, 0x74,
0x68, 0x2E, 0x6D, 0x61, 0x78, 0x28, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54, 0x61, 0x72, 0x67,
0x65, 0x74, 0x2E, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x64, 0x65, 0x66, 0x65, 0x6E, 0x73, 0x65,
0x20, 0x2A, 0x20, 0x28, 0x31, 0x30, 0x30, 0x20, 0x2D, 0x20, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F,
0x69, 0x6E, 0x67, 0x6F, 0x72, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x29, 0x20, 0x2F, 0x20, 0x31,
0x30, 0x30, 0x20, 0x2D, 0x20, 0x6D, 0x61, 0x67, 0x69, 0x63, 0x5F, 0x69, 0x6E, 0x67, 0x6F, 0x72,
0x65, 0x2C, 0x30, 0x29, 0x29, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6E, 0x64, 0x0D, 0x0A,
0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x0D, 0x0A, 0x09, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20,
0x3D, 0x20, 0x28, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x2B, 0x20, 0x63, 0x68, 0x61, 0x6E,
0x67, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x29, 0x20, 0x2A, 0x20, 0x72, 0x65, 0x64,
0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20,
0x2F, 0x20, 0x31, 0x30, 0x30, 0x20, 0x2A, 0x20, 0x63, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x5F, 0x64,
0x61, 0x6D, 0x61, 0x67, 0x65, 0x5F, 0x72, 0x61, 0x74, 0x65, 0x20, 0x2F, 0x20, 0x31, 0x30, 0x30,
0x20, 0x2D, 0x20, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x5F, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65,
0x20, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x69, 0x66, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20,
0x3C, 0x20, 0x30, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09, 0x09, 0x64, 0x61, 0x6D, 0x61,
0x67, 0x65, 0x20, 0x3D, 0x20, 0x30, 0x20, 0x0D, 0x0A, 0x09, 0x65, 0x6E, 0x64, 0x0D, 0x0A, 0x09,
0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20, 0x3D, 0x20, 0x30,
0x0D, 0x0A, 0x09, 0x2D, 0x2D, 0x20, 0xE8, 0xBF, 0x94, 0xE5, 0x9B, 0x9E, 0xE5, 0x8A, 0xA0, 0xE4,
0xB8, 0xAA, 0xE4, 0xBC, 0xA4, 0xE5, 0xAE, 0xB3, 0xE7, 0xB1, 0xBB, 0xE5, 0x9E, 0x8B, 0x0D, 0x0A,
0x09, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x4F, 0x62, 0x6A,
0x20, 0x3D, 0x20, 0x7B, 0x7D, 0x0D, 0x0A, 0x09, 0x69, 0x66, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2E, 0x74, 0x65, 0x61, 0x6D, 0x20, 0x3D, 0x3D, 0x20,
0x32, 0x20, 0x74, 0x68, 0x65, 0x6E, 0x0D, 0x0A, 0x09, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x20,
0x3D, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x0D, 0x0A, 0x09, 0x65, 0x6E, 0x64, 0x0D, 0x0A,
0x09, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x4F, 0x62, 0x6A, 0x2E, 0x64, 0x61, 0x6D, 0x61, 0x67,
0x65, 0x20, 0x3D, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x0D, 0x0A, 0x09, 0x64, 0x61, 0x6D,
0x61, 0x67, 0x65, 0x4F, 0x62, 0x6A, 0x2E, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70,
0x65, 0x20, 0x3D, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x6B, 0x5F, 0x74, 0x79, 0x70, 0x65, 0x20,
0x20, 0x2D, 0x2D, 0x20, 0xE7, 0x89, 0xA9, 0xE7, 0x90, 0x86, 0xEF, 0xBC, 0x8C, 0xE9, 0xAD, 0x94,
0xE6, 0xB3, 0x95, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x0D, 0x0A, 0x0D, 0x0A, 0x09, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6E, 0x20, 0x64, 0x61, 0x6D, 0x61, 0x67, 0x65, 0x4F, 0x62, 0x6A, 0x0D, 0x0A, 0x65,
0x6E, 0x64
};
typedef int (*_luaL_loadbuffer)(void* L,
const char *buff,
size_t sz,
const char *name);
_luaL_loadbuffer luaL_loadbuffer;
typedef void* (*_luaL_newstate)();
_luaL_newstate luaL_newstate;
typedef int (*_lua_Writer) (void* L, const void* p, size_t sz, void* ud);
_lua_Writer lua_Writer;
typedef int (*_lua_dump) (void *L, _lua_Writer writer, void *data);
_lua_dump lua_dump;
int MemoryWriter(void* ls, const void* p, size_t sz, void* ud)
{
writeToFile(p,sz);
return 0;
}
typedef const char* (*_lua_tostring)(void *L, int index);
_lua_tostring lua_tostring;
int (*_loadbuffer)(void* L,
const char *buff,
size_t sz,
const char *name);
int i = 0; // used as dumped file name
//L = lua state
//buff = script bytecode
//sz = script size
//name = script name
int $loadbuffer(void* L,const char *buff,size_t sz,const char *name) //hook loading function to dump all script of game
{
/*dump lua script to documents folder
std::string path(N2C(NSHomeDirectory())); //get app home Directory N2C mean convert NString to C_string
path = path + "/Documents/" + std::to_string(i); //name dumped script with number in order
FILE* file = fopen(path.c_str(),"wb+"); //create file handle
i++
fwrite(buff,sz,1,file); //write buff to file
fclose(file);
*/
//inject
if(sz > 100 && memcmp((void*)buff,(void*)data,100) == 0) //if buff is target lua then replace the original buff with ours
{
return _loadbuffer(L,(const char*)data,sizeof(data),name); //return modified script
}
return _loadbuffer(L,buff,sz,name); //if not target return original lua script
}
CNConstructor(SexyAss)
{
MSHookFunction( ((void*)CNAddr(0x0015D5A0 + 1)) , (void *)$loadbuffer, (void **)&_loadbuffer); // hook lua_loadbuffer
}