Skip to content

Commit b87f202

Browse files
committed
Update v0.13
1 parent 6b63235 commit b87f202

File tree

8 files changed

+141
-51
lines changed

8 files changed

+141
-51
lines changed

cmd/config.go

+93-39
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
"github.com/fatih/color"
56
"os"
67
"path"
78
"path/filepath"
@@ -26,32 +27,31 @@ func init() {
2627
configCmd.Flags().Bool("clean", false, "Clean old record")
2728
configCmd.Flags().StringP("action", "a", "", "Action")
2829
// 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")
3330
configCmd.Flags().Bool("poll", false, "Polling all record in OOB config")
34-
// used for update action
3531
configCmd.Flags().String("secret", "", "Secret of Burp Collab")
3632
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")
3940
configCmd.SetHelpFunc(configHelp)
4041
RootCmd.AddCommand(configCmd)
4142

4243
}
4344

44-
func runConfig(cmd *cobra.Command, _ []string) error {
45+
func runConfig(cmd *cobra.Command, args []string) error {
46+
sort.Strings(args)
4547
// print more help
4648
helps, _ := cmd.Flags().GetBool("hh")
47-
mics, _ := cmd.Flags().GetBool("mics")
4849
if helps == true {
4950
HelpMessage()
5051
os.Exit(1)
5152
}
5253
// turn on verbose by default
5354
options.Verbose = true
54-
5555
polling, _ := cmd.Flags().GetBool("poll")
5656
// polling all oob
5757
if polling == true {
@@ -64,17 +64,41 @@ func runConfig(cmd *cobra.Command, _ []string) error {
6464
}
6565

6666
action, _ := cmd.Flags().GetString("action")
67+
// backward compatible
68+
if action == "" && len(args) > 0 {
69+
action = args[0]
70+
}
71+
getJaelesEnv(&options)
72+
6773
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\nDo 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
6889
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\nDo 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+
}
7499
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)
78102
break
79103
case "clear":
80104
utils.GoodF("Cleaning your DB")
@@ -86,10 +110,8 @@ func runConfig(cmd *cobra.Command, _ []string) error {
86110
os.RemoveAll(options.RootFolder)
87111
break
88112
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)
93115
break
94116
case "oob":
95117
secret, _ := cmd.Flags().GetString("secret")
@@ -99,12 +121,9 @@ func runConfig(cmd *cobra.Command, _ []string) error {
99121
database.ImportCollab(secret, collab)
100122
}
101123
break
102-
case "init":
103-
reloadSignature(options.SignFolder, mics)
104-
break
105124
case "reload":
106125
os.RemoveAll(path.Join(options.RootFolder, "base-signatures"))
107-
reloadSignature(options.SignFolder, mics)
126+
reloadSignature(options.SignFolder, options.Config.SkipMics)
108127
break
109128
case "add":
110129
addSignature(options.SignFolder)
@@ -263,34 +282,55 @@ Mics Flags:
263282
h += "\nOthers Commands:\n"
264283
h += " jaeles server -s '/tmp/custom-signature/sensitive/.*' -L 2\n"
265284
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"
269288
h += " jaeles report -o /tmp/scanned/out\n"
270289
h += " jaeles report -o /tmp/scanned/out --title 'Passive Report'\n"
271290
h += " jaeles report -o /tmp/scanned/out --title 'Verbose Report' --sverbose\n"
272-
h += "\nOfficial Documentation can be found here: https://jaeles-project.github.io/\n"
273291
fmt.Println(h)
292+
fmt.Printf("Official Documentation can be found here: %s\n", color.GreenString(libs.DOCS))
293+
274294
}
275295

276296
// HelpMessage print help message
277297
func HelpMessage() {
278-
h := "\nConfig 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+
`
287324
fmt.Println(h)
325+
fmt.Printf("Official Documentation can be found here: %s\n", color.GreenString(libs.DOCS))
326+
288327
}
289328

290329
func ScanHelp(cmd *cobra.Command, _ []string) {
291330
fmt.Println(libs.Banner())
292331
fmt.Println(cmd.UsageString())
293332
ScanMessage()
333+
fmt.Printf("Official Documentation can be found here: %s\n", color.GreenString(libs.DOCS))
294334
}
295335

296336
// ScanMessage print help message
@@ -315,20 +355,34 @@ func ScanMessage() {
315355
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"
316356
h += "\n"
317357
fmt.Println(h)
358+
fmt.Printf("Official Documentation can be found here: %s\n", color.GreenString(libs.DOCS))
318359
}
319360

320361
// ServerHelp report help message
321362
func ServerHelp(cmd *cobra.Command, _ []string) {
322363
fmt.Println(libs.Banner())
323364
fmt.Println(cmd.UsageString())
365+
fmt.Printf("Official Documentation can be found here: %s\n", color.GreenString(libs.DOCS))
366+
324367
}
325368

326369
// ReportHelp report help message
327370
func ReportHelp(cmd *cobra.Command, _ []string) {
328371
fmt.Println(libs.Banner())
329372
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+
}
330383
}
331384

385+
// CleanOutput clean the output folder in case nothing found
332386
func CleanOutput() {
333387
// clean output
334388
if utils.DirLength(options.Output) == 0 {

cmd/root.go

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func initConfig() {
128128
_, err = database.InitDB(utils.NormalizePath(options.Server.DBPath))
129129
if err != nil {
130130
fmt.Fprintf(os.Stderr, "Can't connect to DB at %v\n", options.Server.DBPath)
131+
fmt.Fprintf(os.Stderr, "Use '--no-db' for to disable DB connection if you want.\n")
131132
os.Exit(-1)
132133
}
133134
}

core/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func InitConfig(options *libs.Options) {
2323
os.MkdirAll(options.RootFolder, 0750)
2424
// cloning default repo
2525
UpdatePlugins(*options)
26-
UpdateSignature(*options, "")
26+
UpdateSignature(*options)
2727
}
2828

2929
configPath := path.Join(options.RootFolder, "config.yaml")

core/update.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ func UpdatePlugins(options libs.Options) {
3333
}
3434

3535
// UpdateSignature update latest UI from UI repo
36-
func UpdateSignature(options libs.Options, customRepo string) {
36+
func UpdateSignature(options libs.Options) {
3737
signPath := path.Join(options.RootFolder, "base-signatures")
38-
3938
url := libs.SIGNREPO
40-
if customRepo != "" {
41-
url = customRepo
39+
// in case we want to in private repo
40+
if options.Config.Repo != "" {
41+
url = options.Config.Repo
4242
}
4343

4444
utils.GoodF("Cloning Signature from: %v", url)
@@ -49,16 +49,16 @@ func UpdateSignature(options libs.Options, customRepo string) {
4949
os.RemoveAll(options.ResourcesFolder)
5050
os.RemoveAll(options.ThirdPartyFolder)
5151
}
52-
if options.Server.Key != "" {
53-
cmd := fmt.Sprintf("GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -i %v' git clone --depth=1 %v %v", options.Server.Key, url, signPath)
52+
if options.Config.PrivateKey != "" {
53+
cmd := fmt.Sprintf("GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -i %v' git clone --depth=1 %v %v", options.Config.PrivateKey, url, signPath)
5454
Execution(cmd)
5555
} else {
5656
var err error
5757
if options.Server.Username != "" && options.Server.Password != "" {
5858
_, err = git.PlainClone(signPath, false, &git.CloneOptions{
5959
Auth: &http.BasicAuth{
60-
Username: options.Server.Username,
61-
Password: options.Server.Password,
60+
Username: options.Config.Username,
61+
Password: options.Config.Password,
6262
},
6363
URL: url,
6464
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,

libs/options.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ type Options struct {
5252
AlwaysTrue bool
5353
BaseRoot bool
5454
BurpProxy bool
55-
Server Server
56-
Report Report
5755
ChunkDir string
5856
ChunkRun bool
5957
ChunkSize int
6058
ChunkLimit int
59+
Server Server
60+
Report Report
61+
Config Config
6162
}
6263

6364
// Report options for api server
@@ -84,6 +85,16 @@ type Server struct {
8485
Key string
8586
}
8687

88+
// Config options for api server
89+
type Config struct {
90+
Forced bool
91+
SkipMics bool
92+
Username string
93+
Password string
94+
Repo string
95+
PrivateKey string
96+
}
97+
8798
// Job define job for running routine
8899
type Job struct {
89100
URL string

libs/signature.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Signature struct {
1313
Donce bool
1414
Info struct {
1515
Name string
16+
Author string
1617
Risk string
1718
Confidence string
1819
Category string

libs/version.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package libs
22

33
const (
44
// VERSION current Jaeles version
5-
VERSION = "beta v0.12.4"
5+
VERSION = "beta v0.13"
66
// AUTHOR author of this
77
AUTHOR = "@j3ssiejjj"
8+
// DOCS link to official documentation
9+
DOCS = "http://jaeles-project.github.io/"
810
// SIGNREPO default repo to get signature
911
SIGNREPO = "https://github.com/jaeles-project/jaeles-signatures"
1012
// UIREPO default repo to get UI

utils/helper.go

+21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
"io/ioutil"
10+
"log"
1011
"os"
1112
"path"
1213
"path/filepath"
@@ -387,3 +388,23 @@ func ChunkFileBySize(source string, chunk int) [][]string {
387388
}
388389
return divided
389390
}
391+
392+
func PromptConfirm(s string) bool {
393+
reader := bufio.NewReader(os.Stdin)
394+
for {
395+
fmt.Printf("%s [y/n]: ", s)
396+
397+
response, err := reader.ReadString('\n')
398+
if err != nil {
399+
log.Fatal(err)
400+
}
401+
402+
response = strings.ToLower(strings.TrimSpace(response))
403+
404+
if response == "y" || response == "yes" {
405+
return true
406+
} else if response == "n" || response == "no" {
407+
return false
408+
}
409+
}
410+
}

0 commit comments

Comments
 (0)