-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to revert TTP detonation (closes #12)
- Loading branch information
1 parent
1bed795
commit 7e84bff
Showing
11 changed files
with
234 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"github.com/datadog/stratus-red-team/pkg/stratus" | ||
"github.com/datadog/stratus-red-team/pkg/stratus/runner" | ||
"github.com/spf13/cobra" | ||
"log" | ||
) | ||
|
||
var revertForce bool | ||
|
||
func buildRevertCmd() *cobra.Command { | ||
detonateCmd := &cobra.Command{ | ||
Use: "revert", | ||
Short: "Revert the detonation of an attack technique", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
return errors.New("you must specify at least one attack technique") | ||
} | ||
_, err := resolveTechniques(args) | ||
return err | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
techniques, _ := resolveTechniques(args) | ||
doRevertCmd(techniques, revertForce) | ||
}, | ||
} | ||
detonateCmd.Flags().BoolVarP(&revertForce, "force", "f", false, "Force attempt to reverting even if the technique is not in the DETONATED state") | ||
return detonateCmd | ||
} | ||
|
||
func doRevertCmd(techniques []*stratus.AttackTechnique, force bool) { | ||
for i := range techniques { | ||
stratusRunner := runner.NewRunner(techniques[i], force) | ||
err := stratusRunner.Revert() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
doStatusCmd(techniques) | ||
} |
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