@@ -38,6 +38,7 @@ import (
38
38
"github.com/Mzack9999/gcache"
39
39
"github.com/asaskevich/govalidator"
40
40
"github.com/hashicorp/go-version"
41
+ "github.com/iangcarroll/cookiemonster/pkg/monster"
41
42
"github.com/kataras/jwt"
42
43
"github.com/logrusorgru/aurora"
43
44
"github.com/projectdiscovery/dsl/deserialization"
@@ -1437,7 +1438,35 @@ func init() {
1437
1438
}
1438
1439
1439
1440
return cases .Title (lang ).String (s ), nil
1440
- }))
1441
+ },
1442
+ ))
1443
+
1444
+ MustAddFunction (NewWithSingleSignature ("cookie_unsign" ,
1445
+ "(s string) string" , false ,
1446
+ func (args ... interface {}) (interface {}, error ) {
1447
+ argSize := len (args )
1448
+ if argSize < 1 {
1449
+ return nil , ErrInvalidDslFunction
1450
+ }
1451
+ s := toString (args [0 ])
1452
+
1453
+ wl := monster .NewWordlist ()
1454
+ if err := wl .LoadDefault (); err != nil {
1455
+ return s , errors .New ("could not load default wordlist" )
1456
+ }
1457
+
1458
+ c := monster .NewCookie (s )
1459
+ if ! c .Decode () {
1460
+ return s , errors .New ("could not decode cookie" )
1461
+ }
1462
+
1463
+ if cookie , ok := c .Unsign (wl , 100 ); ok {
1464
+ return string (cookie ), nil
1465
+ }
1466
+
1467
+ return s , errors .New ("could not unsign cookie" )
1468
+ },
1469
+ ))
1441
1470
1442
1471
MustAddFunction (NewWithPositionalArgs ("gzip_mtime" , 1 , true , func (args ... interface {}) (interface {}, error ) {
1443
1472
if len (args ) == 0 {
0 commit comments