MobileSubstrate game hacking on iphone

967 views Asked by At

I am practicing mobilesubstrate hacking on the game Kingdom Age (v2.0) for ipad.

I just want to make a ton of in-game money, but I am getting nowhere. The player is defined in a class, CCPlayer and is sometimes server checked.

So I am trying to get to the heart of the data, inside the CCGameInformation Class. The function -(id)activePlayer is callet a lot (like 30 times a sec) so I thought that was a nice place to start.

CCPlayer is defined (in the include files) as

@interface CCPlayer : FZPlayer <NSCoding>
{
NSString *townName;
NSString *rawLastUpdateEnergyTime;
NSString *rawLastUpdateStaminaTime;
NSString *rawExpansionTimeStarted;
NSString *rawBankUpgradeTimeStarted;
...
int gold;
int level;
int attack;
...
@end

I declared it in Tweaks.xm as:

@interface CCPlayer:NSObject
{
NSString *townName;
NSString *rawLastUpdateEnergyTime;
NSString *rawLastUpdateStaminaTime;
NSString *rawExpansionTimeStarted;
NSString *rawBankUpgradeTimeStarted;
...
int gold;
int level;
int attack;
...
@end

I actually included the whole thing, only changed the base class.

CCGameInformation is defined as:

@interface CCGameInformation : _ACFacebookAppIdKey
{
CCPlayer *user_;
CCLevel *userLevel_;
....
}

I defined it in Tweaks.xm as

@interface CCGameInformation : NSObject
{
CCPlayer *user_;
}
@end

And my hook looks like:

%hook CCGameInformation
- (id)activePlayer 
{
    CCPlayer* player = (CCPlayer*)%orig;
    MSHookIvar<int>(player, "energy") = 10;
    NSLog(@"Energy:%d\n",MSHookIvar<int>(player, "energy"));
    return player;
}

But it does not work at all. It does print out the "Energy:10" as expected, but the in-game energy does not change.

Am I using the hooking process and decelerations correctly, or is the game just more protected then I expect?

Thanks.

1

There are 1 answers

0
Terry On

The game may in fact store all of the user data on server. This is more prominent in games which feature in-app purchases. Unfortunately there is little that can be done in that case. If you'd like to test it further consider this method, for example:

%hook CCPlayer

-(int)gold
{
    return 1000;     //amount of gold.
}
%end