Example #1
0
def scan_targets() -> None:
    """
    Open the target file, Nmap file or get the target to scan
    """
    # Detect if we have a target list or just a single target
    if ArgHandler.get_target_file() is not None:
        # Target list
        targets = ArgHandler.get_target_file().read().splitlines()

        for target in targets:
            if len(target.strip()) == 0:
                continue
            # Comments start with a hashtag
            if len(target.strip()) > 0 and target[0] == "#":
                continue

            scan_target(target)
    elif ArgHandler.get_nmap_file() is not None:
        print(utils.normal_message(), "Loading nmap file")
        raise NotImplementedError("Loading from an Nmap file with -TF is not yet implemented")
        # nmap.parse_nmap_scan(ArgHandler.get_nmap_file())
    else:
        scan_target(ArgHandler.get_target())
Example #2
0
def test_get_target_none():
    ArgHandler.parse_arguments(["-TF", "targets.lan"])
    assert ArgHandler.get_target() is None
Example #3
0
def test_get_target():
    ArgHandler.parse_arguments(["-T", "127.0.0.1"])
    assert ArgHandler.get_target() is not None