# Reverse Engineering APK

#### You:
i want to reverse engenner a android game apk first thing to do? im gonna use claude ai to help

#### ChatGPT:
The first thing to do is **work on a copy of the APK and set up a proper analysis environment**. Assuming you're examining software you legally own and have the right to analyze, a typical starting workflow is:

### 1. Make a backup

- Copy the original `.apk`.
- Never modify the original file.

### 2. Identify what kind of app it is

Look at:

- Package name
- Version
- Target Android version
- Whether it uses Unity, Unreal, or native libraries (`.so` files)

Useful tools:

- **APKTool** – extracts resources and Smali code.
- **JADX** – decompiles Dalvik bytecode into readable Java.
- Android Studio (optional).

### 3. Decompile the APK

Common commands:

```bash
apktool d game.apk
```

and

```bash
jadx-gui game.apk
```

You'll then inspect:

- `AndroidManifest.xml`
- `classes.dex`
- `lib/arm64-v8a/*.so`
- `assets/`
- `res/`

### 4. Determine the engine

Look for:

- `libunity.so` → Unity game.
- `libUE4.so` → Unreal Engine.
- Large `.obb` or asset bundles.

The engine determines the next steps.

### 5. Use Claude AI effectively

Instead of uploading the whole project, give Claude:

- Individual Smali files.
- Decompiled Java classes from JADX.
- Error messages.
- Directory structures.

Good prompts:

```
Explain what this class does.
```

```
Trace where player health is stored.
```

```
This APK uses Unity. Which files are likely to contain game logic?
```

```
Convert this Smali method into readable Java and explain it.
```

### Typical toolchain

| Purpose                  | Tool                    |
| ------------------------ | ----------------------- |
| Decompile APK            | APKTool                 |
| Java view                | JADX                    |
| Inspect native libraries | Ghidra                  |
| Dynamic analysis         | Frida                   |
| Runtime debugging        | Android Studio + ADB    |
| Network traffic          | mitmproxy or Burp Suite |

If you tell me:

- **Which game engine it uses (Unity, Unreal, unknown)?**
- **What you're trying to understand (assets, game logic, save files, networking, etc.)**

I can suggest a more specific reverse-engineering workflow.


#### You:
its unity

#### ChatGPT:
If it's a **Unity Android game**, the first thing I'd do is identify whether the game logic is in managed C# assemblies or mostly native code.

![Image](https://images.openai.com/static-rsc-4/Tp2Yo0fjZ82JFW6m3JMCUUajNBYktlb8w_swyBVei9Iaq_Tf6P6INGAHLAQHq3T5f6bhNZmADCUOkagy6-6LrdeHXYEMh1_dDK8xu6TNDJEWhgoTXMNpPJ9l9mGZOoqfG0rC0IK9Fhy_wx-wwNWTi8tCnR0zxqnpHwXhgTud1uK_WzQ-R7BYWMtAnmb_Vioj?purpose=fullsize)

![Image](https://images.openai.com/static-rsc-4/7oLoDoJfJE9dQnnXfR2tA64CX8RC525ikiuYL6D2v1Mb_fSk6umSIiUv5SLQEjfEa64rfhPWnOrDOR9rbdM5Uuw9b6uI1EG4kXGDfA3Jn42ZSTNMjm2HrYFFG1kHFlWJNrNuvFfFLPnqlRe9Bvy5-xjUEpUYjzO55hsEyI_76Xph5h6zgSPkvbxQ1y5xqY0B?purpose=fullsize)

![Image](https://images.openai.com/static-rsc-4/QTGxZG__8KRyB5umOMR2-tUuq3Rx_dZx13S6q1yvhRQfRtxhTqk84swee-q01_ghfARu0yE8meq39eH9902c-bXNDV742yKjTeNNV0ITY6GjxoXbUJeHapuzU6XBm1YDinsgjcVv2BjQccsmkQQM3ow0gKYQmZCy2rnF9e8Y7ZZxJWHGElFSAPUBs8y9nXSa?purpose=fullsize)

![Image](https://images.openai.com/static-rsc-4/iwr5lpAxXBjydAQ_Q15u7nCv1rMWfK6u1XiX98YplIvXV0ZrW0TmYRVNzmUqczfy-NH1PW3YOeaweUvqfrnKdvdbTiQwlSCUzgUBawiuzHPJ6X8F6dpkijD3uEupl7AY8lHlbqgkuhLwPanYVihCX6SqJXIBjHEFe25RiLUuS0p7zFJ6pHU-rMKNV3ZHGSmK?purpose=fullsize)

![Image](https://images.openai.com/static-rsc-4/j_Am1tH-CETaMURaQuM9pAmgSTfy3y-p6kO0odvbEevmBQbPCG_e5UKaj0yDxaIo-7lPYX--WRbjAZfdG4nk64Uey2N7PN5dLYPU18rcZNEJ8NFWBHQNxNWN4K6RlQfwGVJr-JsLrUpjrQI_R7z4DLPwMhxfWY2-NpxNk5ZNG03oqZzrG0XCJbvoKZsXi-oV?purpose=fullsize)

## Step 1: Extract the APK

```bash
apktool d game.apk
```

or just unzip it:

```bash
unzip game.apk -d game
```

---

## Step 2: Determine whether it's Mono or IL2CPP

Look inside:

```
assets/bin/Data/
```

### If you see:

```
Managed/
    Assembly-CSharp.dll
    Assembly-CSharp-firstpass.dll
```

then the game uses **Mono**, which is much easier.

Tools:

- JADX (APK inspection)
- dnSpyEx
- ILSpy

Open:

```
Assembly-CSharp.dll
```

Most game logic (player stats, inventory, enemies, etc.) is there.

---

### If you see:

```
global-metadata.dat
```

and:

```
lib/arm64-v8a/libil2cpp.so
```

then it's **IL2CPP**.

Tools:

- Il2CppDumper
- Il2CppInspector
- Ghidra
- IDA Free

The workflow becomes:

```
game.apk
↓
Extract
↓
global-metadata.dat + libil2cpp.so
↓
Il2CppDumper
↓
Generated C# headers/scripts
↓
Ghidra or IDA
```

---

## Step 3: Explore assets

Use:

- AssetStudio
- UABEA

These can extract:

- Textures
- Audio
- Models
- Prefabs
- ScriptableObjects

---

## Step 4: Let Claude help

A good workflow is:

1. Use the tools to obtain code or metadata.
2. Paste individual classes or functions into Claude.
3. Ask things like:

```
Explain what this class does.
```

```
Find where currency is modified.
```

```
Trace the damage calculation.
```

```
Identify anti-cheat mechanisms.
```

```
Show the call chain leading to player experience gain.
```

---

## Step 5: Learn the folder structure

Typical Unity APK:

```
assets/
    bin/
        Data/
            Managed/
            globalgamemanagers
            sharedassets*.assets

lib/
    arm64-v8a/
        libunity.so
        libil2cpp.so

res/
AndroidManifest.xml
```

---

The **very next thing I'd do** is check:

```
assets/bin/Data/
```

and tell me whether you have:

- `Managed/Assembly-CSharp.dll`

or

- `global-metadata.dat + libil2cpp.so`

because the entire reverse-engineering process depends on which one it is.


#### You:
bro i factory reset my pc i have NOTHING installed
C:\Users\adami>apktool
'apktool' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\adami>

#### ChatGPT:
No problem 😂. Start from absolute zero. You only need a few things.

## 1. Install Java (required for Apktool)

Download **Java 17 or newer** from:

[Eclipse Temurin JDK](https://adoptium.net/temurin/releases/?utm_source=chatgpt.com)

After installing, open a new Command Prompt and verify:

```cmd
java -version
```

You should see something like:

```text
openjdk version "17.x.x"
```

---

## 2. Install Apktool

Download:

- `apktool.jar`
- `apktool.bat`

from:

[Apktool official site](https://apktool.org/docs/install?utm_source=chatgpt.com)

Put both files in:

```text
C:\apktool\
```

For example:

```text
C:\apktool\
    apktool.jar
    apktool.bat
```

Then add `C:\apktool` to your Windows PATH, or just use:

```cmd
cd C:\apktool

apktool d C:\Users\adami\Downloads\game.apk
```

---

## 3. Download JADX

Get the GUI version from:

[JADX GitHub releases](https://github.com/skylot/jadx/releases?utm_source=chatgpt.com)

Extract it somewhere like:

```text
C:\jadx\
```

Then run:

```text
jadx-gui.exe
```

and open the APK.

---

## 4. Download dnSpyEx

For Unity Mono games:

[dnSpyEx GitHub](https://github.com/dnSpyEx/dnSpy/releases?utm_source=chatgpt.com)

Open:

```text
Assembly-CSharp.dll
```

inside:

```text
assets\bin\Data\Managed\
```

---

## 5. If the game uses IL2CPP

Download:

[Il2CppDumper GitHub](https://github.com/Perfare/Il2CppDumper?utm_source=chatgpt.com)

and later:

[Ghidra official site](https://ghidra-sre.org/?utm_source=chatgpt.com)

---

### Honestly, if I were rebuilding a reverse-engineering setup from scratch for Unity games, I'd install in this order:

1. Java
2. Apktool
3. JADX
4. dnSpyEx
5. 7-Zip
6. Il2CppDumper
7. Ghidra

Once you've got **Java + Apktool + JADX** installed, tell me which game you're analyzing and we'll figure out whether it's **Mono** or **IL2CPP** and go from there.


#### You:
why is it xapk

#### ChatGPT:
That's normal. **`.xapk` is just a ZIP package containing one or more APKs plus extra files.**

I checked the file you uploaded, and it contains:

- `com.shadowdev.casebattle.apk` ← the main APK
- `config.arm64_v8a.apk` ← architecture-specific split APK
- `manifest.json`

So the developers distributed the game as an **XAPK with split APKs**, which is common nowadays.

### First thing to do

1. Rename:

```text
apk.xapk
```

to

```text
apk.zip
```

or open it directly with **7-Zip**.

2. Extract everything.

You'll see something like:

```text
com.shadowdev.casebattle.apk
config.arm64_v8a.apk
manifest.json
```

3. Start with the **main APK**:

```text
com.shadowdev.casebattle.apk
```

Open it in **JADX** or run:

```cmd
apktool d com.shadowdev.casebattle.apk
```

---

### Next thing I would check

Inside the extracted APK, look for:

```text
assets/bin/Data/Managed/
```

If you see:

```text
Assembly-CSharp.dll
```

it's a **Mono Unity game** (easy to reverse).

If instead you find:

```text
global-metadata.dat
```

and

```text
libil2cpp.so
```

it's an **IL2CPP Unity game** (more involved, but still very doable).

If you want, I can examine the XAPK further and tell you **right now whether this game uses Mono or IL2CPP**.I actually checked your XAPK.

Good news: it's a **Unity IL2CPP game**.

I found:

```text
assets/bin/Data/Managed/Metadata/global-metadata.dat
```

in the main APK, and:

```text
lib/arm64-v8a/libil2cpp.so
lib/arm64-v8a/libunity.so
```

in the ARM64 split APK.

That means:

❌ No `Assembly-CSharp.dll`

✅ `global-metadata.dat`

✅ `libil2cpp.so`

So you're dealing with an IL2CPP build.

### What I'd do next

1. Extract the XAPK.

2. Grab:
   - `global-metadata.dat`
   - `libil2cpp.so`

3. Download:

[Il2CppDumper](https://github.com/Perfare/Il2CppDumper?utm_source=chatgpt.com)

4. Run:

```cmd
Il2CppDumper.exe libil2cpp.so global-metadata.dat output
```

5. Open the generated files in:
   - [Ghidra](https://ghidra-sre.org/?utm_source=chatgpt.com)
   - or [IDA Free](https://hex-rays.com/ida-free/?utm_source=chatgpt.com)

### Before installing Ghidra

Try this first:

- Install Java
- Download Il2CppDumper
- Extract the two files

Paths inside your XAPK are:

```text
com.shadowdev.casebattle.apk
 └─ assets/bin/Data/Managed/Metadata/global-metadata.dat
```

and

```text
config.arm64_v8a.apk
 └─ lib/arm64-v8a/libil2cpp.so
```

Once you have those two files on disk, send me a screenshot of the Il2CppDumper folder or any error it gives. I can walk you through the rest.
