Git Product home page Git Product logo

kavanoz's Introduction

๐Ÿซ™ kavanoz ๐Ÿซ™

Statically unpacking common android banker malware.

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

Requirements

  • python >= 3.9
  • arc4
  • androguard
  • lief
  • unicorn
  • androidemu
  • pycryptodome

๐Ÿ‘€ Installation

pip install -e . --user

โšก Usage

from cmdline

kavanoz /tmp/filepath

from python library

from kavanoz.core import Kavanoz
k = Kavanoz(apk_path)
for plugin_result in k.get_plugin_results():
    if plugin_result['status'] = 'success':
        print('Unpacked')
        print(plugin_result)

๐Ÿ Scripts:

Note

Do not use cryptodome for rc4 decryption. It does not work with 2-4 key size.

โš™๏ธ Development

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, dvms: "list[DalvikVMFormat]"):

Add following function to make early exit from plugin.

def lazy_check(self,apk_object:APK, dvms: "list[DalvikVMFormat]"):

If extraction is succesful 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"

๐Ÿ“– Tips

  • self.dvms hold dex dvm objects. You can get class with dvm.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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.