Hacking Android game using Frida - Part1

Hacking Android Games with Frida (Part1)

Disclaimer:

The techniques and information presented in this serial of blogs are strictly for educational purposes. Unauthorized use of these techniques for illicit activities, including game hacking, is strictly prohibited. The author and publisher do not condone or support any form of illegal or unethical behavior. It is essential to respect the intellectual property rights of game developers and adhere to the terms of service. Any actions taken based on the knowledge gained from this blog are solely at the reader’s own risk, and the author and publisher are not liable for any misuse or legal consequences that may arise.

Introduction:

Mobile gaming has become a massive industry, and many players strive to gain an edge by tweaking or modifying Android games. One powerful tool for game hacking is Frida, an open-source dynamic instrumentation framework. In this serial of blogs, we will guide you through the process of creating a Frida project using TypeScript, enabling you to hack Android games and unlock new possibilities.
I will put all source codes in here.

The Game for Testing:

For the purpose of testing and learning, we will use “MouseBot”, a popular and addictive runner game developed by Vector Unit. You can download the Android version of the game for free from the Play Store here. It’s free.

Prerequisites:

To follow along with this tutorial, you’ll need the following:

  • A basic understanding of TypeScript.
  • Node.js installed on your machine.
  • A rooed Android device or emulator.
  • Frida installed on your machine.
  • Test game , MouseBot, installed in your machine.

Step 1: Setting Up the Project

  • Create a new directory for your Frida project.
  • Open a terminal or command prompt and navigate to the project directory.
  • Create a file named package.json in the project directory. You can view its content from here.
  • Create a file named tsconfig.json in the project directory. You can view its content from here.
  • Install the Frida library for TypeScript and frida-compile by executing the following command, I have write these libraries in this package.json:
    1
    npm i 

Step 2: Writing the Frida Script

  • Inside your project directory, create a new TypeScript file, index.ts:
  • Open the file in your preferred code editor.
    Write the Frida script to print Hello world to the console.
    1
    2
    3
    4
    5
    6
    const test = ()=>{
    console.log('hello world')
    }

    console.log('##################################################')
    test()

Step 3: Running the Frida Script

  • Save the game-hack.ts file.
  • Open a terminal or command prompt and navigate to the project directory.
  • Create a file named Makefile in the project directory. Its content is shown as follows:
    1
    2
    all:
    ./node_modules/frida-compile/bin/compile.js -o _agent.js index.ts
  • Compile the TypeScript file into JavaScript using the following command:
    1
    make
    This command will create a file named _agent.js in the project directory.
  • Run the Frida script using the following command:
  • Setup your Android device, start frida-server. This page has detailed instructions for this step.
  • Launch MouseBot on your Android device or emulator.
  • Execute the following command to inject the Frida script into the game process:
    1
    frida -U -l _agent.js -n 'MouseBot'
    If everything goes well, Frida will inject the script into the game process. and you will see Hello world in the console.

Conclusion:

In this blog, we explored the initial steps of creating a Frida project using TypeScript and injecting a basic Frida script into an Android game. We emphasized the importance of using this knowledge responsibly and for educational purposes only. In the next blog of this series, we will delve deeper into Frida’s capabilities and explore more advanced game hacking techniques. Stay tuned and happy hacking!

Author

Meng Xipeng

Posted on

2023-08-29

Updated on

2023-10-05

Licensed under

Comments