-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend/frontend] First iteration on custom payloads (#743)
- Loading branch information
1 parent
65d1ff9
commit 314d236
Showing
68 changed files
with
1,240 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
openbas-api/src/main/java/io/openbas/migration/V3_12__Payloads.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.openbas.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Statement; | ||
|
||
@Component | ||
public class V3_12__Payloads extends BaseJavaMigration { | ||
|
||
@Override | ||
public void migrate(Context context) throws Exception { | ||
Connection connection = context.getConnection(); | ||
Statement select = connection.createStatement(); | ||
// Purge | ||
select.execute("TRUNCATE payloads CASCADE;"); | ||
select.execute("ALTER TABLE payloads DROP column payload_content;"); | ||
select.execute("ALTER TABLE payloads ADD column payload_platforms text[];"); | ||
select.execute("ALTER TABLE payloads ADD column command_executor varchar(255);"); | ||
select.execute("ALTER TABLE payloads ADD column command_content text;"); | ||
select.execute("ALTER TABLE payloads ADD column executable_file varchar(255) constraint executable_file_fk references documents on delete cascade;"); | ||
select.execute("ALTER TABLE payloads ADD column file_drop_file varchar(255) constraint file_drop_file_fk references documents on delete cascade;"); | ||
select.execute("ALTER TABLE payloads ADD column dns_resolution_hostname text;"); | ||
select.execute("ALTER TABLE payloads ADD column network_traffic_ip text;"); | ||
select.execute("ALTER TABLE payloads ADD column payload_cleanup_executor varchar(255);"); | ||
select.execute("ALTER TABLE payloads ADD column payload_cleanup_command text;"); | ||
select.execute("ALTER TABLE payloads ADD column payload_arguments json;"); | ||
select.execute("ALTER TABLE payloads ADD column payload_prerequisites json;"); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
openbas-api/src/main/java/io/openbas/migration/V3_13__Payloads_Attack_Patterns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.openbas.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Statement; | ||
|
||
@Component | ||
public class V3_13__Payloads_Attack_Patterns extends BaseJavaMigration { | ||
|
||
@Override | ||
public void migrate(Context context) throws Exception { | ||
Connection connection = context.getConnection(); | ||
Statement select = connection.createStatement(); | ||
// Create relations between contracts and attack_patterns | ||
select.execute(""" | ||
CREATE TABLE payloads_attack_patterns ( | ||
attack_pattern_id varchar(255) not null | ||
constraint attack_pattern_id_fk | ||
references attack_patterns | ||
on delete cascade, | ||
payload_id varchar(255) not null | ||
constraint payloads_id_fk | ||
references payloads | ||
on delete cascade, | ||
primary key (attack_pattern_id, payload_id) | ||
); | ||
CREATE INDEX idx_payloads_attack_patterns_pattern on payloads_attack_patterns (attack_pattern_id); | ||
CREATE INDEX idx_payloads_attack_patterns_contract on payloads_attack_patterns (payload_id); | ||
"""); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
openbas-api/src/main/java/io/openbas/migration/V3_14__Injectors_payload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.openbas.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.Statement; | ||
|
||
@Component | ||
public class V3_14__Injectors_payload extends BaseJavaMigration { | ||
|
||
@Override | ||
public void migrate(Context context) throws Exception { | ||
Statement select = context.getConnection().createStatement(); | ||
select.execute("ALTER TABLE injectors ADD injector_payloads bool default false;"); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
openbas-api/src/main/java/io/openbas/migration/V3_15__Injector_contracts_Payloads.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.openbas.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Statement; | ||
|
||
@Component | ||
public class V3_15__Injector_contracts_Payloads extends BaseJavaMigration { | ||
|
||
@Override | ||
public void migrate(Context context) throws Exception { | ||
Connection connection = context.getConnection(); | ||
Statement select = connection.createStatement(); | ||
// Purge | ||
select.execute("ALTER TABLE injectors_contracts ADD column injector_contract_payload varchar(255) constraint injector_contract_payload_fk references payloads on delete cascade;"); | ||
select.execute("CREATE UNIQUE INDEX injector_contract_payload_unique on injectors_contracts (injector_contract_payload, injector_id);"); | ||
} | ||
} |
Oops, something went wrong.