Skip to main content

Unpacking framework for common android malware

Project description

🫙 kavanoz 🫙

Statically unpacking common android banker malware. Ever wanted to get payload from packed malware without running android emulator ? Me neither.

:eyes: Installation

pip install kavanoz

To install from source, clone the repository and do an editable install with -e. Which means if you edit or add new plugins to the project it will be used without reinstalling.

git clone https://github.com/eybisi/kavanoz.git
cd kavanoz
pip install -e .

:zap: Usage

from cmdline

kavanoz /tmp/filepath

You can use -vvv parameter to print verbose logs. (useful for debugging plugins)

as python library

from kavanoz.core import Kavanoz
from kavanoz import utils

utils.set_log("DEBUG")
k = Kavanoz(apk_path="tests/test_apk/coper.apk")
for plugin_result in k.get_plugin_results():
    if plugin_result["status"] == "success":
        print("Unpacked")
        print(plugin_result)
        break

:snake: Scripts:

:gear: Development

Make sure to install kavanoz as editable (with -e). To add new plugins just create new file in loader folder. Extend Unpacker class from unpack_plugin.py file. Define start_decrypt function with your implementation.

def start_decrypt(self, apk_object: APK, dexes: "list[DEX]"):

Add following function to make early exit from plugin.

def lazy_check(self,apk_object:APK, dexes: "list[DEX]"):

If extraction is successful assign self.decrypted_payload_path with extracted file path. You can use helper functions from unpacker class:

  • get_array_data
  • get_smali
  • find_method(class_name,method_name,descriptor="")
  • check_and_write_file(file_data) : checks file has dex, zip and zlib headers and writes unpacked dex with name : "external-{m[:8]}.dex"

:book: Tips

  • self.dexes hold dex objects. You can get class with dex.get_class(smali_annotation_of_class).
  • You can use get_smali function and give target method obj to get smali represantation of target method. Then apply some regex to get data from smali. There are lots of defined regexs in smali_regexes.py file to lookup.
  • Most of the time packers use file from asset folder. You can get files with self.apk_object.get_files()
  • Most of the time packers use Application class to start unpacking sequence. Use application = self.apk_object.get_attribute_value("application", "name") to get application class defined in manifest file.

Thanks:

apkdetect.com for unique samples to work with.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kavanoz-0.0.4.tar.gz (431.0 kB view details)

Uploaded Source

Built Distribution

kavanoz-0.0.4-py3-none-any.whl (440.4 kB view details)

Uploaded Python 3

File details

Details for the file kavanoz-0.0.4.tar.gz.

File metadata

  • Download URL: kavanoz-0.0.4.tar.gz
  • Upload date:
  • Size: 431.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for kavanoz-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f5316511d72028175e7e484637969471991306d4f10e4aab95c00584ba8c5927
MD5 fce9e4e71672104c0022f1d98cdf38a1
BLAKE2b-256 cdb46a5a7c54e126455291bfecee76d35ffd901d71c6b9d6e3296cefd62f6523

See more details on using hashes here.

File details

Details for the file kavanoz-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: kavanoz-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 440.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for kavanoz-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3dd55988ab78dab508c80f521793c9aaebc0b7d36ee294c9c7945ef0ec237ac0
MD5 d1224cf95e4a736961ba4fe955111f29
BLAKE2b-256 5fff7c5be004794e053d426f9071a5a4bc81798b7f50f41e88848f882c58b363

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page