Hacking Android games using MATLAB [without root]

Hacking Android games using MATLAB [without root]

Jan 19, 2015. | By: Sandeep Nadella

Have you ever wondered if you can do some image processing stuff on a game and automate it to make a high score? This post discusses how to hack android games using image processing in Matlab.

We will be hacking two games:

You need not be a pro Matlab user for this. Just having Matlab installed and having an Android phone alone is enough. I’m currently using Matlab in Windows but you can even try out Matlab in Linux or Scilab for this. The commands might differ if you are using Scilab. The Android test device that I will be using is the OnePlus One. It has a resolution of 1080X1920(On screen buttons turned off). So the pixel location that  I’ll be using may vary depending on the device you are using. I will tell you how to determine these locations for your device. This method works on all Android devices including Android Wear.  So without any delay lets get started.


Components required:


Step 1: Enabling developer options and installing drivers

Go to Settings->About phone. Scroll down to Build number and tap it 5-6 times until it says developer options are enabled. Now download the ADB device drivers for your device. You can get these drivers from Universal drivers or developer.android.com. If these don’t work then you can google the term “ADB drivers for ____” and download the drivers suitable for your device from XDA developers forum. Check in Device Manager if the installation was successful. You will notice Android ADB device when connected. Now download the zip file containing the adb file and Matlab scripts from here StickHero_DrawABox_Hack.

Note: This check is not required if you are confident that the drivers are installed properly. Open command prompt and navigate to the directory of the extracted game folder containing adb.exe file. The command is “cd dir_name” to change folders in Windows and Linux. “ls” to view contents of current directory. From this directory type “adb devices”. Your device name must be displayed else drivers are not installed properly if so reinstall from a different source. If installed properly depending on the Android version running a prompt may pop up on the device containing RSA fingerprint key. Check the option “Always allow” and confirm.


Step 2: Setting up Matlab

Make sure Matlab being installed has Image Processing Toolbox. This post might help. Open Matlab and set its current working directory to the game folder extracted.


Step 3: Running the script and understanding it

Make sure your current working directory points to the game folder that you are going to hack. Open the game in your device and click play. Then run the matlab script file(.m file). The code is written keeping in mind of people who are new to programming. The code is well commented. Lot of optimization of code is possible which is neglected for convenience. “Test.m” file contains the code for capturing a single screenshot and determining the pixel locations for your device. Run this code after clicking play and use data cursor to determine the pixel locations.

Note: For running the script stickherowithfruits.m you need to copy sendevent_input.sh file to /sdcard/ of your device. This method is not reliable to achieve high scores. Use stickhero.m for achieving high scores.(Higher than the scores that can be achieved by using Arduino mentioned here :p :)).





Video demonstration of the projects:



Subscribe

Subscribe to this blog via RSS.

Categories

Android-games 5

Matlab 5

Adb tool 5

Recent Posts

Popular Tags

Android-games (5) Matlab (5) Adb tool (5)

About

We are still figuring out on this one!

Social Links

Our Bunker

Innovation Garage, 2nd floor,
Center for Innovation and Incubation,
NIT Warangal, India