Add Android TCP connection support

This commit is contained in:
Hamza Z
2021-07-21 13:35:46 +02:00
parent ccf0f3f18e
commit 2389d5e52d
2 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -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:
+10 -2
View File
@@ -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: