first commit
This commit is contained in:
commit
84153f4d86
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module secucookiedump
|
||||||
|
|
||||||
|
go 1.22.5
|
||||||
|
|
||||||
|
require github.com/gorilla/securecookie v1.1.2 // indirect
|
||||||
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
|
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||||
53
secucookiedump.go
Normal file
53
secucookiedump.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gorilla/securecookie"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
|
key := os.Getenv("SESSION_SECRET")
|
||||||
|
|
||||||
|
if key == "" {
|
||||||
|
fmt.Print("Key not set\nEnter key: ")
|
||||||
|
for scanner.Scan() {
|
||||||
|
key = scanner.Text()
|
||||||
|
if key != "" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
fmt.Print("Enter key: ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s := securecookie.New([]byte(key), nil)
|
||||||
|
|
||||||
|
fmt.Println("Using key:", key)
|
||||||
|
fmt.Println("Enter secure cookie (Ctrl+D to finish):")
|
||||||
|
|
||||||
|
for scanner.Scan() {
|
||||||
|
text := scanner.Text()
|
||||||
|
fmt.Println("Read:", text)
|
||||||
|
split := strings.SplitN(text, "=", 2)
|
||||||
|
//split := strings.Fields(text)
|
||||||
|
value := make(map[interface{}]interface{})
|
||||||
|
if err := s.Decode(split[0], split[1], &value); err == nil {
|
||||||
|
for key, val := range value {
|
||||||
|
fmt.Printf("Key: %s, Value: %s\n", key, val)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println("")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
fmt.Println("Error reading standard input:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Program finished.")
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user