@@ -2,6 +2,7 @@ package cmd
2
2
3
3
import (
4
4
"fmt"
5
+ "github.com/fatih/color"
5
6
"os"
6
7
"path"
7
8
"path/filepath"
@@ -26,32 +27,31 @@ func init() {
26
27
configCmd .Flags ().Bool ("clean" , false , "Clean old record" )
27
28
configCmd .Flags ().StringP ("action" , "a" , "" , "Action" )
28
29
// used for cred action
29
- configCmd .Flags ().String ("user" , "" , "Username" )
30
- configCmd .Flags ().String ("pass" , "" , "Password" )
31
- configCmd .Flags ().Bool ("hh" , false , "More helper" )
32
- configCmd .Flags ().Bool ("mics" , true , "Skip import mics signatures" )
33
30
configCmd .Flags ().Bool ("poll" , false , "Polling all record in OOB config" )
34
- // used for update action
35
31
configCmd .Flags ().String ("secret" , "" , "Secret of Burp Collab" )
36
32
configCmd .Flags ().String ("collab" , "" , "List of Burp Collab File" )
37
- configCmd .Flags ().String ("repo" , "" , "Signature Repo" )
38
- configCmd .Flags ().StringVarP (& options .Server .Key , "key" , "K" , "" , "Private Key to pull repo" )
33
+ // used for update action
34
+ configCmd .Flags ().BoolVar (& options .Config .SkipMics , "mics" , true , "Skip import mics signatures" )
35
+ configCmd .Flags ().BoolVarP (& options .Config .Forced , "yes" , "y" , false , "Forced to delete old folder" )
36
+ configCmd .Flags ().StringVar (& options .Config .Username , "user" , "" , "Username" )
37
+ configCmd .Flags ().StringVar (& options .Config .Password , "pass" , "" , "Password" )
38
+ configCmd .Flags ().StringVar (& options .Config .Repo , "repo" , "" , "Signature Repo" )
39
+ configCmd .Flags ().StringVarP (& options .Config .PrivateKey , "key" , "K" , "" , "Private Key to pull repo" )
39
40
configCmd .SetHelpFunc (configHelp )
40
41
RootCmd .AddCommand (configCmd )
41
42
42
43
}
43
44
44
- func runConfig (cmd * cobra.Command , _ []string ) error {
45
+ func runConfig (cmd * cobra.Command , args []string ) error {
46
+ sort .Strings (args )
45
47
// print more help
46
48
helps , _ := cmd .Flags ().GetBool ("hh" )
47
- mics , _ := cmd .Flags ().GetBool ("mics" )
48
49
if helps == true {
49
50
HelpMessage ()
50
51
os .Exit (1 )
51
52
}
52
53
// turn on verbose by default
53
54
options .Verbose = true
54
-
55
55
polling , _ := cmd .Flags ().GetBool ("poll" )
56
56
// polling all oob
57
57
if polling == true {
@@ -64,17 +64,41 @@ func runConfig(cmd *cobra.Command, _ []string) error {
64
64
}
65
65
66
66
action , _ := cmd .Flags ().GetString ("action" )
67
+ // backward compatible
68
+ if action == "" && len (args ) > 0 {
69
+ action = args [0 ]
70
+ }
71
+ getJaelesEnv (& options )
72
+
67
73
switch action {
74
+ case "init" :
75
+ if utils .FolderExists (options .RootFolder ) {
76
+ if options .Config .Forced {
77
+ os .RemoveAll (options .RootFolder )
78
+ } else {
79
+ mess := fmt .Sprintf ("Looks like you already have signatures in %s\n Do you want to to override it?" , options .RootFolder )
80
+ c := utils .PromptConfirm (mess )
81
+ if c {
82
+ utils .InforF ("Cleaning root folder" )
83
+ os .RemoveAll (options .RootFolder )
84
+ }
85
+ }
86
+ }
87
+ reloadSignature (options .SignFolder , options .Config .SkipMics )
88
+ break
68
89
case "update" :
69
- // in case we want to in private repo
70
- username , _ := cmd .Flags ().GetString ("user" )
71
- password , _ := cmd .Flags ().GetString ("pass" )
72
- options .Server .Username = username
73
- options .Server .Password = password
90
+ // only ask if use default Repo
91
+ if utils .FolderExists (options .RootFolder ) && options .Config .Repo == "" {
92
+ mess := fmt .Sprintf ("Looks like you already have signatures in %s\n Do you want to to override it?" , options .RootFolder )
93
+ c := utils .PromptConfirm (mess )
94
+ if c {
95
+ utils .InforF ("Cleaning root folder" )
96
+ os .RemoveAll (options .RootFolder )
97
+ }
98
+ }
74
99
core .UpdatePlugins (options )
75
- repo , _ := cmd .Flags ().GetString ("repo" )
76
- core .UpdateSignature (options , repo )
77
- reloadSignature (path .Join (options .RootFolder , "base-signatures" ), mics )
100
+ core .UpdateSignature (options )
101
+ reloadSignature (path .Join (options .RootFolder , "base-signatures" ), options .Config .SkipMics )
78
102
break
79
103
case "clear" :
80
104
utils .GoodF ("Cleaning your DB" )
@@ -86,10 +110,8 @@ func runConfig(cmd *cobra.Command, _ []string) error {
86
110
os .RemoveAll (options .RootFolder )
87
111
break
88
112
case "cred" :
89
- username , _ := cmd .Flags ().GetString ("user" )
90
- password , _ := cmd .Flags ().GetString ("pass" )
91
- database .CreateUser (username , password )
92
- utils .GoodF ("Create new credentials %v:%v \n " , username , password )
113
+ database .CreateUser (options .Config .Username , options .Config .Password )
114
+ utils .GoodF ("Create new credentials %v:%v \n " , options .Config .Username , options .Config .Password )
93
115
break
94
116
case "oob" :
95
117
secret , _ := cmd .Flags ().GetString ("secret" )
@@ -99,12 +121,9 @@ func runConfig(cmd *cobra.Command, _ []string) error {
99
121
database .ImportCollab (secret , collab )
100
122
}
101
123
break
102
- case "init" :
103
- reloadSignature (options .SignFolder , mics )
104
- break
105
124
case "reload" :
106
125
os .RemoveAll (path .Join (options .RootFolder , "base-signatures" ))
107
- reloadSignature (options .SignFolder , mics )
126
+ reloadSignature (options .SignFolder , options . Config . SkipMics )
108
127
break
109
128
case "add" :
110
129
addSignature (options .SignFolder )
@@ -263,34 +282,55 @@ Mics Flags:
263
282
h += "\n Others Commands:\n "
264
283
h += " jaeles server -s '/tmp/custom-signature/sensitive/.*' -L 2\n "
265
284
h += " jaeles server --host 0.0.0.0 --port 5000 -s '/tmp/custom-signature/sensitive/.*' -L 2\n "
266
- h += " jaeles config -a reload --signDir /tmp/standard-signatures/\n "
267
- h += " jaeles config -a add -B /tmp/custom-active-signatures/\n "
268
- h += " jaeles config -a update --repo https://github.com/jaeles-project/jaeles-signatures\n "
285
+ h += " jaeles config reload --signDir /tmp/standard-signatures/\n "
286
+ h += " jaeles config add -B /tmp/custom-active-signatures/\n "
287
+ h += " jaeles config update --repo https://github.com/jaeles-project/jaeles-signatures\n "
269
288
h += " jaeles report -o /tmp/scanned/out\n "
270
289
h += " jaeles report -o /tmp/scanned/out --title 'Passive Report'\n "
271
290
h += " jaeles report -o /tmp/scanned/out --title 'Verbose Report' --sverbose\n "
272
- h += "\n Official Documentation can be found here: https://jaeles-project.github.io/\n "
273
291
fmt .Println (h )
292
+ fmt .Printf ("Official Documentation can be found here: %s\n " , color .GreenString (libs .DOCS ))
293
+
274
294
}
275
295
276
296
// HelpMessage print help message
277
297
func HelpMessage () {
278
- h := "\n Config Command example:\n \n "
279
- h += " jaeles config -a init\n \n "
280
- h += " jaeles config -a update --repo http://github.com/jaeles-project/another-signatures --user admin --pass admin\n "
281
- h += " jaeles config -a update --repo [email protected] /jaeles-project/another-signatures -K your_private_key\n "
282
- h += " jaeles config -a clean\n "
283
- h += " jaeles config -a reload\n "
284
- h += " jaeles config -a reload --signDir /tmp/standard-signatures/\n "
285
- h += " jaeles config -a add --signDir /tmp/standard-signatures/\n "
286
- h += " jaeles config -a cred --user sample --pass not123456\n \n "
298
+ h := `
299
+ Usage:
300
+ jaeles config [action]
301
+
302
+ Config Command examples:
303
+ # Init default signatures
304
+ jaeles config init
305
+
306
+ # Update latest signatures
307
+ jaeles config update
308
+ jaeles config update --repo http://github.com/jaeles-project/another-signatures --user admin --pass admin
309
+ jaeles config update --repo [email protected] /jaeles-project/another-signatures -K your_private_key
310
+
311
+ # Reload signatures from a standard signatures folder (contain passives + resources)
312
+ jaeles config reload --signDir ~/standard-signatures/
313
+
314
+ # Add custom signatures from folder
315
+ jaeles config add --signDir ~/custom-signatures/
316
+
317
+ # Clean old stuff
318
+ jaeles config clean
319
+
320
+ # More examples
321
+ jaeles config add --signDir /tmp/standard-signatures/
322
+ jaeles config cred --user sample --pass not123456
323
+ `
287
324
fmt .Println (h )
325
+ fmt .Printf ("Official Documentation can be found here: %s\n " , color .GreenString (libs .DOCS ))
326
+
288
327
}
289
328
290
329
func ScanHelp (cmd * cobra.Command , _ []string ) {
291
330
fmt .Println (libs .Banner ())
292
331
fmt .Println (cmd .UsageString ())
293
332
ScanMessage ()
333
+ fmt .Printf ("Official Documentation can be found here: %s\n " , color .GreenString (libs .DOCS ))
294
334
}
295
335
296
336
// ScanMessage print help message
@@ -315,20 +355,34 @@ func ScanMessage() {
315
355
h += " cat urls.txt | grep 'interesting' | jaeles scan -L 5 -c 50 -s 'fuzz/.*' -U list_of_urls.txt --proxy http://127.0.0.1:8080\n "
316
356
h += "\n "
317
357
fmt .Println (h )
358
+ fmt .Printf ("Official Documentation can be found here: %s\n " , color .GreenString (libs .DOCS ))
318
359
}
319
360
320
361
// ServerHelp report help message
321
362
func ServerHelp (cmd * cobra.Command , _ []string ) {
322
363
fmt .Println (libs .Banner ())
323
364
fmt .Println (cmd .UsageString ())
365
+ fmt .Printf ("Official Documentation can be found here: %s\n " , color .GreenString (libs .DOCS ))
366
+
324
367
}
325
368
326
369
// ReportHelp report help message
327
370
func ReportHelp (cmd * cobra.Command , _ []string ) {
328
371
fmt .Println (libs .Banner ())
329
372
fmt .Println (cmd .UsageString ())
373
+ fmt .Printf ("Official Documentation can be found here: %s\n " , color .GreenString (libs .DOCS ))
374
+ }
375
+
376
+ func getJaelesEnv (options * libs.Options ) {
377
+ if utils .GetOSEnv ("JAELES_REPO" ) != "JAELES_REPO" {
378
+ options .Config .Repo = utils .GetOSEnv ("JAELES_REPO" )
379
+ }
380
+ if utils .GetOSEnv ("JAELES_KEY" ) != "JAELES_KEY" {
381
+ options .Config .PrivateKey = utils .GetOSEnv ("JAELES_KEY" )
382
+ }
330
383
}
331
384
385
+ // CleanOutput clean the output folder in case nothing found
332
386
func CleanOutput () {
333
387
// clean output
334
388
if utils .DirLength (options .Output ) == 0 {
0 commit comments