diff --git a/cmd/config.go b/cmd/config.go index 3244a84..c0ff68a 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -43,6 +43,13 @@ func runConfig(cmd *cobra.Command, args []string) error { } switch action { + case "check": + err := generalCheck() + if err != nil { + fmt.Printf("‼️ There is might be something wrong with your setup: %v\n", color.HiRedString("%v", err)) + return nil + } + break case "init": if utils.FolderExists(fmt.Sprintf("%vcore", options.Env.RootFolder)) { utils.GoodF("Look like you got properly setup.") @@ -93,6 +100,9 @@ func runConfig(cmd *cobra.Command, args []string) error { break default: utils.ErrorF("Unknown action: %v", color.HiRedString(action)) + if options.FullHelp { + fmt.Println(cmd.UsageString()) + } fmt.Println(ConfigUsage()) } diff --git a/cmd/exec.go b/cmd/exec.go index 6b8c1d5..17fd577 100644 --- a/cmd/exec.go +++ b/cmd/exec.go @@ -19,6 +19,12 @@ func init() { execCmd.Flags().String("script", "", "Scripts to run (Multiple -s flags are accepted)") execCmd.Flags().StringP("scriptFile", "S", "", "File contain list of scripts") RootCmd.AddCommand(execCmd) + execCmd.PreRun = func(cmd *cobra.Command, args []string) { + if options.FullHelp { + cmd.Help() + os.Exit(0) + } + } } func runExec(cmd *cobra.Command, _ []string) error { diff --git a/cmd/health.go b/cmd/health.go index 5fc0c84..cbac21c 100644 --- a/cmd/health.go +++ b/cmd/health.go @@ -5,6 +5,7 @@ import ( "os" "path" "sort" + "strings" "github.com/fatih/color" "github.com/j3ssie/osmedeus/core" @@ -155,22 +156,26 @@ func generalCheck() error { // check core programs var err error - // if _, err = utils.RunCommandWithErr("jaeles -h"); err != nil { - // color.Red("[-] Core program setup incorrectly") - // return fmt.Errorf("error checking core programs: %v", "jaeles") - // } + var errorBinary []string if _, err = utils.RunCommandWithErr("timeout --help"); err != nil { - color.Red("[-] Core program setup incorrectly") - return fmt.Errorf("error checking core programs: %v", "timeout") + errorBinary = append(errorBinary, "timeout") } if _, err = utils.RunCommandWithErr("amass -h"); err != nil { - color.Red("[-] Core program setup incorrectly") - return fmt.Errorf("error checking core programs: %v", "amass") + errorBinary = append(errorBinary, "amass") + } + if _, err = utils.RunCommandWithErr(fmt.Sprintf("%s -h", path.Join(options.Env.BinariesFolder, "subfinder"))); err != nil { + errorBinary = append(errorBinary, "subfinder") } - _, err = utils.RunCommandWithErr(fmt.Sprintf("%s -h", path.Join(options.Env.BinariesFolder, "httprobe"))) - if err != nil { + if _, err = utils.RunCommandWithErr(fmt.Sprintf("%s -h", path.Join(options.Env.BinariesFolder, "httprobe"))); err != nil { + errorBinary = append(errorBinary, "httprobe") + } + if _, err = utils.RunCommandWithErr(fmt.Sprintf("%s -h", path.Join(options.Env.BinariesFolder, "nuclei"))); err != nil { + errorBinary = append(errorBinary, "nuclei") + } + + if len(errorBinary) > 0 { color.Red("[-] Core program setup incorrectly") - return fmt.Errorf("error checking core programs: %v", fmt.Sprintf("%s -h", path.Join(options.Env.BinariesFolder, "httprobe"))) + return fmt.Errorf("error checking core programs: %v", color.HiCyanString(strings.Join(errorBinary, ", "))) } fmt.Printf("[+] Health Check Core Programs: %s\n", color.GreenString("✔")) @@ -237,7 +242,7 @@ func listFlows() error { table.SetHeader([]string{"Flow Name", "Description"}) table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true}) table.SetColWidth(120) - table.AppendBulk(content) // Add Bulk Data + table.AppendBulk(content) table.Render() h := color.HiCyanString("\nUsage:\n") @@ -273,7 +278,7 @@ func listDefaultModules() error { table.SetHeader([]string{"Module Name", "Description"}) table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true}) table.SetColWidth(120) - table.AppendBulk(content) // Add Bulk Data + table.AppendBulk(content) table.Render() h := color.HiCyanString("\nModule Usage:\n") diff --git a/cmd/usage.go b/cmd/usage.go index e7a325e..bfd425e 100644 --- a/cmd/usage.go +++ b/cmd/usage.go @@ -264,7 +264,6 @@ func ConfigHelp(cmd *cobra.Command, _ []string) { fmt.Println(cmd.UsageString()) } h := ConfigUsage() - fmt.Println(h) printDocs(cmd) } diff --git a/core/token.go b/core/token.go index 23213c9..456671b 100644 --- a/core/token.go +++ b/core/token.go @@ -113,7 +113,11 @@ func SetupOSEnv(options *libs.Options) { continue } - utils.DebugF("Setting environment variable: %v -- %v", name, value) + redactedValue := "*****" + if len(value) > 5 { + redactedValue = value[:2] + "***" + value[len(value)-2:] + } + utils.DebugF("Setting environment variable: %v -- %v", name, redactedValue) err := os.Setenv(name, value) if err != nil {