Jump to content

11 posts in this topic

Recommended Posts

Updated (edited)

Hello, in this tutorial I will show one of the ways to hook a function. I will be hooking a function from a Unity game.

First you need to find the address at which the beginning of the function is located in real time, this is difficult due to ASLR (address randomization).

First, let's write a method that will return the following address:

// RVA: 0x11FE288 Offset: 0x11FE288 VA: 0x11FE288
    private void Update() { }
  (This is the address and information about the function that is in the compiled game engine)

uint64_t getExecAddr(uint64_t addr, int index)
{
    const struct mach_header* header = _dyld_get_image_header(index);
    if (header == NULL){return 0;}

    uint64_t libLoadAddr = (uint64_t)header;
    uint64_t exec_addr = libLoadAddr + addr;

    return exec_addr;
}

In this example, we are making a method that returns a number of type uint64_t and takes two parameters: the address of the function (for example, the one I gave above) and the library index.

Using the _dyld_get_image_header() method, we get the address from which the library was loaded by its index.

 

How to find the library index? This can be done in two ways: Using the LLDB debugger (image list command) or using another method that we will now write (this method is better than the first one)

uint64_t getLibIndex(const char* que_image)
{
	int i = 0;
	int image_count = _dyld_image_count();

	for(; i < image_count; i++)
	{
		const char* req_image = _dyld_get_image_name(i);

		if(req_image && strcmp(req_image, que_image) == 0)
			{return i;}
	}
	return -1;
}

This method takes a path parameter to the library, we use the _dyld_image_count() method to find out how many libraries are loaded into the game process, then using a loop we compare our path to the library with others, and if the paths match, we return the index.

Okay, there's not much left. Now let's create a pointer to the old function and create a replacement function that will be called instead of the original one:

void (*old_Update)(void *self);

void Update(void *self)
{
 	// "your code here"
  
	old_Update(self);
}

Now let's just make a hook according to a template that can be easily found on the Internet:

%ctor 
{		
	MSHookFunction( (void *)address_to_your_func_with_aslr, (void *)Update, (void **)&old_Update);	
}	

To make it clearer, I will show the full code of my hook:

#include <unistd.h>
#include <dispatch/dispatch.h>
#include <mach-o/dyld.h>
#include <substrate.h>
#include <string.h>

uint64_t getExecAddr(uint64_t addr, int index)
{
    const struct mach_header* header = _dyld_get_image_header(index);
    if (header == NULL){return 0;}

    uint64_t libLoadAddr = (uint64_t)header;
    uint64_t exec_addr = libLoadAddr + addr;

    return exec_addr;
}


uint64_t getLibIndex(const char* que_image)
{
	int i = 0;
	int image_count = _dyld_image_count();

	for(; i < image_count; i++)
	{
		const char* req_image = _dyld_get_image_name(i);

		if(req_image && strcmp(req_image, que_image) == 0)
			{return i;}
	}
	return -1;
}


void (*old_Update)(void *self);

void Update(void *self)
{
	sleep(5);
	old_Update(self);
}


%ctor 
{	
	dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

		sleep(150);

		int index = getLibIndex("/private/var/containers/Bundle/Application/BAE27894-6809-4743-AFFA-C1F6B93195CB/hidenseek.app/Frameworks/UnityFramework.framework/UnityFramework");
		
		uint64_t address = getExecAddr(0x11fe288, index);

		MSHookFunction( (void *)address, (void *)Update, (void **)&old_Update);

	});	

}	

 

This is my test version of the hook, it works great. (dispatch_async I used to wait until all libraries are loaded) In my example, the hook changes the behavior of the program so that when Update() is called, the game slows down for 5 seconds, this is only a beta version and you can add other logic there :)

If you liked the tutorial, please rate it. I will try to answer questions :)

 

 

Updated by nngot44
  • Like 4
  • Thanks 1
  • Informative 1
Posted

Very good tutorial for beginner, easy to read and detailed

Thank you for posting

Posted
3 hours ago, nngot44 said:
/private/var/containers/Bundle/Application/BAE27894-6809-4743-AFFA-C1F6B93195CB/

Have to be careful here if you plan on releasing this tweak. :) This location is dynamic and changes per device & iOS version.

  • Informative 1
Posted

Really nice. Have you try this on Dopamine jailbreak? I got some issue while hooking on Dopamine.

 

Posted
1 minute ago, 34306 said:

Really nice. Have you try this on Dopamine jailbreak? I got some issue while hooking on Dopamine.

 

What kind of issues? I've seen similar reports after converting rootful to rootless with iGameGod.

Posted
Just now, Rook said:

What kind of issues? I've seen similar reports after converting rootful to rootless with iGameGod.

I have no idea, maybe it's Dopamine issue. Opa said on 1.1 he fixed PPLRW but when i tried to hooking (Unity game). It still crash. I have no idea what's going on..
xVY8cNF.jpg

Posted
Just now, 34306 said:

I have no idea, maybe it's Dopamine issue. Opa said on 1.1 he fixed PPLRW but when i tried to hooking (Unity game). It still crash. I have no idea what's going on..
xVY8cNF.jpg

Shouldn't this be an ElleKit related issue rather than Dopamine?

I tried hooks on palera1n rootless and they seem to work fine.

Posted
Just now, Rook said:

Shouldn't this be an ElleKit related issue rather than Dopamine?

I tried hooks on palera1n rootless and they seem to work fine.

Let me update Ellekit. They already have Substitute, Substrate, Libhooker. And Ellekit such a weird thing...

Report back to you later!

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

    • Vikings Revenge v1.0.11 [+5 Jailed Cheats]
      Modded/Hacked App: Vikings Revenge By Estoty LLC
      Bundle ID: com.vikings.game
      App Store Link: https://apps.apple.com/us/app/vikings-revenge/id6745582935?uo=4



      🤩 Hack Features

      - Add All Resources
      - Increase Tool Level
      - Never Die
      - Skip Current Quest (Use it when you needed)
      - Enable No Ads
      • 2 replies
    • Vikings Revenge v1.0.11 [+5 Cheats]
      Modded/Hacked App: Vikings Revenge By Estoty LLC
      Bundle ID: com.vikings.game
      App Store Link: https://apps.apple.com/us/app/vikings-revenge/id6745582935?uo=4

       

      🤩 Hack Features

      - Add All Resources
      - Increase Tool Level
      - Never Die
      - Skip Current Quest (Use it when you needed)
      - Enable No Ads
      • 4 replies
    • Slay Quest v1.3.12 [+3 Cheats]
      Modded/Hacked App: Slay Quest By Quest Lab Games Korlatolt Felelossegu Tarsasag
      Bundle ID: com.questlab.slayquest
      App Store Link: https://apps.apple.com/us/app/slay-quest/id6670221918?uo=4



      🤩 Hack Features

      - Unlimited Resources
      - Never Die
      - One Hit Kill
       
      • 7 replies
    • Slay Quest v1.3.12 [+3 Jailed Cheats]
      Modded/Hacked App: Slay Quest By Quest Lab Games Korlatolt Felelossegu Tarsasag
      Bundle ID: com.questlab.slayquest
      App Store Link: https://apps.apple.com/us/app/slay-quest/id6670221918?uo=4

       

      🤩 Hack Features

      - Unlimited Resources
      - Never Die
      - One Hit Kill
      • 5 replies
    • Forest Survival - Zombie War v4.0 [+3 Cheats]
      Modded/Hacked App: Forest Survival - Zombie War By APPWILL COMPANY LTD
      Bundle ID: com.g1.forest.survival
      App Store Link: https://apps.apple.com/us/app/forest-survival-zombie-war/id6450904348?uo=4



      🤩 Hack Features

      - Enemy Can't Attack
      - Add Resources
      - Auto Win
       
      • 2 replies
    • Forest Survival - Zombie War v4.0 [+3 Jailed Cheats]
      Modded/Hacked App: Forest Survival - Zombie War By APPWILL COMPANY LTD
      Bundle ID: com.g1.forest.survival
      App Store Link: https://apps.apple.com/us/app/forest-survival-zombie-war/id6450904348?uo=4



      🤩 Hack Features

      - Enemy Can't Attack
      - Add Resources
      - Auto Win
      • 3 replies
    • NFL Rivals 26 Mobile Football v3.2.3 [ +3 Cheats ] AI Stupid
      Modded/Hacked App: NFL Rivals - Football Game By Mythical, Inc.
      Bundle ID: com.mythical.superteam
      iTunes Store Link: https://apps.apple.com/us/app/nfl-rivals-football-game/id1640028998?uo=4


      Hack Features:
      - AI ON Your Team 
      - Tackle 
      - No Interceptions
      • 66 replies
    • NFL Rivals 26 Mobile Football v3.2.3 [ +3 Jailed ] AI Stupid
      Modded/Hacked App: NFL Rivals - Football Game By Mythical, Inc.
      Bundle ID: com.mythical.superteam
      iTunes Store Link: https://apps.apple.com/us/app/nfl-rivals-football-game/id1640028998?uo=4


      Hack Features:

      - AI ON Your Team 
      - Tackle No
      - No Interceptions
      • 66 replies
    • Legend of Gladiator v1.7.0 [+5 Jailed Cheats]
      Modded/Hacked App: Legend of Gladiator By TapNation
      Bundle ID: com.onestepstudio.legendofgladiator
      App Store Link: https://apps.apple.com/us/app/legend-of-gladiator/id6745028264?uo=4



      🤩 Hack Features

      - Add Gems
      - Add Gold
      - Never Die
      - No Stamina Cost (Enable inside battle)
      - Remove Ads (Not rewarded)
      • 18 replies
    • Legend of Gladiator v1.7.0 [+5 Cheats]
      Modded/Hacked App: Legend of Gladiator By TapNation
      Bundle ID: com.onestepstudio.legendofgladiator
      App Store Link: https://apps.apple.com/us/app/legend-of-gladiator/id6745028264?uo=4

       

      🤩 Hack Features

      - Add Gems
      - Add Gold
      - Never Die
      - No Stamina Cost (Enable inside battle)
      - Remove Ads (Not rewarded)
      • 4 replies
    • Defense Legend 5: TD Strategy v1.0.44 [ +14 Cheats ] Currency Max
      Modded/Hacked App: Defense Legend 5: Survivor TD By GCENTER VIET NAM TECHNOLOGY JOINT STOCK COMPANY
      Bundle ID: com.Gcenter.DefenseLegend.TowerDefense.TD.survivor.V5
      App Store Link: https://apps.apple.com/us/app/defense-legend-5-survivor-td/id6449526611?uo=4

      🤩 Hack Features

      - ADS NO / Rewards Free
      - Unlimited Currency
      - Unlimited Resources
      - Heroes Unlocked
      - Heroes Skin Unlocked
      - Gun Unlocked
      - Unlimited Battle Items
      - Unlimited Skill Points
      - Premium Pass Active
      - Premium Pass / Claim Unlimited
      - Free Pass / Claim Unlimited
      - Unlimited Battle Cash / Sell Tower
      - Unlimited Tower Range
      • 2 replies
    • Defense Legend 5: TD Strategy v1.0.44 [ +14 Jailed ] Currency Max
      Modded/Hacked App: Defense Legend 5: Survivor TD By GCENTER VIET NAM TECHNOLOGY JOINT STOCK COMPANY
      Bundle ID: com.Gcenter.DefenseLegend.TowerDefense.TD.survivor.V5
      App Store Link: https://apps.apple.com/us/app/defense-legend-5-survivor-td/id6449526611?uo=4

      🤩 Hack Features

      - ADS NO / Rewards Free
      - Unlimited Currency
      - Unlimited Resources
      - Heroes Unlocked
      - Heroes Skin Unlocked
      - Gun Unlocked
      - Unlimited Battle Items
      - Unlimited Skill Points
      - Premium Pass Active
      - Premium Pass / Claim Unlimited
      - Free Pass / Claim Unlimited
      - Unlimited Battle Cash / Sell Tower
      - Unlimited Tower Range
      • 3 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