BAPKA: A Detailed Overview
BAPKA (Akamai BMP APK Analyzer) is a specialized tool designed to detect the version of Akamai Bot Manager Premier (BMP) used in Android APK files.
Step-by-Step Guide to Using BAPKA
-
Install Prerequisites:
- Before using BAPKA, you need two primary tools:
apktool
andPython 3
. apktool
is used for reverse engineering Android APK files. You can download and install it from apktool's website.- Ensure you have
Python 3
installed on your system. You can download it from Python's official website.
- Before using BAPKA, you need two primary tools:
-
Download BAPKA:
- Clone or download the BAPKA repository from its GitHub page.
Or get from here:
- Clone or download the BAPKA repository from its GitHub page.
#!/usr/bin/env python3
import argparse
import glob
import os
import subprocess
import re
TMPDIR = "/tmp/bapka"
def apktool_decompile(file):
print("APKTOOL: Starting to decompile")
outdir = os.path.join(TMPDIR, "out")
try:
subprocess.run(
["apktool", "d", file, "-b", "-f", "-r", "-o", outdir], check=True
)
except Exception as e:
print(f"APKTOOL: Failed to decompile the apk: {e}")
exit(1)
print("APKTOOL: Decompiled successfully")
return outdir
def grep(root_dir, pattern) -> None | re.Match:
pattern = re.compile(pattern)
for path in glob.iglob("**/*.smali", root_dir=root_dir, recursive=True):
abspath = os.path.join(root_dir, path)
with open(abspath, "r") as f:
for line in f:
result = re.search(pattern, line)
if result is not None:
return result
return None
def get_bmp_version(dir):
result = grep(dir, "BMPSDK/(.+) \\(")
if result is None:
print("ERROR:")
exit(1)
return result.groups()[0]
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("filename", help=".apk file to analyze")
args = parser.parse_args()
config = vars(args)
decompiled_dir = apktool_decompile(config["filename"])
bmp_version = get_bmp_version(decompiled_dir)
print("Akamai BMP found!")
print(f"BMP Version: {bmp_version}")
-
Prepare the APK File:
- Obtain the APK file you want to analyze. Ensure you have the correct path to this file on your system.
-
Run BAPKA:
- Open a terminal or command prompt.
- Navigate to the directory where you downloaded BAPKA.
- Run the following command:
Replace./bapka <path-to-apk.apk>
<path-to-apk.apk>
with the actual path to your APK file.
-
Analyze the Output:
- After running the command, BAPKA will analyze the APK file and output the version of Akamai BMP used in it.
- This information is crucial for understanding the bot management capabilities integrated into the app.
-
Contribute to the Project:
- If you have information about other apps using Akamai BMP or newer versions, you can contribute to the BAPKA project by submitting a Pull Request on GitHub.