BareDroid allows for bare-metal analysis on Android devices. See the paper here
backup: used to create a backup of the device. It is a bash script which stores a copy of:
- userdata
- system
- boot in the store partition (partition number 30). This is needed only when you want to setup a new device.
restore: used to restore a previous backup. It is a bash script which restore a) system, b) userdata and c) userdatanew partition.
backup_and_restore: used to create a backup and restore it. It is a merge of the previous scripts.
setup_device:
- setup: used to setup a device. Basically, this script creates the new partitions;
update: contains the python scripts used to manage the infrastructure.
- adb.py: provides APIs used to send command through adb shell;
- device.py: contains information about the update_manager associated to the device (deprecated, not used in the next version);
- analysis.py: it bridges the gap between the infrastructure and the experiments. For a detailed description see below;
- util.py: provides utilities (deprecated);
- manager.py: manages the command line interface;
- updtae_manager.py: it is the core of the infrastructure. It is a separate process which manages the update and analysis process;
- update_manager_device.py: represents a separate process used to update the device during the analysis;
- update_manager_recovery.py: represents a separate process used to update the device during the reboot. it is used to perform a relabel of the userdata partition ( SELinux :) );
update/config: contains cfg and info files used to setup the python scripts.
- config.cfg: contains the information about where to save the logs, and which scripts use to perform the analysis
- devices.info: contains general information about the devices (e.g., user, AndroidId)
- connect the device
- run the "./script" file (the script reboots the device in recovery mode and run the script)
- reboot the device
- connect the device
- run the "./script" file (the script reboots the device in recovery mode and run the script)
- reboot the device
The goal of this script is to provide a wrapper between the experiment and the infrastructure, SetupAndStart is the main method and the only one called by the infrastructure (i.e., update_manager.py line 178). It setups the environment for the experiment (e.g., adb root) and run the experiment. If you want to use your code in an experiment you need to:
- modify the config.cfg file. In the stanza 'Project' put the absolute path to the code that you want to use;
- create an python script containing the class used in the stanza 'class' of the config.cfg file;
- define a 'run' method in the config.cfg file. This is the method used by the wrapper to start the experiment.
- see 'setup_device';
- run the backup and restore scripts;
- add info to the 'update/config/device.info' file (e.g., AndroidId); [mandatory]
general consideration:
- device -> Settings -> Storage -> USB computer connection -> disable MTP
- device -> Security -> Screen lock -> None
- be sure you can install untrusted app (i.e., from outside the market)
Architectural overview:
- to run an experiment you need to include the absolute path of the folder containing the samples to analyze;
- run the manager start script against the folder containing the apps to analyze;
example
./start_baredroid path/to/folder/containing/samples
- the script will prompt a command line interface which allows the user to interact with the infrastructure (e.g., start experiment);
- select option '2' to run the experiment;
- when the experiment is finished click on 'q';
- the results are stored in the 'update/experiment' folder.
email: simone.mutti@unibg.it