Exemple #1
0
 def test_blackbox_dos_header_malconv(self):
     black_box_attack = CBlackBoxHeaderEvasionProblem(CEnd2EndWrapperPhi(
         self.end2end_classifier),
                                                      optimize_all_dos=True,
                                                      iterations=5,
                                                      population_size=10)
     engine = CGeneticAlgorithm(black_box_attack)
     y_pred, _, _, _ = engine.run(self.X, self.Y)
     self.assert_evasion_result(y_pred)
Exemple #2
0
def create_byte_based_black_box_attack(cli_args):
    population_size = int(cli_args.population_size)
    inject = int(cli_args.inject)
    iterations = int(cli_args.query_budget) // population_size + 1
    model = cli_args.model
    threshold = float(cli_args.threshold)
    if cli_args.type == SHIFT:
        problem = CBlackBoxFormatExploitEvasionProblem(
            model,
            preferable_extension_amount=inject,
            pe_header_extension=0,
            iterations=iterations,
            population_size=population_size)
    elif cli_args.type == EXTEND:
        problem = CBlackBoxFormatExploitEvasionProblem(
            model,
            preferable_extension_amount=0,
            pe_header_extension=inject,
            iterations=iterations,
            population_size=population_size)
    elif cli_args.type == PARTIAL_DOS:
        problem = CBlackBoxHeaderEvasionProblem(
            model,
            optimize_all_dos=False,
            iterations=iterations,
            population_size=population_size)
    elif cli_args.type == FULL_DOS:
        problem = CBlackBoxHeaderEvasionProblem(
            model,
            optimize_all_dos=True,
            iterations=iterations,
            population_size=population_size)
    elif cli_args.type == PADDING:
        problem = CBlackBoxPaddingEvasionProblem(
            model,
            how_many_padding_bytes=inject,
            iterations=iterations,
            population_size=population_size)
    else:
        raise KeyError(f"{cli_args.type} not recognized as attack")
    return problem