diff --git a/mvt/android/cli.py b/mvt/android/cli.py index f8c37a8..38832e6 100644 --- a/mvt/android/cli.py +++ b/mvt/android/cli.py @@ -49,7 +49,7 @@ def cli(): help="Specify a path to a folder where you want to store JSON results") @click.option("--from-file", "-f", type=click.Path(exists=True), help="Instead of acquiring from phone, load an existing packages.json file for lookups (mainly for debug purposes)") -@click.option("--serial", "-s", type=str, help="Use the Android device with a given serial") +@click.option("--serial", "-s", type=str, help="Use the Android device with a given serial number") def download_apks(all_apks, virustotal, koodous, all_checks, output, from_file, serial): try: if from_file: diff --git a/mvt/android/modules/adb/base.py b/mvt/android/modules/adb/base.py index e39fcf9..ea0abe5 100644 --- a/mvt/android/modules/adb/base.py +++ b/mvt/android/modules/adb/base.py @@ -8,7 +8,7 @@ import sys import time import logging import tempfile -from adb_shell.adb_device import AdbDeviceUsb +from adb_shell.adb_device import AdbDeviceUsb, AdbDeviceTcp from adb_shell.auth.keygen import keygen, write_public_keyfile from adb_shell.auth.sign_pythonrsa import PythonRSASigner from adb_shell.exceptions import DeviceAuthError, AdbCommandFailureException @@ -58,7 +58,15 @@ class AndroidExtraction(MVTModule): signer = PythonRSASigner("", priv_key) - self.device = AdbDeviceUsb(serial=self.serial) + if self.serial is None or ":" not in self.serial: + self.device = AdbDeviceUsb(serial=self.serial) + else: + addr = self.serial.split(":") + + if len(addr) < 2: + raise ValueError("TCP serial number must follow the format: `address:port`") + + self.device = AdbDeviceTcp(addr[0], int(addr[1]), default_transport_timeout_s=9.) while True: try: