From a16b0c12d2a17c5aafeca9a0cdea2e2ef0f3db25 Mon Sep 17 00:00:00 2001 From: Nex Date: Sat, 21 Aug 2021 15:48:52 +0200 Subject: [PATCH] Added shared help messages --- mvt/android/cli.py | 23 ++++++++++------------- mvt/common/help.py | 14 ++++++++++++++ mvt/ios/cli.py | 30 ++++++++++++++---------------- 3 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 mvt/common/help.py diff --git a/mvt/android/cli.py b/mvt/android/cli.py index c5ab781..0296fd7 100644 --- a/mvt/android/cli.py +++ b/mvt/android/cli.py @@ -9,6 +9,7 @@ import os import click from rich.logging import RichHandler +from mvt.common.help import * from mvt.common.indicators import Indicators, IndicatorsFileBadFormat from mvt.common.module import run_module, save_timeline @@ -24,10 +25,6 @@ logging.basicConfig(level="INFO", format=LOG_FORMAT, handlers=[ RichHandler(show_path=False, log_time_format="%X")]) log = logging.getLogger(__name__) -# Help messages of repeating options. -OUTPUT_HELP_MESSAGE = "Specify a path to a folder where you want to store JSON results" -SERIAL_HELP_MESSAGE = "Specify a device serial number or HOST:PORT connection string" - #============================================================================== # Main #============================================================================== @@ -40,7 +37,7 @@ def cli(): # Download APKs #============================================================================== @cli.command("download-apks", help="Download all or non-safelisted installed APKs installed on the device") -@click.option("--serial", "-s", type=str, help=SERIAL_HELP_MESSAGE) +@click.option("--serial", "-s", type=str, help=HELP_MSG_SERIAL) @click.option("--all-apks", "-a", is_flag=True, help="Extract all packages installed on the phone, even those marked as safe") @click.option("--virustotal", "-v", is_flag=True, help="Check packages on VirusTotal") @@ -92,13 +89,13 @@ def download_apks(ctx, all_apks, virustotal, koodous, all_checks, output, from_f # Checks through ADB #============================================================================== @cli.command("check-adb", help="Check an Android device over adb") -@click.option("--serial", "-s", type=str, help=SERIAL_HELP_MESSAGE) +@click.option("--serial", "-s", type=str, help=HELP_MSG_SERIAL) @click.option("--iocs", "-i", type=click.Path(exists=True), multiple=True, - default=[], help="Path to indicators file (can be invoked multiple times)") + default=[], help=HELP_MSG_IOC) @click.option("--output", "-o", type=click.Path(exists=False), - help="Specify a path to a folder where you want to store JSON results") -@click.option("--list-modules", "-l", is_flag=True, help="Print list of available modules and exit") -@click.option("--module", "-m", help="Name of a single module you would like to run instead of all") + help=HELP_MSG_OUTPUT) +@click.option("--list-modules", "-l", is_flag=True, help=HELP_MSG_LIST_MODULES) +@click.option("--module", "-m", help=HELP_MSG_MODULE) @click.pass_context def check_adb(ctx, iocs, output, list_modules, module, serial): if list_modules: @@ -155,10 +152,10 @@ def check_adb(ctx, iocs, output, list_modules, module, serial): # Check ADB backup #============================================================================== @cli.command("check-backup", help="Check an Android Backup") -@click.option("--serial", "-s", type=str, help=SERIAL_HELP_MESSAGE) +@click.option("--serial", "-s", type=str, help=HELP_MSG_SERIAL) @click.option("--iocs", "-i", type=click.Path(exists=True), multiple=True, - default=[], help="Path to indicators file (can be invoked multiple times)") -@click.option("--output", "-o", type=click.Path(exists=False), help=OUTPUT_HELP_MESSAGE) + default=[], help=HELP_MSG_IOC) +@click.option("--output", "-o", type=click.Path(exists=False), help=HELP_MSG_OUTPUT) @click.argument("BACKUP_PATH", type=click.Path(exists=True)) @click.pass_context def check_backup(ctx, iocs, output, backup_path, serial): diff --git a/mvt/common/help.py b/mvt/common/help.py new file mode 100644 index 0000000..d42e930 --- /dev/null +++ b/mvt/common/help.py @@ -0,0 +1,14 @@ +# Mobile Verification Toolkit (MVT) +# Copyright (c) 2021 The MVT Project Authors. +# Use of this software is governed by the MVT License 1.1 that can be found at +# https://license.mvt.re/1.1/ + +# Help messages of repeating options. +HELP_MSG_OUTPUT = "Specify a path to a folder where you want to store JSON results" +HELP_MSG_IOC = "Path to indicators file (can be invoked multiple time)" +HELP_MSG_FAST = "Avoid running time/resource consuming features" +HELP_MSG_LIST_MODULES = "Print list of available modules and exit" +HELP_MSG_MODULE = "Name of a single module you would like to run instead of all" + +# Android-specific. +HELP_MSG_SERIAL = "Specify a device serial number or HOST:PORT connection string" diff --git a/mvt/ios/cli.py b/mvt/ios/cli.py index b5e4a8d..29437f8 100644 --- a/mvt/ios/cli.py +++ b/mvt/ios/cli.py @@ -10,6 +10,7 @@ import click from rich.logging import RichHandler from rich.prompt import Prompt +from mvt.common.help import * from mvt.common.indicators import Indicators, IndicatorsFileBadFormat from mvt.common.module import run_module, save_timeline from mvt.common.options import MutuallyExclusiveOption @@ -25,9 +26,6 @@ logging.basicConfig(level="INFO", format=LOG_FORMAT, handlers=[ RichHandler(show_path=False, log_time_format="%X")]) log = logging.getLogger(__name__) -# Help messages of repeating options. -OUTPUT_HELP_MESSAGE = "Specify a path to a folder where you want to store JSON results" - # Set this environment variable to a password if needed. PASSWD_ENV = "MVT_IOS_BACKUP_PASSWORD" @@ -122,11 +120,11 @@ def extract_key(password, backup_path, key_file): #============================================================================== @cli.command("check-backup", help="Extract artifacts from an iTunes backup") @click.option("--iocs", "-i", type=click.Path(exists=True), multiple=True, - default=[], help="Path to indicators file (can be invoked multiple time)") -@click.option("--output", "-o", type=click.Path(exists=False), help=OUTPUT_HELP_MESSAGE) -@click.option("--fast", "-f", is_flag=True, help="Avoid running time/resource consuming features") -@click.option("--list-modules", "-l", is_flag=True, help="Print list of available modules and exit") -@click.option("--module", "-m", help="Name of a single module you would like to run instead of all") + default=[], help=HELP_MSG_IOC) +@click.option("--output", "-o", type=click.Path(exists=False), help=HELP_MSG_OUTPUT) +@click.option("--fast", "-f", is_flag=True, help=HELP_MSG_FAST) +@click.option("--list-modules", "-l", is_flag=True, help=HELP_MSG_LIST_MODULES) +@click.option("--module", "-m", help=HELP_MSG_MODULE) @click.argument("BACKUP_PATH", type=click.Path(exists=True)) @click.pass_context def check_backup(ctx, iocs, output, fast, backup_path, list_modules, module): @@ -185,11 +183,11 @@ def check_backup(ctx, iocs, output, fast, backup_path, list_modules, module): #============================================================================== @cli.command("check-fs", help="Extract artifacts from a full filesystem dump") @click.option("--iocs", "-i", type=click.Path(exists=True), multiple=True, - default=[], help="Path to indicators file (can be invoked multiple time)") -@click.option("--output", "-o", type=click.Path(exists=False), help=OUTPUT_HELP_MESSAGE) -@click.option("--fast", "-f", is_flag=True, help="Avoid running time/resource consuming features") -@click.option("--list-modules", "-l", is_flag=True, help="Print list of available modules and exit") -@click.option("--module", "-m", help="Name of a single module you would like to run instead of all") + default=[], help=HELP_MSG_IOC) +@click.option("--output", "-o", type=click.Path(exists=False), help=HELP_MSG_OUTPUT) +@click.option("--fast", "-f", is_flag=True, help=HELP_MSG_FAST) +@click.option("--list-modules", "-l", is_flag=True, help=HELP_MSG_LIST_MODULES) +@click.option("--module", "-m", help=HELP_MSG_MODULE) @click.argument("DUMP_PATH", type=click.Path(exists=True)) @click.pass_context def check_fs(ctx, iocs, output, fast, dump_path, list_modules, module): @@ -249,9 +247,9 @@ def check_fs(ctx, iocs, output, fast, dump_path, list_modules, module): #============================================================================== @cli.command("check-iocs", help="Compare stored JSON results to provided indicators") @click.option("--iocs", "-i", type=click.Path(exists=True), multiple=True, - default=[], required=True, help="Path to indicators file (can be invoked multiple time)") -@click.option("--list-modules", "-l", is_flag=True, help="Print list of available modules and exit") -@click.option("--module", "-m", help="Name of a single module you would like to run instead of all") + default=[], required=True, help=HELP_MSG_IOC) +@click.option("--list-modules", "-l", is_flag=True, help=HELP_MSG_LIST_MODULES) +@click.option("--module", "-m", help=HELP_MSG_MODULE) @click.argument("FOLDER", type=click.Path(exists=True)) @click.pass_context def check_iocs(ctx, iocs, list_modules, module, folder):