Skip to content

Commit

Permalink
Add arguments error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Oct 30, 2020
1 parent e6f8c96 commit 2746562
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
14 changes: 10 additions & 4 deletions cmd/crack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
crack "github.com/hahwul/jwt-hack/pkg/crack"
"github.com/spf13/cobra"
log "github.com/sirupsen/logrus"
)

var wordlist, chars, mode string
Expand All @@ -14,10 +15,15 @@ var crackCmd = &cobra.Command{
Use: "crack [JWT Token]",
Short: "Cracking JWT Token",
Run: func(cmd *cobra.Command, args []string) {
if mode == "dict" {
crack.Crack(mode, args[0], wordlist, conc, max, power)
} else if mode == "brute" {
crack.Crack(mode, args[0], chars, conc, max, power)
if len(args) >= 1 {
if mode == "dict" {
crack.Crack(mode, args[0], wordlist, conc, max, power)
} else if mode == "brute" {
crack.Crack(mode, args[0], chars, conc, max, power)
}
} else {
log.Error("Arguments Error")
log.Error("e.g jwt-hack crack {JWT_CODE} -w {WORDLIST}")
}
},
}
Expand Down
1 change: 1 addition & 0 deletions cmd/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var decodeCmd = &cobra.Command{
var log = logrus.New()
log.Out = os.Stdout
log.Error("Arguments Error")
log.Error("e.g jwt-hack decode {JWT_CODE}")
}
},
}
Expand Down
1 change: 1 addition & 0 deletions cmd/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var encodeCmd = &cobra.Command{
fmt.Println(jwtInterface.JWTencode(raw, secret, algo))
} else {
log.Error("Arguments Error")
log.Error("e.g jwt-hack encode {JWT_CODE} --secret={YOUR_SECRET}")
}
},
}
Expand Down
12 changes: 9 additions & 3 deletions cmd/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ import (
jwtInterface "github.com/hahwul/jwt-hack/pkg/jwt"
jwtPayload "github.com/hahwul/jwt-hack/pkg/payload"
"github.com/spf13/cobra"
log "github.com/sirupsen/logrus"
)

// payloadCmd represents the payload command
var payloadCmd = &cobra.Command{
Use: "payload [JWT Token]",
Short: "Generate JWT Attack payloads",
Run: func(cmd *cobra.Command, args []string) {
var token *jwt.Token
token = jwtInterface.JWTdecode(args[0])
jwtPayload.GenerateAllPayloads(token)
if len(args) >= 1 {
var token *jwt.Token
token = jwtInterface.JWTdecode(args[0])
jwtPayload.GenerateAllPayloads(token)
} else {
log.Error("Arguments Error")
log.Error("e.g jwt-hack payload {JWT_CODE}")
}
},
}

Expand Down

0 comments on commit 2746562

Please sign in to comment.