Example #1
0
def main():
    args = argument_parser(TOOLS).parse_args()
    log.setLevel(LOG_LEVELS[args.loglevel])
    cdb = None
    ret = 0
    processcdb_config = ConfigParser()

    if args.dumpconfigs:
        for tool_name in TOOLS:
            tool = TOOLS[tool_name](tool_name)
            processcdb_config[tool_name] = tool.default_config()
        config_file = args.config.absolute()
        config_file.parent.mkdir(parents=True, exist_ok=True)
        if config_file.exists():
            log.warn(
                f"Configuration file {config_file} already exists, overwriting"
            )
        with config_file.open("w") as output:
            processcdb_config.write(output)
        log.info(f"Configuration file written to {config_file}")
        sys.exit(0)

    processcdb_config.read(args.config)
    try:
        tool = TOOLS[args.tool](args.tool, processcdb_config)
    except KeyError:
        log.error(f"Unknown tool '{args.tool}' - cant initilize")
        return 127

    if args.cdb.is_file():
        cdb = json.loads(args.cdb.read_text())
        if cdb:
            #if args.commit_a is not None:
            #cdb = filterByChangelist(cdb, (args.commit_a, args.commit_b))

            if not args.allow_dupes:
                cdb = remove_dupes(cdb)

            try:
                ret = tool.execute(cdb, args)
                log.info(f"Return value from tool process: {ret}")
            except EnvironmentError as e:
                log.error(f"Cant process: {e}")
            except Exception as e:
                log.error(f"{e}")
                traceback.print_exc()
        else:
            log.error(f"File '{args.cdb}' is empty")
    else:
        log.error(f"File '{args.cdb}' does not exist")
    return ret  # TODO: Add proper return codes
Example #2
0
    parser.add_argument('--debug',
                        action='store_true',
                        help='Optional: show debug messages')
    parser.add_argument(
        '--show-target',
        action='store_true',
        help='Optional: Do NOT anonymize the target IP address '
        '/ network in the fingerprint')
    return parser.parse_args()


if __name__ == '__main__':
    print_logo()
    args = parse_arguments()
    if args.debug:
        LOGGER.setLevel('DEBUG')

    filetype = determine_filetype(args.files)
    # Read the file(s) into a dataframe
    data: pd.DataFrame = pd.concat([
        read_file(f, filetype=filetype, nr_processes=args.n)
        for f in args.files
    ])
    attack = Attack(data,
                    filetype)  # Construct an Attack object with the DDoS data
    target = args.target or infer_target(
        attack)  # Infer the attack target if not passed as an argument
    attack.filter_data_on_target(
        target_network=target)  # Keep only the traffic sent to the target
    attack_vectors = extract_attack_vectors(
        attack)  # Extract the attack vectors from the attack