@cli.command('check-adb', help='Check an Android device over adb')
@click.option('--serial', '-s', type=str, help=HELP_MSG_SERIAL)
@click.option('--iocs', '-i', type=click.Path(exists=True), multiple=True, 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.pass_context
def check_adb(ctx, iocs, output, fast, list_modules, module, serial):
    if list_modules:
        log.info('Following is the list of available check-adb modules:')
        for adb_module in ADB_MODULES:
            log.info(' - %s', adb_module.__name__)
        return
    log.info('Checking Android through adb bridge')
    if (output and (not os.path.exists(output))):
        try:
            os.makedirs(output)
        except Exception as e:
            log.critical('Unable to create output folder %s: %s', output, e)
            ctx.exit(1)
    indicators = Indicators(log=log)
    indicators.load_indicators_files(iocs)
    timeline = []
    timeline_detected = []
    for adb_module in ADB_MODULES:
        if (module and (adb_module.__name__ != module)):
            continue
        m = adb_module(output_folder=output, fast_mode=fast, log=logging.getLogger(adb_module.__module__))
        if indicators.total_ioc_count:
            m.indicators = indicators
            m.indicators.log = m.log
        if serial:
            m.serial = serial
        run_module(m)
        timeline.extend(m.timeline)
        timeline_detected.extend(m.timeline_detected)
    if output:
        if (len(timeline) > 0):
            save_timeline(timeline, os.path.join(output, 'timeline.csv'))
        if (len(timeline_detected) > 0):
            save_timeline(timeline_detected, os.path.join(output, 'timeline_detected.csv'))
@cli.command('check-adb', help='Check an Android device over adb')
@click.option('--serial', '-s', type=str, help=HELP_MSG_SERIAL)
@click.option('--iocs', '-i', type=click.Path(exists=True), multiple=True, 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.pass_context
def check_adb(ctx, iocs, output, fast, list_modules, module, serial):
    if list_modules:
        log.info('Following is the list of available check-adb modules:')
        for adb_module in ADB_MODULES:
            log.info(' - %s', adb_module.__name__)
        return
    log.info('Checking Android through adb bridge')
    if (output and (not os.path.exists(output))):
        try:
            os.makedirs(output)
        except Exception as e:
            log.critical('Unable to create output folder %s: %s', output, e)
            ctx.exit(1)
    indicators = Indicators(log=log)
    indicators.load_indicators_files(iocs)
    timeline = []
    timeline_detected = []
    for adb_module in ADB_MODULES:
        if (module and (adb_module.__name__ != module)):
            continue
        m = adb_module(output_folder=output, fast_mode=fast, log=logging.getLogger(adb_module.__module__))
        if indicators.total_ioc_count:
            m.indicators = indicators
            m.indicators.log = m.log
        if serial:
            m.serial = serial
        run_module(m)
        timeline.extend(m.timeline)
        timeline_detected.extend(m.timeline_detected)
    if output:
        if (len(timeline) > 0):
            save_timeline(timeline, os.path.join(output, 'timeline.csv'))
        if (len(timeline_detected) > 0):
            save_timeline(timeline_detected, os.path.join(output, 'timeline_detected.csv'))