Skip to content

Commit

Permalink
Add --skip option (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamg authored Jun 22, 2021
1 parent d25d9de commit 05dc2f2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import (
var runAnyExploit bool
var exploitName string
var promptForPassword bool
var skipExploits []string

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

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -59,6 +61,9 @@ var rootCmd = &cobra.Command{
var found bool
var vulnFound bool
for _, exploit := range allExploits {
if shouldSkip(exploit.Name) {
continue
}
if exploitName == "" || exploitName == exploit.Name {
found = true
exploitLogger := baseLog.WithTitle(exploit.Name)
Expand Down Expand Up @@ -100,6 +105,15 @@ var rootCmd = &cobra.Command{
},
}

func shouldSkip(id string) bool {
for _, skip := range skipExploits {
if skip == id {
return true
}
}
return false
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
Expand Down

0 comments on commit 05dc2f2

Please sign in to comment.