Projects STRLCPY Osmedeus Commits d2f76f98
🤬
  • Adding default-modules folder for much easier to run the scan with -m flag

  • Loading...
  • j3ssie committed 2 years ago
    d2f76f98
    1 parent fb492f7d
  • ■ ■ ■ ■ ■ ■
    README.md
    skipped 90 lines
    91 91   
    92 92  # Utilities Usage:
    93 93   osmedeus health
     94 + osmedeus health git
     95 + osmedeus health cloud
    94 96   osmedeus version --json
     97 + osmedeus update
     98 + osmedeus update --vuln
     99 + osmedeus update --force --clean
    95 100   osmedeus utils tmux ls
    96 101   osmedeus utils tmux logs -A -l 10
    97 102   osmedeus utils ps
    98 103   osmedeus utils ps --proc 'jaeles'
    99 104   osmedeus utils cron --cmd 'osmdeus scan -t example.com' --sch 60
    100 105   osmedeus utils cron --for --cmd 'osmedeus scan -t example.com'
     106 + osmedeus utils workflow
    101 107  ```
    102 108   
    103 109  Check out [**this page**](https://docs.osmedeus.org/installation/usage/) for full usage and the [**Practical
    skipped 18 lines
  • ■ ■ ■ ■ ■
    cmd/health.go
    skipped 64 lines
    65 65   return nil
    66 66   }
    67 67   
    68  - err = generalCheck()
    69  - if err != nil {
     68 + if err = generalCheck(); err != nil {
    70 69   fmt.Printf("‼️ There is might be something wrong with your setup: %v\n", err)
    71 70   return nil
    72 71   }
    73 72   
    74  - err = listFlows()
    75  - if err != nil {
    76  - fmt.Printf("‼️ There is might be something wrong with your setup: %v\n", err)
     73 + if err = listFlows(); err != nil {
     74 + fmt.Printf("‼️ There is might be something wrong with your workflow setup: %v\n", err)
     75 + return nil
     76 + }
     77 + 
     78 + if err = listDefaultModules(); err != nil {
     79 + fmt.Printf("‼️ There is might be something wrong with your workflow setup: %v\n", err)
    77 80   return nil
    78 81   }
    79 82   fmt.Printf(color.GreenString("\n🦾 It’s all good. Happy Hacking 🦾\n"))
    skipped 118 lines
    198 201   return fmt.Errorf("[-] Error to list workflows: %s", options.Env.WorkFlowsFolder)
    199 202   }
    200 203   fmt.Printf("[+] Health Check Workflows: %s\n", color.GreenString("✔"))
     204 + if options.PremiumPackage {
     205 + fmt.Printf("💎 Making use of the premium workflow\n")
     206 + }
    201 207   
    202 208   var content [][]string
    203 209   for _, flow := range flows {
    skipped 17 lines
    221 227   table.AppendBulk(content) // Add Bulk Data
    222 228   table.Render()
    223 229   
    224  - h := "\nUsage:\n"
    225  - h += color.HiCyanString(" osmedeus scan -f [flowName] -t [target] \n")
     230 + h := color.HiCyanString("\nUsage:\n")
     231 + h += color.HiGreenString(" osmedeus scan -f %v", color.HiMagentaString("[flowName]")) + color.HiGreenString(" -t ") + color.HiMagentaString("[target]") + "\n"
     232 + fmt.Printf(h)
     233 + return nil
     234 +}
     235 + 
     236 +func listDefaultModules() error {
     237 + defaultModule := path.Join(options.Env.WorkFlowsFolder, "default-modules")
     238 + modules := core.DefaultWorkflows(options)
     239 + 
     240 + if len(modules) == 0 {
     241 + return fmt.Errorf("[-] Error to list default modules: %s", defaultModule)
     242 + }
     243 + 
     244 + var content [][]string
     245 + for _, flow := range modules {
     246 + parsedModule, err := core.ParseModules(flow)
     247 + if err != nil {
     248 + utils.ErrorF("Error parsing flow: %v", flow)
     249 + continue
     250 + }
     251 + row := []string{
     252 + parsedModule.Name, parsedModule.Desc,
     253 + }
     254 + content = append(content, row)
     255 + }
     256 + fmt.Printf("\nFound %v default modules at: %s \n\n", color.HiGreenString("%v", len(content)), color.HiCyanString(defaultModule))
     257 + 
     258 + table := tablewriter.NewWriter(os.Stdout)
     259 + table.SetAutoFormatHeaders(false)
     260 + table.SetHeader([]string{"Module Name", "Description"})
     261 + table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true})
     262 + table.SetColWidth(120)
     263 + table.AppendBulk(content) // Add Bulk Data
     264 + table.Render()
     265 + 
     266 + h := color.HiCyanString("\nModule Usage:\n")
     267 + h += color.HiGreenString(" osmedeus scan -m %v", color.HiMagentaString("[moduleName]")) + color.HiGreenString(" -t ") + color.HiMagentaString("[target]") + "\n\n"
    226 268   fmt.Printf(h)
    227 269   return nil
    228 270  }
    skipped 1 lines
  • ■ ■ ■ ■ ■
    cmd/usage.go
    skipped 96 lines
    97 97   h += " osmedeus utils ps --proc 'jaeles' \n"
    98 98   h += " osmedeus utils cron --cmd 'osmdeus scan -t example.com' --sch 60\n"
    99 99   h += " osmedeus utils cron --for --cmd 'osmedeus scan -t example.com'\n"
     100 + h += " osmedeus utils workflow\n"
    100 101   return h
    101 102  }
    102 103   
    skipped 115 lines
  • ■ ■ ■ ■ ■
    cmd/utils.go
    skipped 12 lines
    13 13   
    14 14  func init() {
    15 15   var utilsCmd = &cobra.Command{
    16  - Use: "utils",
    17  - Short: "Utils to get some information from the system",
    18  - Long: core.Banner(),
    19  - RunE: runProvider,
     16 + Use: "utils",
     17 + Aliases: []string{"u", "util"},
     18 + Short: "Utils to get some information from the system",
     19 + Long: core.Banner(),
     20 + RunE: runUtils,
    20 21   }
    21 22   
    22 23   var psCmd = &cobra.Command{
    skipped 28 lines
    51 52   cronCmd.Flags().BoolVar(&options.Cron.Forever, "for", false, "Keep running forever right after the command done")
    52 53   cronCmd.Flags().StringVar(&options.Cron.Command, "cmd", "", "Command to run")
    53 54   
     55 + var workflowCmd = &cobra.Command{
     56 + Use: "workflow",
     57 + Aliases: []string{"wf", "wl", "workflows", "wfs", "work", "works"},
     58 + Short: "Listing all available workflows",
     59 + Long: core.Banner(),
     60 + RunE: runWorkflow,
     61 + }
     62 + 
    54 63   // add command
    55 64   utilsCmd.PersistentFlags().BoolVar(&options.JsonOutput, "json", false, "Output as JSON")
    56 65   utilsCmd.AddCommand(cronCmd)
    57 66   utilsCmd.AddCommand(tmuxCmd)
    58 67   utilsCmd.AddCommand(psCmd)
     68 + utilsCmd.AddCommand(workflowCmd)
    59 69   utilsCmd.SetHelpFunc(UtilsHelp)
    60 70   RootCmd.AddCommand(utilsCmd)
     71 + RootCmd.AddCommand(workflowCmd)
     72 +}
     73 + 
     74 +func runUtils(_ *cobra.Command, _ []string) error {
     75 + fmt.Println(UtilsUsage())
     76 + return nil
    61 77  }
    62 78   
    63 79  func runPs(cmd *cobra.Command, _ []string) error {
    skipped 59 lines
    123 139   return nil
    124 140  }
    125 141   
     142 +func runWorkflow(_ *cobra.Command, _ []string) error {
     143 + listFlows()
     144 + fmt.Printf("\n------------------------------------------------------------\n")
     145 + listDefaultModules()
     146 + return nil
     147 +}
     148 + 
  • ■ ■ ■ ■ ■ ■
    core/flow.go
    skipped 115 lines
    116 116   return selectedModules
    117 117  }
    118 118   
    119  -// DirectSelectModule select module from ~/.osmedeus/core/workflow/plugins/
     119 +// DefaultWorkflows select module from ~/.osmedeus/core/workflow/plugins/
     120 +func DefaultWorkflows(options libs.Options) []string {
     121 + defaultModule := path.Join(options.Env.WorkFlowsFolder, "default-modules")
     122 + modePath := path.Join(defaultModule, "/*.yaml")
     123 + results, err := filepath.Glob(modePath)
     124 + if err != nil {
     125 + utils.ErrorF("No default module found in %v", defaultModule)
     126 + return []string{}
     127 + }
     128 + return results
     129 +}
     130 + 
     131 +// DirectSelectModule select module from ~/osmedeus-base/workflow/default-modules
    120 132  func DirectSelectModule(options libs.Options, moduleName string) string {
    121 133   // got absolutely path
    122 134   if utils.FileExists(moduleName) {
    skipped 71 lines
  • ■ ■ ■ ■ ■ ■
    core/module.go
    skipped 37 lines
    38 38   r.DBNewReports(module)
    39 39   
    40 40   // pre-run
    41  - utils.InforF("Running prepare scripts for module %v", color.CyanString(module.Name))
    42  - r.RunScripts(module.PreRun)
     41 + if len(module.PreRun) > 0 {
     42 + utils.InforF("Running prepare scripts for module %v", color.CyanString(module.Name))
     43 + r.RunScripts(module.PreRun)
     44 + }
    43 45   
    44 46   // main part
    45 47   utils.BlockF(module.Name, "Start run main steps")
    skipped 3 lines
    49 51   }
    50 52   
    51 53   // post-run
    52  - utils.InforF("Running prepare scripts for module %v", color.CyanString(module.Name))
    53  - r.RunScripts(module.PostRun)
     54 + if len(module.PostRun) > 0 {
     55 + utils.InforF("Running conclude scripts for module %v", color.CyanString(module.Name))
     56 + r.RunScripts(module.PostRun)
     57 + }
    54 58   
    55 59   // print the reports file
    56 60   utils.PrintLine()
    skipped 324 lines
  • ■ ■ ■ ■ ■
    core/runner.go
    skipped 147 lines
    148 148   r.RoutinePath = rawModule
    149 149   r.Opt.Module, err = ParseModules(module)
    150 150   if err != nil || r.Opt.Module.Name == "" {
     151 + utils.WarnF("Your module %v doesn't exist", color.HiRedString(r.Opt.Scan.Modules[0]))
    151 152   continue
    152 153   }
    153 154   if r.Opt.Module.NoDB {
    skipped 195 lines
  • ■ ■ ■ ■ ■
    core/validate.go
    skipped 14 lines
    15 15   return nil
    16 16   }
    17 17   
    18  - // cidr, cidr-file
    19 18   r.RequiredInput = strings.ToLower(strings.TrimSpace(r.RequiredInput))
     19 + //if r.RequiredInput == "file" {
     20 + // if utils.FileExists(r.Input) {
     21 + // return nil
     22 + // }
     23 + //}
     24 + 
    20 25   var inputAsFile bool
    21  - if strings.HasSuffix(r.RequiredInput, "-file") {
     26 + // cidr, cidr-file
     27 + if strings.HasSuffix(r.RequiredInput, "-file") || r.RequiredInput == "file" {
    22 28   inputAsFile = true
    23 29   }
    24 30   v := validator.New()
    25 31   
    26 32   // if input as a file
    27 33   if utils.FileExists(r.Input) && inputAsFile {
    28  - 
    29 34   r.InputType = "file"
    30 35   inputs := utils.ReadingLines(r.Input)
    31 36   
    skipped 17 lines
    49 54   
    50 55   }
    51 56   
     57 + utils.InforF("Start validating input: %v", color.HiCyanString("%v -- %v", r.Input, r.InputType))
    52 58   var err error
    53 59   r.InputType, err = validate(v, r.Input)
    54 60   if err != nil {
    skipped 5 lines
    60 66   return fmt.Errorf("input does not match the require validation: inputType:%v -- requireType:%v", r.InputType, r.RequiredInput)
    61 67   }
    62 68   
    63  - utils.InforF("Start validating input: %v", color.HiCyanString("%v -- %v", r.Input, r.InputType))
    64 69   if inputAsFile {
    65 70   utils.MakeDir(libs.TEMP)
    66 71   dest := path.Join(libs.TEMP, fmt.Sprintf("%v-%v", utils.StripPath(r.Input), utils.RandomString(4)))
    skipped 7 lines
    74 79   }
    75 80   
    76 81   utils.DebugF("validator: input:%v -- type: %v -- require:%v", r.Input, r.InputType, r.RequiredInput)
    77  - 
    78 82   return nil
    79 83  }
    80 84   
    81 85  func validate(v *validator.Validate, raw string) (string, error) {
    82 86   var err error
    83 87   var inputType string
     88 + 
     89 + if utils.FileExists(raw) {
     90 + inputType = "file"
     91 + }
    84 92   
    85 93   err = v.Var(raw, "required,url")
    86 94   if err == nil {
    skipped 28 lines
    115 123   err = v.Var(raw, "required,uri")
    116 124   if err == nil {
    117 125   inputType = "url"
    118  - if strings.HasPrefix(raw, "https://github.com") || strings.HasPrefix(raw, "https://gitlab.com") || strings.HasPrefix(raw, "git@") {
     126 + if strings.HasPrefix(raw, "https://github.com") || strings.HasPrefix(raw, "https://gitlab.com") {
    119 127   inputType = "git-url"
    120 128   }
     129 + }
     130 + 
     131 + if strings.HasPrefix(raw, "git@") {
     132 + inputType = "git-url"
    121 133   }
    122 134   
    123 135   if inputType == "" {
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    core/validate_test.go
    skipped 27 lines
    28 28   
    29 29   runner.Input = "1.2.3.4/24"
    30 30   runner.Validator()
     31 + 
     32 + runner.Input = "https://github.com/j3ssie/osmedeus"
     33 + runner.Validator()
     34 + fmt.Printf("==> runner.InputType --> %v:%v -- %s\n\n", runner.RequiredInput, runner.InputType, runner.Input)
     35 + 
     36 + runner.Input = "[email protected]:j3ssie/osmedeus.git"
     37 + runner.Validator()
     38 + fmt.Printf("==> runner.InputType --> %v:%v -- %s\n\n", runner.RequiredInput, runner.InputType, runner.Input)
     39 + 
    31 40   //
    32 41   ////raw := "tcp://[email protected]:j3ssie/osmd-assets"
    33 42   //raw := "[email protected]/j3ssie/osmd-assets"
    skipped 12 lines
  • ■ ■ ■ ■
    libs/version.go
    skipped 3 lines
    4 4   
    5 5  const (
    6 6   // VERSION of this project
    7  - VERSION = "v4.1.3"
     7 + VERSION = "v4.1.4"
    8 8   // DESC description of the tool
    9 9   DESC = "A Workflow Engine for Offensive Security"
    10 10   // BINARY name of osmedeus
    skipped 17 lines
Please wait...
Page is in error, reload to recover