Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
V4NSH4J
GitHub Repository: V4NSH4J/discord-mass-DM-GO
Path: blob/main/discord/token_checker.go
310 views
1
// Copyright (C) 2021 github.com/V4NSH4J
2
//
3
// This source code has been released under the GNU Affero General Public
4
// License v3.0. A copy of this license is available at
5
// https://www.gnu.org/licenses/agpl-3.0.en.html
6
7
package discord
8
9
import (
10
"fmt"
11
"os"
12
"os/exec"
13
"time"
14
15
"github.com/V4NSH4J/discord-mass-dm-GO/instance"
16
"github.com/V4NSH4J/discord-mass-dm-GO/utilities"
17
"github.com/gookit/color"
18
"github.com/zenthangplus/goccm"
19
)
20
21
func LaunchTokenChecker() {
22
cfg, instances, err := instance.GetEverything()
23
if err != nil {
24
utilities.LogErr("Error while getting neccessary information %v", err)
25
return
26
}
27
var tokenFile, workingFile, lockedFile, uncheckedFile, emailVerifiedFile, phoneVerifiedFile, unverifiedFile, spammerFile, quarantinedFile string
28
if cfg.OtherSettings.Logs {
29
path := fmt.Sprintf(`logs/token_checker/DMDGO-TC-%s-%s`, time.Now().Format(`2006-01-02 15-04-05`), utilities.RandStringBytes(5))
30
err := os.MkdirAll(path, 0755)
31
if err != nil && !os.IsExist(err) {
32
utilities.LogErr("Error creating logs directory: %s", err)
33
utilities.ExitSafely()
34
}
35
tokenFileX, err := os.Create(fmt.Sprintf(`%s/token.txt`, path))
36
if err != nil {
37
utilities.LogErr("Error creating token file: %s", err)
38
utilities.ExitSafely()
39
}
40
tokenFileX.Close()
41
workingFileX, err := os.Create(fmt.Sprintf(`%s/working.txt`, path))
42
if err != nil {
43
utilities.LogErr("Error creating working file: %s", err)
44
utilities.ExitSafely()
45
}
46
workingFileX.Close()
47
lockedFileX, err := os.Create(fmt.Sprintf(`%s/locked.txt`, path))
48
if err != nil {
49
utilities.LogErr("Error creating locked file: %s", err)
50
utilities.ExitSafely()
51
}
52
lockedFileX.Close()
53
uncheckedFileX, err := os.Create(fmt.Sprintf(`%s/unchecked.txt`, path))
54
if err != nil {
55
utilities.LogErr("Error creating unchecked file: %s", err)
56
utilities.ExitSafely()
57
}
58
uncheckedFileX.Close()
59
emailVerifiedFileX, err := os.Create(fmt.Sprintf(`%s/email_verified.txt`, path))
60
if err != nil {
61
utilities.LogErr("Error creating email verified file: %s", err)
62
utilities.ExitSafely()
63
}
64
emailVerifiedFileX.Close()
65
phoneVerifiedFileX, err := os.Create(fmt.Sprintf(`%s/phone_verified.txt`, path))
66
if err != nil {
67
utilities.LogErr("Error creating phone verified file: %s", err)
68
utilities.ExitSafely()
69
}
70
phoneVerifiedFileX.Close()
71
unverifiedFileX, err := os.Create(fmt.Sprintf(`%s/unverified.txt`, path))
72
if err != nil {
73
utilities.LogErr("Error creating unverified file: %s", err)
74
utilities.ExitSafely()
75
}
76
unverifiedFileX.Close()
77
spammerFileX, err := os.Create(fmt.Sprintf(`%s/spammer.txt`, path))
78
if err != nil {
79
utilities.LogErr("Error creating spammer file: %s", err)
80
utilities.ExitSafely()
81
}
82
spammerFileX.Close()
83
quarantinedFileX, err := os.Create(fmt.Sprintf(`%s/quarantined.txt`, path))
84
if err != nil {
85
utilities.LogErr("Error creating quarantined file: %s", err)
86
utilities.ExitSafely()
87
}
88
quarantinedFileX.Close()
89
tokenFile, workingFile, lockedFile, uncheckedFile, emailVerifiedFile, phoneVerifiedFile, unverifiedFile, spammerFile, quarantinedFile = tokenFileX.Name(), workingFileX.Name(), lockedFileX.Name(), uncheckedFileX.Name(), emailVerifiedFileX.Name(), phoneVerifiedFileX.Name(), unverifiedFileX.Name(), spammerFileX.Name(), quarantinedFileX.Name()
90
for i := 0; i < len(instances); i++ {
91
instances[i].WriteInstanceToFile(tokenFile)
92
}
93
}
94
threads := utilities.UserInputInteger("Enter number of threads (0 for maximum):")
95
if threads > len(instances) {
96
threads = len(instances)
97
}
98
if threads == 0 {
99
threads = len(instances)
100
}
101
title := make(chan bool)
102
var validTokens []instance.Instance
103
var valid, invalid, errors int
104
go func() {
105
Out:
106
for {
107
select {
108
case <-title:
109
break Out
110
default:
111
cmd := exec.Command("cmd", "/C", "title", fmt.Sprintf(`DMDGO [%v Unchecked %v Valid %v Invalid %v Errors]`, len(instances)-valid-invalid-errors, valid, invalid, errors))
112
_ = cmd.Run()
113
}
114
115
}
116
}()
117
c := goccm.New(threads)
118
for i := 0; i < len(instances); i++ {
119
c.Wait()
120
go func(i int) {
121
defer c.Done()
122
var printStrings []string
123
// Checking Validity of token & Information
124
r, err := instances[i].CheckTokenNew()
125
if err != nil {
126
if cfg.OtherSettings.Logs {
127
instances[i].WriteInstanceToFile(uncheckedFile)
128
}
129
printStrings = append(printStrings, MakeColoredString("red", "FAILED", " Token %v: %v", i, instances[i].CensorToken()))
130
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Error %v while checking token", err))
131
errors++
132
} else {
133
if r == 200 || r == 204 {
134
if cfg.OtherSettings.Logs {
135
instances[i].WriteInstanceToFile(workingFile)
136
}
137
validTokens = append(validTokens, instances[i])
138
printStrings = append(printStrings, MakeColoredString("green", "WORKING", " Token %v: %v", i, instances[i].CensorToken()))
139
r, info, err := instances[i].AtMe()
140
if err != nil {
141
if cfg.OtherSettings.Logs {
142
instances[i].WriteInstanceToFile(uncheckedFile)
143
}
144
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Error %v while checking token", err))
145
errors++
146
}
147
if r != 200 && r != 204 {
148
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Invalid status code %v while checking token", r))
149
} else {
150
if info.ID != "" {
151
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " ID: %v", info.ID))
152
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Age: %v", utilities.TimeDifference(utilities.ReverseSnowflake(info.ID), time.Now())))
153
if info.Avatar != "" {
154
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Avatar: true"))
155
}
156
if info.Username != "" && info.Discriminator != "" {
157
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Username: %v#%v", info.Username, info.Discriminator))
158
}
159
if info.Flags != 0 {
160
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Flags: %v", info.Flags))
161
}
162
if info.PublicFlags != 0 {
163
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Public Flags: %v", info.PublicFlags))
164
}
165
if info.Flags != 0 {
166
f := info.Flags - info.PublicFlags
167
if f == 17592186044416 {
168
printStrings = append(printStrings, MakeColoredString("red", "QUARANTINED", " Token is QUARANTINED"))
169
if cfg.OtherSettings.Logs {
170
instances[i].WriteInstanceToFile(quarantinedFile)
171
}
172
} else if f == 1048576 {
173
printStrings = append(printStrings, MakeColoredString("red", "SPAMMER", " Token is flagged as spammer"))
174
if cfg.OtherSettings.Logs {
175
instances[i].WriteInstanceToFile(spammerFile)
176
}
177
} else if f == 17592186044416+1048576 {
178
if cfg.OtherSettings.Logs {
179
instances[i].WriteInstanceToFile(spammerFile)
180
}
181
if cfg.OtherSettings.Logs {
182
instances[i].WriteInstanceToFile(quarantinedFile)
183
}
184
printStrings = append(printStrings, MakeColoredString("red", "SPAMMER & QUARANTINED", " Token is flagged as spammer and QUARANTINED"))
185
}
186
}
187
if info.Bio != "" {
188
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Bio: %v", info.Bio))
189
}
190
if info.MFAEnabled {
191
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " 2FA: true"))
192
}
193
if info.Email != "" {
194
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Email: %v", info.Email))
195
}
196
if info.Verified {
197
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Email Verified: true"))
198
if cfg.OtherSettings.Logs {
199
instances[i].WriteInstanceToFile(emailVerifiedFile)
200
}
201
}
202
if !info.Verified && info.Phone == "" {
203
if cfg.OtherSettings.Logs {
204
instances[i].WriteInstanceToFile(unverifiedFile)
205
}
206
}
207
if info.Phone != "" {
208
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Phone Verified: true [%v]", info.Phone))
209
if cfg.OtherSettings.Logs {
210
instances[i].WriteInstanceToFile(phoneVerifiedFile)
211
}
212
} else {
213
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Phone Verified: false"))
214
}
215
// Check Guilds
216
r, guilds, _, err := instances[i].Guilds()
217
if err == nil {
218
if r == 200 || r == 204 {
219
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Guilds: %v", guilds))
220
} else {
221
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Unexpected Response Status Code %v while checking guilds", r))
222
}
223
} else {
224
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Error %v while checking guilds", err))
225
}
226
r, channels, _, err := instances[i].Channels()
227
if err == nil {
228
if r == 200 || r == 204 {
229
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Open DMs: %v", channels))
230
} else {
231
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Unexpected Response Status Code %v while checking channels", r))
232
}
233
} else {
234
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Error %v while checking channels", err))
235
}
236
r, friends, blocked, incoming, outgoing, _, err := instances[i].Relationships()
237
if err == nil {
238
if r == 200 || r == 204 {
239
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Friends: %v", friends))
240
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Blocked: %v", blocked))
241
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Incoming Requests: %v", incoming))
242
printStrings = append(printStrings, MakeColoredString("cyan", "INFO", " Outgoing Requests: %v", outgoing))
243
} else {
244
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Unexpected Response Status Code %v while checking relationships", r))
245
}
246
} else {
247
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Error %v while checking relationships", err))
248
}
249
printStrings = append(printStrings, "===================\n\n")
250
}
251
}
252
253
valid++
254
} else if r == 401 || r == 403 {
255
// Locked/Invalid
256
if cfg.OtherSettings.Logs {
257
instances[i].WriteInstanceToFile(lockedFile)
258
}
259
printStrings = append(printStrings, MakeColoredString("red", "LOCKED", " Token %v: %v", i, instances[i].CensorToken()))
260
invalid++
261
} else {
262
// Invalid StatusCode
263
if cfg.OtherSettings.Logs {
264
instances[i].WriteInstanceToFile(uncheckedFile)
265
}
266
267
errors++
268
printStrings = append(printStrings, MakeColoredString("red", "FAILED", " Token %v: %v", i, instances[i].CensorToken()))
269
printStrings = append(printStrings, MakeColoredString("red", "ERROR", " Unexpected Response Status Code %v while checking token", r))
270
}
271
272
}
273
var e string
274
for x := 0; x < len(printStrings); x++ {
275
e += printStrings[x]
276
}
277
color.Printf(e)
278
279
}(i)
280
}
281
c.WaitAllDone()
282
283
title <- true
284
var validTokenStrings []string
285
for i := 0; i < len(validTokens); i++ {
286
if validTokens[i].Password != "" && validTokens[i].Email != "" {
287
validTokenStrings = append(validTokenStrings, fmt.Sprintf("%v:%v:%v", validTokens[i].Email, validTokens[i].Password, validTokens[i].Token))
288
} else {
289
validTokenStrings = append(validTokenStrings, validTokens[i].Token)
290
}
291
}
292
utilities.TruncateLines("tokens.txt", validTokenStrings)
293
utilities.LogSuccess("All Done!")
294
}
295
296
func MakeColoredString(color, title, format string, args ...interface{}) string {
297
return fmt.Sprintf("<fg=white>[</><fg=%v;op=bold>%v</><fg=white>]</>%s\n", color, title, fmt.Sprintf(format, args...))
298
}
299
300