Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker support for blutter #53

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM debian:unstable-slim
RUN apt update && apt install -y python3-pyelftools python3-requests git cmake ninja-build \
build-essential pkg-config libicu-dev libcapstone-dev
COPY . /blutter
VOLUME [ "/data/lib", "/data/output" ]
WORKDIR /blutter
CMD [ "python3", "blutter.py", "/data/lib", "/data/output"]
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,98 @@
# B(l)utter

Flutter Mobile Application Reverse Engineering Tool by Compiling Dart AOT Runtime

Currently the application supports only Android libapp.so (arm64 only).
Also the application is currently work only against recent Dart versions.

For high priority missing features, see [TODO](#todo)


## Environment Setup

This application uses C++20 Formatting library. It requires very recent C++ compiler such as g++>=13, Clang>=16.

I recommend using Linux OS (only tested on Deiban sid/trixie) because it is easy to setup.

### Debian Unstable (gcc 13)

- Install build tools and depenencies

```
apt install python3-pyelftools python3-requests git cmake ninja-build \
build-essential pkg-config libicu-dev libcapstone-dev
```

### Windows

- Install git and python 3
- Install latest Visual Studio with "Desktop development with C++" and "C++ CMake tools"
- Install required libraries (libcapstone and libicu4c)

```
python scripts\init_env_win.py
```

- Start "x64 Native Tools Command Prompt"

### macOS Ventura and Sonoma (clang 16)

- Install XCode
- Install clang 16 and required tools

```
brew install llvm@16 cmake ninja pkg-config icu4c capstone
pip3 install pyelftools requests
```

## Usage

Extract "lib" directory from apk file

```
python3 blutter.py path/to/app/lib/arm64-v8a out_dir
```

The blutter.py will automatically detect the Dart version from the flutter engine and call executable of blutter to get the information from libapp.so.

If the blutter executable for required Dart version does not exists, the script will automatically checkout Dart source code and compiling it.

## Update

You can use ```git pull``` to update and run blutter.py with ```--rebuild``` option to force rebuild the executable

```
python3 blutter.py path/to/app/lib/arm64-v8a out_dir --rebuild
```

## Usage with docker

You can use docker to run blutter without setting up the environment.

```
docker build -t blutter .
```

then,you can use it with following command

```
docker run --rm blutter -v /path/to/app/lib/arm64-v8a:/data/lib -v /path/to/out_dir:/data/output
```

blutter also have an unofficial docker image on dockerhub. you can use it with following command.Note that the image is not updated frequently.

```
docker run --rm yixinbc/blutter -v /path/to/app/lib/arm64-v8a:/data/lib -v /path/to/out_dir:/data/output
```

## Output files

- **asm/\*** libapp assemblies with symbols
- **blutter_frida.js** the frida script template for the target application
- **objs.txt** complete (nested) dump of Object from Object Pool
- **pp.txt** all Dart objects in Object Pool


## Directories

- **bin** contains blutter executables for each Dart version in "blutter_dartvm\<ver\>\_\<os\>\_\<arch\>" format
- **blutter** contains source code. need building against Dart VM library
- **build** contains building projects which can be deleted after finishing the build process
Expand All @@ -67,14 +101,16 @@ python3 blutter.py path/to/app/lib/arm64-v8a out_dir --rebuild
- **packages** contains the static libraries of Dart Runtime
- **scripts** contains python scripts for getting/building Dart


## Generating Visual Studio Solution for Development

I use Visual Studio to delevlop Blutter on Windows. ```--vs-sln``` options can be used to generate a Visual Studio solution.

```
python blutter.py path\to\lib\arm64-v8a build\vs --vs-sln
```

## TODO

- More code analysis
- Function arguments and return type
- Some psuedo code for code pattern
Expand Down