-- Creator -poko
-- Date - 2/6/2022
--GLOBAL INIT
GAME_LIBS = {}
function ReadInt32(addr)
local from = {{address = addr, flags=4}};
from = [Link](from);
return from[1].value;
end
function Num2HexStr(num, uppercase)
if(not uppercase or uppercase == 0) then
return ([Link]("%x",num)); end
return ([Link]("%X",num));
end
function alreadyHave(compare_t , str)
for index, element in ipairs(compare_t) do
if(element == str) then
return true;
end
end
return false;
end
--probably the .bss or .data section in most case
function getLastSection(lib_name)
local temp_t = [Link](("/data/*" .. lib_name));
return temp_t[#temp_t]['end']-1;
end
--set GAME_LIBS and return table of strings for UI
--in a sync order to GAME_LIBS
function getSortedGameLibs()
local return_t = {}
local lib_maps = [Link](("/data/*" ..
[Link]().packageName .. "*lib*.so"));
for index, element in ipairs(lib_maps) do
if([Link] == 'Xa' or [Link] == 'Cd') then
org_name = [Link]:match("/.*/(lib.*%.so)");
if( not alreadyHave(return_t, org_name) ) then
[Link] = getLastSection(org_name);
element.org_name = org_name;
[Link](GAME_LIBS, element);
[Link](return_t, org_name);
end
end
end --forloop end
return return_t;
end
--Dump Elf file (libs)
function dumpELF(data)
--checking elf header just in case
if( ReadInt32([Link]) ~= 1179403647) then
print("Something is wrong !")
[Link]();
end
[Link]([Link], [Link], '/sdcard/dump')
local old_name = [Link]().packageName .. "-" ..
Num2HexStr([Link]) .. "-" .. Num2HexStr([Link]+1) .. ".bin";
local new_name = "[" .. Num2HexStr([Link],1) .. "-" ..
Num2HexStr([Link]+1,1) .. "]_" .. data.org_name;
local save_path = "/sdcard/dump/";
[Link]((save_path .. old_name), (save_path .. new_name));
[Link]("Saved Loaction :" .. save_path .. new_name);
print("Thanks For using the script !");
[Link]();
end
function entrypoint()
--show list of libs as menu
libs_t = getSortedGameLibs();
if(#libs_t ==0) then
print("No libs found in this target!");
[Link]()
end
point = [Link](libs_t , nil, 'Select Lib to Dump:')
if not point then print("Thanks! have goood day!") [Link]() end;
dumpELF(GAME_LIBS[point]);
end
entrypoint();