Skip to content

Commit 05dc2f2

Browse files
authored
Add --skip option (#45)
1 parent d25d9de commit 05dc2f2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/cmd/root.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import (
1919
var runAnyExploit bool
2020
var exploitName string
2121
var promptForPassword bool
22+
var skipExploits []string
2223

2324
func init() {
2425
rootCmd.PersistentFlags().BoolVarP(&runAnyExploit, "any", "a", runAnyExploit, "Attempt to exploit a vulnerability as soon as it is detected. Provides a shell where possible.")
2526
rootCmd.PersistentFlags().BoolVarP(&promptForPassword, "with-password", "p", promptForPassword, "Prompt for the user password, if you know it. Can provide more GTFOBins possibilities via sudo.")
2627
rootCmd.PersistentFlags().StringVarP(&exploitName, "exploit", "e", exploitName, "Run the specified exploit, if the system is found to be vulnerable. Provides a shell where possible.")
28+
rootCmd.PersistentFlags().StringSliceVarP(&skipExploits, "skip", "s", skipExploits, "Exploit(s) to skip - specify multiple times to skip multiple exploits.")
2729
}
2830

2931
var rootCmd = &cobra.Command{
@@ -59,6 +61,9 @@ var rootCmd = &cobra.Command{
5961
var found bool
6062
var vulnFound bool
6163
for _, exploit := range allExploits {
64+
if shouldSkip(exploit.Name) {
65+
continue
66+
}
6267
if exploitName == "" || exploitName == exploit.Name {
6368
found = true
6469
exploitLogger := baseLog.WithTitle(exploit.Name)
@@ -100,6 +105,15 @@ var rootCmd = &cobra.Command{
100105
},
101106
}
102107

108+
func shouldSkip(id string) bool {
109+
for _, skip := range skipExploits {
110+
if skip == id {
111+
return true
112+
}
113+
}
114+
return false
115+
}
116+
103117
func Execute() {
104118
if err := rootCmd.Execute(); err != nil {
105119
_, _ = fmt.Fprintln(os.Stderr, err)

0 commit comments

Comments
 (0)