Skip to content

Commit

Permalink
(#14) show more information in decode mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Oct 24, 2020
1 parent b8569ca commit 95df53d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
28 changes: 28 additions & 0 deletions cmd/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"fmt"
"os"
"time"
"strconv"
"encoding/json"

"github.com/dgrijalva/jwt-go"
Expand All @@ -21,14 +23,40 @@ var decodeCmd = &cobra.Command{
if len(args) >= 1 {
var token *jwt.Token
var log = logrus.New()
var jdata map[string]interface{}

log.Out = os.Stdout
token = jwtInterface.JWTdecode(args[0])
header,_ := json.Marshal(token.Header)
log.WithFields(logrus.Fields{
"method": token.Method,
"header": string(header),
}).Info("Decoded data(claims)")

data,_ := json.Marshal(token.Claims)
json.Unmarshal([]byte(data),&jdata)


if jdata["iat"] != nil {
iatf := jdata["iat"].(float64)
iats := fmt.Sprintf("%.0f",iatf)
iat,_ := strconv.Atoi(iats)
iatt := time.Unix(0,int64(iat))
log.WithFields(logrus.Fields{
"IAT": iats,
"TIME": iatt,
}).Info("Issued At Time")
}
if jdata["exp"] != nil {
expf := jdata["exp"].(float64)
exps := fmt.Sprintf("%.0f",expf)
exp,_ := strconv.Atoi(exps)
expt := time.Unix(0,int64(exp))
log.WithFields(logrus.Fields{
"EXP": exps,
"TIME": expt,
}).Info("Expiraton Time")
}
fmt.Println(string(data))
} else {
var log = logrus.New()
Expand Down
9 changes: 7 additions & 2 deletions pkg/crack/crack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

jwtInterface "github.com/hahwul/jwt-hack/pkg/jwt"
"github.com/sirupsen/logrus"
color "github.com/logrusorgru/aurora"
)

var log = logrus.New()
Expand Down Expand Up @@ -37,6 +38,7 @@ func Crack(mode, token, data string, concurrency, max int, power bool) {
func RunTestingJWT(token string, lists []string, concurrency int) {
wordlists := make(chan string)
found := false
secret := ""
// Add go routine job
var wg sync.WaitGroup
for i := 0; i < concurrency; i++ {
Expand All @@ -51,9 +53,9 @@ func RunTestingJWT(token string, lists []string, concurrency int) {
log.WithFields(logrus.Fields{
"Signature": "Verified",
"Word": word,
}).Info("Found! This JWT Token signature secret is.. ")
fmt.Println(word)
}).Info("Found! Token signature secret is "+word)
found = true
secret = word

} else {
log.WithFields(logrus.Fields{
Expand All @@ -73,5 +75,8 @@ func RunTestingJWT(token string, lists []string, concurrency int) {

close(wordlists)
wg.Wait()
if found {
fmt.Println("[+] Found! JWT signature secret:",color.BrightYellow(secret))
}
fmt.Println("[+] Finish crack mode")
}

0 comments on commit 95df53d

Please sign in to comment.