forked from Vedza/NitroSniperGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sniper.go
319 lines (278 loc) · 10.3 KB
/
sniper.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
package main
import (
"encoding/json"
"io/ioutil"
"log"
"os"
"os/exec"
"os/signal"
"regexp"
strconv "strconv"
"strings"
"syscall"
"time"
"github.com/bwmarrin/discordgo"
"github.com/dgraph-io/ristretto"
"github.com/gookit/color"
"github.com/kardianos/osext"
"github.com/valyala/fasthttp"
)
type Settings struct {
Tokens struct {
Main string `json:"main"`
Alts []string `json:"alts"`
} `json:"tokens"`
Status struct {
Main string `json:"main"`
Alts string `json:"alts"`
} `json:"status"`
Nitro struct {
Max int `json:"max"`
Cooldown int `json:"cooldown"`
MainSniper bool `json:"main_sniper"`
Delay bool `json:"delay"`
} `json:"nitro"`
Giveaway struct {
Enable bool `json:"enable"`
Delay int `json:"delay"`
DM string `json:"dm"`
DMDelay int `json:"dm_delay"`
BlacklistWords []string `json:"blacklist_words"`
WhitelistWords []string `json:"whitelist_words"`
BlacklistServers []string `json:"blacklist_servers"`
} `json:"giveaway"`
Invite struct {
Enable bool `json:"enable"`
Delay struct {
Min int `json:"min"`
Max int `json:"max"`
} `json:"delay"`
InviteMax int `json:"max"`
Cooldown int `json:"cooldown"`
} `json:"invite"`
Privnote struct {
Enable bool `json:"enable"`
} `json:"privnote"`
Webhook struct {
URL string `json:"url"`
GoodOnly bool `json:"good_only"`
} `json:"webhook"`
BlacklistServers []string `json:"blacklist_servers"`
}
type Response struct {
Message string `json:"message"`
Code int `json:"code"`
}
var (
paymentSourceID string
currentToken string
NitroSniped int
InviteSniped int
SniperRunning bool
InviteRunning bool
settings Settings
nbServers int
cache, _ = ristretto.NewCache(&ristretto.Config{
NumCounters: 1e7,
MaxCost: 1 << 30,
BufferItems: 64,
})
reGiftLink = regexp.MustCompile("(discord.com/gifts/|discordapp.com/gifts/|discord.gift/)([a-zA-Z0-9]+)")
rePrivnote = regexp.MustCompile("(https://privnote.com/[0-9A-Za-z]+)#([0-9A-Za-z]+)")
rePrivnoteData = regexp.MustCompile(`"data": "(.*)",`)
reInviteServer = regexp.MustCompile(`"name": "(.*)", "splash"`)
reGiveaway = regexp.MustCompile("You won the \\*\\*(.*)\\*\\*")
reGiveawayMessage = regexp.MustCompile("<https://discordapp.com/channels/(.*)/(.*)/(.*)>")
rePaymentSourceId = regexp.MustCompile(`("id": ")([0-9]+)"`)
reInviteLink = regexp.MustCompile("https://discord.gg/([0-9a-zA-Z]+)")
reNitroType = regexp.MustCompile(` "name": "([ a-zA-Z]+)", "features"`)
)
func contains(array []string, value string) bool {
for _, v := range array {
if v == value {
return true
}
}
return false
}
func getPaymentSourceId() {
var strRequestURI = []byte("https://discord.com/api/v8/users/@me/billing/payment-sources")
req := fasthttp.AcquireRequest()
req.Header.Set("authorization", settings.Tokens.Main)
req.Header.SetMethodBytes([]byte("GET"))
req.SetRequestURIBytes(strRequestURI)
res := fasthttp.AcquireResponse()
if err := fasthttp.Do(req, res); err != nil {
return
}
fasthttp.ReleaseRequest(req)
body := res.Body()
id := rePaymentSourceId.FindStringSubmatch(string(body))
if id == nil {
paymentSourceID = "null"
}
if len(id) > 1 {
paymentSourceID = id[2]
}
}
func init() {
executablePath, err := osext.ExecutableFolder()
if err != nil {
log.Fatal("Error: Couldn't determine working directory: " + err.Error())
}
os.Chdir(executablePath)
file, err := ioutil.ReadFile("settings.json")
if err != nil {
fatalWithTime("[x] Failed read file: " + err.Error())
time.Sleep(4 * time.Second)
os.Exit(-1)
}
err = json.Unmarshal(file, &settings)
if err != nil {
fatalWithTime("[x] Failed to parse JSON file: " + err.Error())
time.Sleep(4 * time.Second)
os.Exit(-1)
}
NitroSniped = 0
InviteSniped = 0
SniperRunning = true
InviteRunning = true
}
func timerEnd() {
SniperRunning = true
NitroSniped = 0
logWithTime("<green>[+] Starting Nitro sniping</>")
}
func inviteTimerEnd() {
InviteSniped = 0
InviteRunning = true
logWithTime("<green>[+] Starting Invite sniping</>")
}
func run(token string, finished chan bool, index int) {
currentToken = token
dg, err := discordgo.New(token)
if err != nil {
fatalWithTime("[x] Error creating Discord session for " + token + "," + err.Error())
} else {
err = dg.Open()
if err != nil {
logWithTime("<red>[x] Error opening connection for " + token + "," + err.Error() + "</>")
} else {
nbServers += len(dg.State.Guilds)
dg.AddHandler(messageCreate)
if settings.Status.Alts != "" {
_, _ = dg.UserUpdateStatus(discordgo.Status(settings.Status.Alts))
}
}
}
if index == len(settings.Tokens.Alts)-1 {
finished <- true
}
}
func deleteEmpty(s []string) []string {
var r []string
for _, str := range s {
if str != "" {
r = append(r, str)
}
}
return r
}
func logWithTime(msg string) {
timeStr := time.Now().Format("15:04:05")
color.Println("<magenta>" + timeStr + " </>" + msg)
}
func fatalWithTime(msg string) {
timeStr := time.Now().Format("15:04:05 ")
color.Println("<magenta>" + timeStr + "</><red>" + msg + "</>")
time.Sleep(4 * time.Second)
os.Exit(-1)
}
func main() {
if settings.Tokens.Main == "" {
fatalWithTime("[x] You must put your token in settings.json")
}
finished := make(chan bool)
settings.Tokens.Alts = deleteEmpty(settings.Tokens.Alts)
if len(settings.Tokens.Alts) != 0 {
for i, token := range settings.Tokens.Alts {
go run(token, finished, i)
}
}
var dg *discordgo.Session
var err error
if settings.Nitro.MainSniper {
dg, err = discordgo.New(settings.Tokens.Main)
if err != nil {
fatalWithTime("[x] Error creating Discord session for " + settings.Tokens.Main + "," + err.Error())
time.Sleep(4 * time.Second)
os.Exit(-1)
}
err = dg.Open()
if err != nil {
fatalWithTime("[x] Error opening connection for " + settings.Tokens.Main + "," + err.Error())
time.Sleep(4 * time.Second)
os.Exit(-1)
}
dg.AddHandler(messageCreate)
if settings.Status.Main != "" {
_, _ = dg.UserUpdateStatus(discordgo.Status(settings.Status.Main))
}
nbServers += len(dg.State.Guilds)
}
if len(settings.Tokens.Alts) != 0 {
<-finished
}
c := exec.Command("clear")
c.Stdout = os.Stdout
_ = c.Run()
color.Red.Println(`
▓█████▄ ██▓ ██████ ▄████▄ ▒█████ ██▀███ ▓█████▄ ██████ ███▄ █ ██▓ ██▓███ ▓█████ ██▀███
▒██▀ ██▌▓██▒▒██ ▒ ▒██▀ ▀█ ▒██▒ ██▒▓██ ▒ ██▒▒██▀ ██▌ ▒██ ▒ ██ ▀█ █ ▓██▒▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
░██ █▌▒██▒░ ▓██▄ ▒▓█ ▄ ▒██░ ██▒▓██ ░▄█ ▒░██ █▌ ░ ▓██▄ ▓██ ▀█ ██▒▒██▒▓██░ ██▓▒▒███ ▓██ ░▄█ ▒
░▓█▄ ▌░██░ ▒ ██▒▒▓▓▄ ▄██▒▒██ ██░▒██▀▀█▄ ░▓█▄ ▌ ▒ ██▒▓██▒ ▐▌██▒░██░▒██▄█▓▒ ▒▒▓█ ▄ ▒██▀▀█▄
░▒████▓ ░██░▒██████▒▒▒ ▓███▀ ░░ ████▓▒░░██▓ ▒██▒░▒████▓ ▒██████▒▒▒██░ ▓██░░██░▒██▒ ░ ░░▒████▒░██▓ ▒██▒
▒▒▓ ▒ ░▓ ▒ ▒▓▒ ▒ ░░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒▓ ▒ ▒ ▒▓▒ ▒ ░░ ▒░ ▒ ▒ ░▓ ▒▓▒░ ░ ░░░ ▒░ ░░ ▒▓ ░▒▓░
░ ▒ ▒ ▒ ░░ ░▒ ░ ░ ░ ▒ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ▒ ▒ ░ ░▒ ░ ░░ ░░ ░ ▒░ ▒ ░░▒ ░ ░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░░░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░
`)
getPaymentSourceId()
color.Print("<cyan>Sniping Discord Nitro</>")
if settings.Giveaway.Enable == true && settings.Privnote.Enable == false {
color.Print("<cyan> and Giveaway</>")
} else if settings.Giveaway.Enable == true && settings.Privnote.Enable == true {
color.Print("<cyan>, Giveaway and Privnote</>")
} else if settings.Privnote.Enable == true {
color.Print("<cyan> and Privnote</>")
}
if settings.Nitro.MainSniper {
color.Print("<cyan> for " + dg.State.User.Username + " on " + strconv.Itoa(nbServers) + " servers and " + strconv.Itoa(len(settings.Tokens.Alts)+1) + " accounts 🔫</>\n\n")
} else {
color.Print("v on " + strconv.Itoa(nbServers) + " servers and " + strconv.Itoa(len(settings.Tokens.Alts)) + " accounts 🔫</>\n\n")
}
logWithTime("<magenta>[+] Sniper is ready</>")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
if settings.Nitro.MainSniper {
_ = dg.Close()
}
}
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
if contains(settings.BlacklistServers, m.GuildID) {
return
}
if reGiftLink.Match([]byte(m.Content)) && SniperRunning {
checkGiftLink(s, m, m.Content, time.Now())
} else if settings.Giveaway.Enable && !contains(settings.Giveaway.BlacklistServers, m.GuildID) && (strings.Contains(strings.ToLower(m.Content), "**giveaway**") || (strings.Contains(strings.ToLower(m.Content), "react with") && strings.Contains(strings.ToLower(m.Content), "giveaway"))) && m.Author.Bot {
handleNewGiveaway(s, m)
} else if (strings.Contains(strings.ToLower(m.Content), "giveaway") || strings.Contains(strings.ToLower(m.Content), "win") || strings.Contains(strings.ToLower(m.Content), "won")) && strings.Contains(m.Content, s.State.User.ID) && m.Author.Bot {
handleGiveawayWon(s, m)
} else if rePrivnote.Match([]byte(m.Content)) && settings.Privnote.Enable {
checkPrivnote(s, m)
} else if reInviteLink.Match([]byte(m.Content)) && settings.Invite.Enable {
handleInviteLink(s, m)
}
}