Skip to content

Commit 7416360

Browse files
committed
Added version configuration and sanitize_path
1 parent 62b80a0 commit 7416360

File tree

4 files changed

+92
-25
lines changed

4 files changed

+92
-25
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog
22

3+
### 0.7.57
4+
- CHANGE: Added sanitize_path in setup option
5+
- ADDED: Version configuration for tools
6+
37
### 0.7.56
48
- CHANGE: Updated build-tools
59

mpt/console.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def setup_pentest(apk):
9494
log.info("Folder for security assessment {} created".format(Fore.CYAN + settings.PENTEST_FOLDER + Style.RESET_ALL))
9595

9696
# Replace masked characters with "", fix errors with special chars in shell
97-
new_apk_filename = re.sub(r'[^\w.-]', '', apk_file)
97+
new_apk_filename = functions.sanitize_path(apk_file)
98+
9899
if apk_file != new_apk_filename:
99100
log.warn(f"APK file renamed to {new_apk_filename}")
100101
app_pentest_file_location = os.path.join(settings.APP_FOLDER, os.path.basename(new_apk_filename))

mpt/functions.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import random
3+
import re
34
import string
45
import time
56

@@ -656,6 +657,19 @@ def get_device_architecture():
656657
return arch
657658

658659

660+
# sanitize path – replace unsafe characters in file name only
661+
def sanitize_path(path):
662+
dir_name = os.path.dirname(path)
663+
base_name = os.path.basename(path)
664+
665+
# Replace disallowed characters and whitespace with underscores
666+
# Includes: < > : " / \ | ? * control chars, whitespace, (), []
667+
safe_base = re.sub(r'[<>"\/\\|?*\[\]\(\)\x00-\x1F\s]', '_', base_name)
668+
669+
return os.path.join(dir_name, safe_base)
670+
671+
672+
659673
# data for wifi username and password generation
660674
adjectives = [
661675
"Silly", "Wobbly", "Sneaky", "Clumsy", "Jolly", "Grumpy", "Nifty", "Goofy", "Zany", "Loopy",

mpt/settings.py

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import mpt.config
66
from mpt.config import Config
77

8-
__version__ = '0.7.56'
8+
__version__ = '0.7.57'
99
HOME_FOLDER = expanduser("~")
1010
DEFAULT_MOBILE_FOLDER = os.path.join(HOME_FOLDER, "tools/MOBILE/")
1111
MPT_BIN = os.path.join(DEFAULT_MOBILE_FOLDER, 'bin')
@@ -28,6 +28,32 @@
2828
# sh does not support source command and it was replaces with .
2929
# "The . is POSIX-compliant and also works in /bin/sh."
3030

31+
32+
# ANDROID_TOOLS Versions
33+
# for the tools without version use release date e.g. 2025.03.07
34+
VERSION_MOBSF = '4.3.0' # check: 'https://github.com/MobSF/Mobile-Security-Framework-MobSF'
35+
VERSION_RMS = '1.5.23' # check: https://github.com/m0bilesecurity/RMS-Runtime-Mobile-Security',
36+
VERSION_OBJECTION = '1.11.0'
37+
VERSION_SPOTBUGS = '4.9.3'
38+
VERSION_JADX = '1.5.1'
39+
VERSION_JD_GUI = '1.6.6'
40+
VERSION_LUYTEN = '0.5.4'
41+
VERSION_SQLITESTUDIO = '3.4.17'
42+
VERSION_PIDCAT = '2018.12.22' # check: https://github.com/healthluck/pidcat-ex
43+
VERSION_PIDCAT_EX = '2018.12.22' # check: https://github.com/healthluck/pidcat-ex.git
44+
VERSION_ADUS = '2025.03.19' # check https://github.com/ByteSnipers/adus
45+
VERSION_FRIDUMP = '2024.11.07' # check https://github.com/rootbsd/fridump3
46+
VERSION_AAPT = 'r34-rc3'
47+
VERSION_ADB = '35.0.2' # check version https://developer.android.com/tools/releases/platform-tools
48+
VERSION_ABE = '2025.01.15'
49+
VERSION_APKTOOL = '2.11.1'
50+
VERSION_DEX2JAR = '2.4'
51+
VERSION_JANUS = '2023.05.16'
52+
VERSION_LINUX_ROUTER = '2024.12.18'
53+
VERSION_KITTY = '0.40.1'
54+
VERSION_SCRCPY = '3.1'
55+
56+
3157
ANDROID_TOOLS = {
3258
# available parameters
3359
# bin
@@ -71,13 +97,15 @@
7197
'MobSF': {
7298
# check updates: 'https://github.com/MobSF/Mobile-Security-Framework-MobSF'
7399
# fix dependency in mobSF (remove if not required) -> sed -i \'s/packaging = ">=21\.3,<22\.0"/packaging = ">=24\.2"/\' pyproject.toml
74-
'url': 'https://github.com/MobSF/Mobile-Security-Framework-MobSF/archive/refs/tags/v4.3.0.zip',
100+
# 'url': 'https://github.com/MobSF/Mobile-Security-Framework-MobSF/archive/refs/tags/v4.3.0.zip',
101+
'version': VERSION_MOBSF,
102+
'url': f'https://github.com/MobSF/Mobile-Security-Framework-MobSF/archive/refs/tags/v{VERSION_MOBSF}.zip',
75103
'info': 'Mobile Security Framework (MobSF)',
76104
'bin': 'cd {}; python -m venv venv; . ./venv/bin/activate; . ./run.sh'.format(os.path.join(conf.load_config('install-dir'), 'MobSF')),
77105
'bin_info': 'Open MobSF in browser: http://127.0.0.1:8000 (Press CTRL+C to quit)',
78106
'dir': 'MobSF',
79107
'install': 'http',
80-
'post': 'mv Mobile-Security-Framework-MobSF-4.3.0 MobSF; cd MobSF; python -m venv venv; . ./venv/bin/activate; pip install poetry; . ./setup.sh',
108+
'post': f'mv Mobile-Security-Framework-MobSF-{VERSION_MOBSF} MobSF; cd MobSF; python -m venv venv; . ./venv/bin/activate; pip install poetry; . ./setup.sh',
81109
},
82110

83111
# RMS installation old version
@@ -95,7 +123,7 @@
95123
'RMS': {
96124
# check 'https://github.com/m0bilesecurity/RMS-Runtime-Mobile-Security',
97125
#
98-
# HOW TO SELECT A RIGHT NODEJS VERSION ??
126+
# HOW TO SELECT A RIGHT Node.js VERSION ??
99127
# https://github.com/ChiChou/Grapefruit/wiki/How-do-I-decide-which-version-of-nodejs-to-use%3F
100128
#
101129
# You need to find the right node version. To check which nodejs is supported, you can refer to these two pages:
@@ -107,16 +135,18 @@
107135
# we need to install v22.12.0
108136
# put the correct version in post command "... nodeenv --python-virtualenv --node 22.12.0 ..."
109137
#
138+
'version': VERSION_RMS,
110139
'info': 'Runtime Mobile Security (RMS)',
111140
'dir': 'RMS',
112141
'bin': 'cd {}; . ./venv/bin/activate; rms'.format(os.path.join(conf.load_config('install-dir'), 'RMS')),
113142
'bin_info': 'Running on http://127.0.0.1:5491/ (Press CTRL+C to quit)',
114143
'install': 'local',
115-
# install nodejs locally within the python virtual environment
144+
# install Node.js locally within the python virtual environment
116145
'post': 'cd RMS; python -m venv venv; . ./venv/bin/activate; pip install nodeenv; nodeenv --python-virtualenv --node 22.12.0; npm install -g rms-runtime-mobile-security',
117146
},
118147
'objection': {
119148
# check: 'https://github.com/sensepost/objection',
149+
'version': VERSION_OBJECTION,
120150
'info': 'Runtime Mobile Exploration Toolkit',
121151
'dir': 'objection',
122152
# 'bin_info': 'Please run "frida-ps -U" to find an app and start objection with the following command:\nobjection --gadget "<APP-NAME>" explore',
@@ -126,18 +156,21 @@
126156
'post': 'cd objection; python -m venv venv; . ./venv/bin/activate; pip install --upgrade setuptools; pip install -U objection'
127157
},
128158
'spotbugs': {
129-
# check: 'https://github.com/spotbugs/spotbugs/releases',
130-
'url': 'https://github.com/spotbugs/spotbugs/releases/download/4.9.3/spotbugs-4.9.3.zip',
159+
#'url': 'https://github.com/spotbugs/spotbugs/releases/download/4.9.3/spotbugs-4.9.3.zip',
160+
'version': VERSION_SPOTBUGS,
161+
'url': f'https://github.com/spotbugs/spotbugs/releases/download/{VERSION_SPOTBUGS}/spotbugs-{VERSION_SPOTBUGS}.zip',
131162
'info': 'Static code analysis for vulnerabilities and bugs',
132163
'dir': 'spotbugs',
133164
'bin': f'cd {os.path.join(conf.load_config('install-dir'), 'spotbugs')}; ./bin/spotbugs',
134165
'install': 'http',
135-
'post': 'mv spotbugs-4.9.3 spotbugs',
166+
'post': f'mv spotbugs-{VERSION_SPOTBUGS} spotbugs',
136167
'bin_global': {'spotbugs': 'bin/spotbugs'}
137168
},
138169
'jadx': {
139170
# check updates: 'https://github.com/skylot/jadx/releases'
140-
'url': 'https://github.com/skylot/jadx/releases/download/v1.5.1/jadx-1.5.1.zip',
171+
# 'url': 'https://github.com/skylot/jadx/releases/download/v1.5.1/jadx-1.5.1.zip',
172+
'version': VERSION_JADX,
173+
'url': f'https://github.com/skylot/jadx/releases/download/v{VERSION_JADX}/jadx-{VERSION_JADX}.zip',
141174
'info': 'Dex to Java decompiler',
142175
'bin': os.path.join(conf.load_config('install-dir'), 'jadx/bin/jadx-gui'),
143176
'dir': 'jadx',
@@ -148,44 +181,54 @@
148181
},
149182
'jd-gui': {
150183
# check updates: 'https://github.com/java-decompiler/jd-gui/releases'
151-
'url': 'https://github.com/java-decompiler/jd-gui/releases/download/v1.6.6/jd-gui-1.6.6.jar',
184+
#'url': 'https://github.com/java-decompiler/jd-gui/releases/download/v1.6.6/jd-gui-1.6.6.jar',
185+
'version': VERSION_JD_GUI,
186+
'url': f'https://github.com/java-decompiler/jd-gui/releases/download/v{VERSION_JD_GUI}/jd-gui-{VERSION_JD_GUI}.jar',
152187
'info': 'Java Decompiler, dex2jar required',
153188
'bin': os.path.join(conf.load_config('install-dir'), 'jd-gui/jd-gui.jar'),
154189
'dir': 'jd-gui',
155190
'install': 'http',
156191
},
157192
'luyten': {
158193
# check updates https://github.com/deathmarine/Luyten/releases
159-
'url': 'https://github.com/deathmarine/Luyten/releases/download/v0.5.4_Rebuilt_with_Latest_depenencies/luyten-0.5.4.jar',
194+
# 'url': f'https://github.com/deathmarine/Luyten/releases/download/v0.5.4_Rebuilt_with_Latest_depenencies/luyten-0.5.4.jar',
195+
'version': VERSION_LUYTEN,
196+
'url': f'https://github.com/deathmarine/Luyten/releases/download/v{VERSION_LUYTEN}_Rebuilt_with_Latest_depenencies/luyten-{VERSION_LUYTEN}.jar',
160197
'info': 'Java Decompiler Gui for Procyon',
161198
'bin': os.path.join(conf.load_config('install-dir'), 'luyten/luyten.jar'),
162199
'dir': 'luyten',
163200
'install': 'http'
164201
},
165202
'sqlitestudio': {
166203
# check updates : https://github.com/pawelsalawa/sqlitestudio/releases
167-
'url': 'https://github.com/pawelsalawa/sqlitestudio/releases/download/3.4.17/sqlitestudio-3.4.17-linux-x64.tar.xz',
204+
#VERSION_SQLITESTUDIO
205+
'version': VERSION_SQLITESTUDIO,
206+
# 'url': 'https://github.com/pawelsalawa/sqlitestudio/releases/download/3.4.17/sqlitestudio-3.4.17-linux-x64.tar.xz',
207+
'url': f'https://github.com/pawelsalawa/sqlitestudio/releases/download/{VERSION_SQLITESTUDIO}/sqlitestudio-{VERSION_SQLITESTUDIO}-linux-x64.tar.xz',
168208
'info': 'Multi-platform SQLite database manager',
169209
'dir': 'SQLiteStudio',
170210
'bin': os.path.join(conf.load_config('install-dir'), 'SQLiteStudio/sqlitestudio'),
171211
'install': 'http',
172212
'bin_global': {'sqlitestudio': 'sqlitestudio', 'sqlitestudiocli': 'sqlitestudiocli'}
173213
},
174214
'pidcat': {
215+
'version': VERSION_PIDCAT,
175216
'url': 'https://github.com/JakeWharton/pidcat',
176217
'info': 'excellent logcat color script',
177218
'bin': os.path.join(conf.load_config('install-dir') + 'pidcat/pidcat.py'),
178219
'dir': 'pidcat',
179220
'install': 'git'
180221
},
181222
'pidcat-ex': {
223+
'version': VERSION_PIDCAT_EX,
182224
'url': 'https://github.com/healthluck/pidcat-ex.git',
183225
'info': 'PID Cat (extended version)',
184226
'bin': os.path.join(conf.load_config('install-dir') + 'pidcat-ex/pidcat-ex.py'),
185227
'dir': 'pidcat-ex',
186228
'install': 'git'
187229
},
188230
'adus': {
231+
'version': VERSION_ADUS,
189232
'url': 'https://github.com/ByteSnipers/adus',
190233
'info': 'Bash script to dump, build and sign apk',
191234
'bin': os.path.join(conf.load_config('install-dir') + 'adus/adus.sh'),
@@ -195,6 +238,7 @@
195238
'fridump': {
196239
# check https://github.com/rootbsd/fridump3 (updated version)
197240
# https://github.com/Nightbringer21/fridump (obsolete version)
241+
'version': VERSION_FRIDUMP,
198242
'url': 'https://github.com/rootbsd/fridump3',
199243
'info': 'Memory dumping tool using frida',
200244
'bin': f'cd {os.path.join(conf.load_config('install-dir'),'fridump')}; . ./venv/bin/activate; python fridump3.py',
@@ -203,6 +247,7 @@
203247
'post': 'cd fridump; python -m venv venv; . ./venv/bin/activate; pip install --upgrade frida-tools; chmod +x fridump3.py'
204248
},
205249
'adb': {
250+
'version' : VERSION_ADB,
206251
'url': 'https://dl.google.com/android/repository/platform-tools-latest-linux.zip',
207252
'info': 'Android Debug Bridge (adb)',
208253
'dir': 'platform-tools',
@@ -215,7 +260,8 @@
215260
# URL examples
216261
# version + RC: https://dl.google.com/android/repository/build-tools_r34-rc3-linux.zip'
217262
# version: https://dl.google.com/android/repository/build-tools_r34-linux.zip # android 14
218-
'url': 'https://dl.google.com/android/repository/build-tools_r34-rc3-linux.zip', # android 14
263+
'version' : VERSION_AAPT,
264+
'url': f'https://dl.google.com/android/repository/build-tools_{VERSION_AAPT}-linux.zip', # android 14
219265
'info': 'Android Asset Packaging Tool',
220266
'bin': os.path.join(conf.load_config('install-dir'), 'build-tools/aapt'),
221267
'dir': 'build-tools',
@@ -227,35 +273,32 @@
227273
},
228274
'abe': {
229275
# check updates: https://github.com/nelenkov/android-backup-extractor/releases
276+
'version' : VERSION_ABE,
230277
'url': 'https://github.com/nelenkov/android-backup-extractor/releases/download/latest/abe-0059753.jar', # 2024-11
231278
'info': 'Android backup extractor, android:allowBackup="true" required',
232279
'bin': os.path.join(conf.load_config('install-dir'), 'abe/abe.jar'),
233280
'dir': 'abe',
234281
'install': 'http'
235282
},
236-
'signapk': {
237-
'url': 'https://github.com/appium-boneyard/sign',
238-
'info': 'sign an apk with the Android test certificate',
239-
'bin': os.path.join(conf.load_config('install-dir'),'sign/dist/signapk.jar'), # not tested
240-
'dir': 'sign',
241-
'install': 'git'
242-
},
243283
'apktool': {
244284
# check https://bitbucket.org/iBotPeaches/apktool/downloads/ and https://apktool.org/blog
245-
'url': 'https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.11.1.jar',
285+
'version': VERSION_APKTOOL,
286+
# 'url': 'https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.11.1.jar',
287+
'url': f'https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_{VERSION_APKTOOL}.jar',
246288
'info': 'A tool for reverse engineering Android apk files',
247289
'bin': os.path.join(conf.load_config('install-dir'), 'apktool/apktool.jar'),
248290
'dir': 'apktool',
249291
'install': 'http'
250292
},
251293
'dex2jar': {
252294
# check https://github.com/pxb1988/dex2jar/
253-
'url': 'https://github.com/pxb1988/dex2jar/releases/download/v2.4/dex-tools-v2.4.zip',
295+
'version': VERSION_DEX2JAR,
296+
'url': f'https://github.com/pxb1988/dex2jar/releases/download/v2.4/dex-tools-v{VERSION_DEX2JAR}.zip',
254297
'info': 'Convert the Dalvik Executable (.dex) file to jar',
255298
'bin': os.path.join(conf.load_config('install-dir'), 'dex2jar/d2j-dex2jar.sh'),
256299
'dir': 'dex2jar',
257300
'install': 'http',
258-
'post': 'mv dex-tools-v2.4 dex2jar',
301+
'post': f'mv dex-tools-v{VERSION_DEX2JAR} dex2jar',
259302
'bin_global': {
260303
'd2j-apk-sign.sh': 'd2j-apk-sign.sh', 'd2j-asm-verify.sh': 'd2j-asm-verify.sh', 'd2j-baksmali.sh': 'd2j-baksmali.sh',
261304
'd2j-class-version-switch.sh': 'd2j-class-version-switch.sh', 'd2j-decrypt-string.sh': 'd2j-decrypt-string.sh', 'd2j-dex2jar.sh': 'd2j-dex2jar.sh',
@@ -266,6 +309,7 @@
266309
}
267310
},
268311
'janus': {
312+
'version': VERSION_JANUS,
269313
'url': 'https://github.com/ppapadatis/python-janus-vulnerability-scan',
270314
'info': 'scans an APK and an Android device for CVE-2017–13156',
271315
'bin': 'cd {}; . ./venv/bin/activate; python janus.py'.format(os.path.join(conf.load_config('install-dir'), 'python-janus-vulnerability-scan')),
@@ -274,6 +318,7 @@
274318
'post': 'cd python-janus-vulnerability-scan; python -m venv venv; . ./venv/bin/activate; pip install -r requirements.txt'
275319
},
276320
'linux-router': {
321+
'version': VERSION_LINUX_ROUTER,
277322
'url': 'https://github.com/garywill/linux-router',
278323
'info': 'Set Linux as router in one command. Able to provide Internet, or create WiFi hotspot',
279324
'bin': 'cd {}; sudo ./lnxrouter'.format(os.path.join(conf.load_config('install-dir'), 'linux-router')),
@@ -284,6 +329,7 @@
284329
'kitty': {
285330
# check https://sw.kovidgoyal.net/kitty/binary/
286331
# requirement tool to objection execution with interactive cli
332+
'version': VERSION_KITTY,
287333
'info': 'The fast, feature-rich, GPU based terminal emulator',
288334
'bin': os.path.join(conf.load_config('install-dir'), 'kitty/kitty.app/bin/kitty'),
289335
'dir': 'kitty',
@@ -292,7 +338,9 @@
292338
},
293339
'scrcpy': {
294340
# check version and replace file: https://github.com/Genymobile/scrcpy/releases
295-
'url': 'https://github.com/Genymobile/scrcpy/releases/download/v3.1/scrcpy-linux-x86_64-v3.1.tar.gz',
341+
'version': VERSION_SCRCPY,
342+
# 'url': 'https://github.com/Genymobile/scrcpy/releases/download/v3.1/scrcpy-linux-x86_64-v3.1.tar.gz',
343+
'url': f'https://github.com/Genymobile/scrcpy/releases/download/v{VERSION_SCRCPY}/scrcpy-linux-x86_64-v{VERSION_SCRCPY}.tar.gz',
296344
'info': 'Application mirrors Android devices (video and audio) connected via USB',
297345
'bin': os.path.join(conf.load_config('install-dir'), 'scrcpy/scrcpy'),
298346
'dir': 'scrcpy',

0 commit comments

Comments
 (0)