Debian Codegraph @

droidlysis.egg-info/PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: droidlysis
3 Version: 3.4.7
4 Summary: DroidLysis: pre-analysis of suspicious Android samples
5 Home-page: https://github.com/cryptax/droidlysis
6 Author: @cryptax
7 Author-email: [email protected]
8 License: MIT
9 Keywords: android malware reverse
10 Classifier: Programming Language :: Python :: 3
11 Classifier: License :: OSI Approved :: MIT License
12 Classifier: Development Status :: 3 - Alpha
13 Classifier: Operating System :: Unix
14 Classifier: Topic :: Software Development :: Disassemblers
15 Requires-Python: >=3.0
16 Description-Content-Type: text/markdown
17 License-File: LICENSE
18 Requires-Dist: configparser>=4.0.2
19 Requires-Dist: python-magic==0.4.12
20 Requires-Dist: requests
21 Requires-Dist: SQLAlchemy>=1.1.1
22 Requires-Dist: rarfile>=3.0
23 Requires-Dist: platformdirs
24
25 # DroidLysis
26
27 DroidLysis is a **pre-analysis tool for Android apps**: it performs repetitive and boring tasks we'd typically do at the beginning of any reverse engineering. It disassembles the Android sample, organizes output in directories, and searches for suspicious spots in the code to look at.
28 The output helps the reverse engineer speed up the first few steps of analysis.
29
30 DroidLysis can be used over Android packages (apk), Dalvik executables (dex), Zip files (zip), Rar files (rar) or directories of files.
31
32 <img src="https://img.shields.io/badge/PyPi%20-3.4.7-blue">
33
34 ## Installing DroidLysis
35
36 1. Install required system packages
37
38 ```
39 sudo apt-get install default-jre git python3 python3-pip unzip wget libmagic-dev libxml2-dev libxslt-dev
40 ```
41
42
43 2. Install Android disassembly tools
44
45 - [Apktool](https://ibotpeaches.github.io/Apktool/) ,
46 - [Baksmali](https://bitbucket.org/JesusFreke/smali/downloads), and optionally
47 - [Dex2jar](https://github.com/pxb1988/dex2jar) and
48
49 ```
50 $ mkdir -p ~/softs
51 $ cd ~/softs
52 $ wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.9.3.jar
53 $ wget https://bitbucket.org/JesusFreke/smali/downloads/baksmali-2.5.2.jar
54 $ wget https://github.com/pxb1988/dex2jar/releases/download/v2.4/dex-tools-v2.4.zip
55 $ unzip dex-tools-v2.4.zip
56 $ rm -f dex-tools-v2.4.zip
57 ```
58
59 3. Get DroidLysis from the Git repository (preferred) or from pip
60
61 Install from Git in a Python virtual environment (`python3 -m venv`, or pyenv virtual environments etc).
62
63 ```
64 $ python3 -m venv venv
65 $ source ./venv/bin/activate
66 (venv) $ pip3 install git+https://github.com/cryptax/droidlysis
67 ```
68
69 Alternatively, you can install DroidLysis directly from PyPi (`pip3 install droidlysis`).
70
71 4. Configure `conf/general.conf`. In particular make sure to change `/home/axelle` with your appropriate directories.
72
73 ```
74 [tools]
75 apktool = /home/axelle/softs/apktool_2.9.3.jar
76 baksmali = /home/axelle/softs/baksmali-2.5.2.jar
77 dex2jar = /home/axelle/softs/dex-tools-v2.4/d2j-dex2jar.sh
78 keytool = /usr/bin/keytool
79 ...
80 ```
81
82 5. Run it:
83
84 ```
85 python3 ./droidlysis3.py --help
86 ```
87
88
89 ## Configuration
90
91 The configuration file is `./conf/general.conf` (you can switch to another file with the `--config` option).
92 This is where you configure the location of various external tools (e.g. Apktool), the name of pattern files
93 (by default `./conf/smali.conf`, `./conf/wide.conf`, `./conf/arm.conf`, `./conf/kit.conf`) and the name of
94 the database file (only used if you specify `--enable-sql`)
95
96 Be sure to specify the correct paths for disassembly tools, or DroidLysis won't find them.
97
98
99 ## Usage
100
101 DroidLysis uses **Python 3**. To launch it and get options:
102
103 ```
104 droidlysis --help
105 ```
106
107 For example, test it on [Signal's APK](https://signal.org/android/apk/):
108
109 ```
110 droidlysis --input Signal-website-universal-release-6.26.3.apk --output /tmp --config /PATH/TO/DROIDLYSIS/conf/general.conf
111 ```
112
113 ![](./images/example.png)
114
115 DroidLysis outputs:
116
117 - A summary on the console (see image above)
118 - The unzipped, pre-processed sample in a subdirectory of your output dir. The subdirectory is named using the sample's filename and sha256 sum. For example, if we analyze the Signal application and set `--output /tmp`, the analysis will be written to `/tmp/Signalwebsiteuniversalrelease4.52.4.apk-f3c7d5e38df23925dd0b2fe1f44bfa12bac935a6bc8fe3a485a4436d4487a290`.
119 - A database (by default, SQLite `droidlysis.db`) containing properties it noticed.
120
121 ## Options
122
123 Get usage with `droidlysis --help`
124
125 - The input can be a file or a directory of files to recursively look into. DroidLysis knows how to process Android packages, DEX, ODEX and ARM executables, ZIP, RAR. DroidLysis won't fail on other type of files (unless there is a bug...) but won't be able to understand the content.
126
127 - When processing directories of files, it is typically quite helpful to move processed samples to another location to know what has been processed. This is handled by option `--movein`. Also, if you are only interested in statistics, you should probably clear the output directory which contains detailed information for each sample: this is option `--clearoutput`. If you want to store all statistics in a SQL database, use `--enable-sql` (see [here](#sqlite_database))
128
129 - DroidLysis's analysis does not inspect known 3rd party SDK by default, i.e. for instance it won't report any suspicious activity from these. If you want them to be inspected, use option `--no-kit-exception`. This usually creates many more detected properties for the sample, as SDKs (e.g. advertisment) use lots of flagged APIs (get GPS location, get IMEI, get IMSI, HTTP POST...).
130
131 ## Sample output directory (`--output DIR`)
132
133 This directory contains (when applicable):
134
135 - A readable `AndroidManifest.xml`
136 - Readable resources in `res`
137 - Libraries `lib`, assets `assets`
138 - Disassembled Smali code: `smali` (and others)
139 - Package meta information: `META-INF`
140 - Package contents when simply unzipped in `./unzipped`
141 - DEX executable `classes.dex` (and others), and converted to jar: `classes-dex2jar.jar`, and unjarred in `./unjarred`
142
143 The following files are generated by DroidLysis:
144
145 - `autoanalysis.md`: lists each pattern DroidLysis detected and where.
146 - `report.md`: same as what was printed on the console
147
148 If you do not need the sample output directory to be generated, use the option `--clearoutput`.
149
150 ## Import trackers from Exodus etc (`--import-exodus`)
151
152 ```
153 $ python3 ./droidlysis3.py --import-exodus --verbose
154 Processing file: ./droidurl.pyc ...
155 DEBUG:droidconfig.py:Reading configuration file: './conf/./smali.conf'
156 DEBUG:droidconfig.py:Reading configuration file: './conf/./wide.conf'
157 DEBUG:droidconfig.py:Reading configuration file: './conf/./arm.conf'
158 DEBUG:droidconfig.py:Reading configuration file: '/home/axelle/.cache/droidlysis/./kit.conf'
159 DEBUG:droidproperties.py:Importing ETIP Exodus trackers from https://etip.exodus-privacy.eu.org/api/trackers/?format=json
160 DEBUG:connectionpool.py:Starting new HTTPS connection (1): etip.exodus-privacy.eu.org:443
161 DEBUG:connectionpool.py:https://etip.exodus-privacy.eu.org:443 "GET /api/trackers/?format=json HTTP/1.1" 200 None
162 DEBUG:droidproperties.py:Appending imported trackers to /home/axelle/.cache/droidlysis/./kit.conf
163 ```
164
165 Trackers from Exodus which are not present in your initial `kit.conf` are appended to `~/.cache/droidlysis/kit.conf`. Diff the 2 files and check what trackers you wish to add.
166
167
168 ## SQLite database{#sqlite_database}
169
170 If you want to process a directory of samples, you'll probably like to store the properties DroidLysis found in a database, to easily parse and query the findings. In that case, use the option `--enable-sql`. This will automatically dump all results in a database named `droidlysis.db`, in a table named `samples`. Each entry in the table is relative to a given sample. Each column is properties DroidLysis tracks.
171
172 For example, to retrieve all filename, SHA256 sum and smali properties of the database:
173
174 ```
175 sqlite> select sha256, sanitized_basename, smali_properties from samples;
176 f3c7d5e38df23925dd0b2fe1f44bfa12bac935a6bc8fe3a485a4436d4487a290|Signalwebsiteuniversalrelease4.52.4.apk|{"send_sms": true, "receive_sms": true, "abort_broadcast": true, "call": false, "email": false, "answer_call": false, "end_call": true, "phone_number": false, "intent_chooser": true, "get_accounts": true, "contacts": false, "get_imei": true, "get_external_storage_stage": false, "get_imsi": false, "get_network_operator": false, "get_active_network_info": false, "get_line_number": true, "get_sim_country_iso": true,
177 ...
178 ```
179
180 ## Property patterns
181
182 What DroidLysis detects can be configured and extended in the files of the `./conf` directory.
183
184 A pattern consist of:
185
186 - a **tag** name: example `send_sms`. This is to name the property. Must be unique across the `.conf` file.
187 - a **pattern**: this is a regexp to be matched. Ex: `;->sendTextMessage|;->sendMultipartTextMessage|SmsManager;->sendDataMessage`. In the `smali.conf` file, this regexp is match on Smali code. In this particular case, there are 3 different ways to send SMS messages from the code: sendTextMessage, sendMultipartTextMessage and sendDataMessage.
188 - a **description** (optional): explains the importance of the property and what it means.
189
190 ```
191 [send_sms]
192 pattern=;->sendTextMessage|;->sendMultipartTextMessage|SmsManager;->sendDataMessage
193 description=Sending SMS messages
194 ```
195
196
197 ## Importing Exodus Privacy Trackers
198
199 Exodus Privacy maintains a list of various SDKs which are interesting to rule out in our analysis via `conf/kit.conf`.
200 Add option `--import_exodus` to the droidlysis command line: this will parse existing trackers Exodus Privacy knows and which aren't yet in your `kit.conf`. Finally, it will **append** all new trackers to `~/.cache/droidlysis/kit.conf`.
201
202 Afterwards, you may want to sort your `kit.conf` file:
203
204 ```python
205 import configparser
206 import collections
207 import os
208
209 config = configparser.ConfigParser({}, collections.OrderedDict)
210 config.read(os.path.expanduser('~/.cache/droidlysis/kit.conf'))
211 # Order all sections alphabetically
212 config._sections = collections.OrderedDict(sorted(config._sections.items(), key=lambda t: t[0] ))
213 with open('sorted.conf','w') as f:
214 config.write(f)
215 ```
216
217 ## JEB script for smali properties
218
219 This script helps you search for methods on JEB UI that contain code that matches the smali pattern and easily navigates to those functions. When you load the script and select `details.md` file among the droidlysis analysis files, a search box will appear. Once moved, you can easily bring up the search windows again by using recent script execution shortcut.
220
221 - JEB > File > Scripts > Script selector > `script/DroidlysisSearch.py`
222 - JEB > File > Scripts > Run last Script
223
224 ## Updates
225
226 - v3.4.6 - Detecting manifest feature that automatically loads APK at install
227 - v3.4.5 - Creating a writable user kit.conf file
228 - v3.4.4 - Bug fix #14
229 - v3.4.3 - Using configuration files
230 - v3.4.2 - Adding import of Exodus Privacy Trackers
231 - v3.4.1 - Removed dependency to Androguard
232 - v3.4.0 - Multidex support
233 - v3.3.1 - Improving detection of Base64 strings
234 - v3.3.0 - Dumping data to JSON
235 - v3.2.1 - IP address detection
236 - v3.2.0 - Dex2jar is optional
237 - v3.1.0 - Detection of Base64 strings
238
239