Skip to content

Commit

Permalink
Add duplicate code detection and custom status
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedza committed Jan 9, 2021
1 parent 0670170 commit ac0486f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Edit `settings.json`
],
"nitro_max": 2, // Maxi Nitro before cooldown
"cooldown": 24, // in Hour
"main_status": "", // online, offline, idle, dnd, invisible
"alts_status": "", // online, offline, idle, dnd, invisible
"giveaway_sniper": true // Enable or not giveaway joiner
"nitro_giveaway_sniper": true, // Only join Nitro gieaways
"giveaway_dm": "Hey, I won a giveaway !", // DM sent to giveaway host, leave empty to not send any dm
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.14

require (
github.com/bwmarrin/discordgo v0.22.0
github.com/dgraph-io/ristretto v0.0.3
github.com/fatih/color v1.9.0
github.com/valyala/fasthttp v1.16.0
)
9 changes: 6 additions & 3 deletions settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"main_token": "",
"alts_tokens": [],
"alts_tokens": [
""
],
"nitro_max": 2,
"cooldown": 24,
"giveaway_sniper": true,
"main_status": "",
"alts_status": "invisible",
"nitro_giveaway_sniper": true,
"giveaway_dm": "",
"privnote_sniper": true,
Expand All @@ -12,7 +16,6 @@
"good_only": false
},
"blacklist_servers": [
"",
""
]
}
}
45 changes: 34 additions & 11 deletions sniper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"github.com/bwmarrin/discordgo"
"github.com/dgraph-io/ristretto"
"github.com/fatih/color"
"github.com/valyala/fasthttp"
"io/ioutil"
Expand All @@ -28,6 +29,8 @@ type Settings struct {
AltsTokens []string `json:"alts_tokens"`
NitroMax int `json:"nitro_max"`
Cooldown int `json:"cooldown"`
MainStatus string `json:"main_status"`
AltsStatus string `json:"alts_status"`
GiveawaySniper bool `json:"giveaway_sniper"`
PrivnoteSniper bool `json:"privnote_sniper"`
NitroGiveawaySniper bool `json:"nitro_giveaway_sniper"`
Expand All @@ -45,11 +48,16 @@ type Response struct {
}

var (
paymentSourceID string
NitroSniped int
SniperRunning bool
settings Settings
nbServers int
paymentSourceID string
NitroSniped int
SniperRunning bool
settings Settings
nbServers int
cache, _ = ristretto.NewCache(&ristretto.Config{
NumCounters: 1e7,
MaxCost: 1 << 30,
BufferItems: 64,
})
re = 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": "(.*)",`)
Expand Down Expand Up @@ -184,6 +192,7 @@ func init() {
_, _ = fmt.Fprintf(os.Stderr, "Failed to parse JSON file: %s\n", err)
os.Exit(1)
}

NitroSniped = 0
SniperRunning = true
}
Expand All @@ -205,12 +214,14 @@ func run(token string, finished chan bool, index int) {
} else {
nbServers += len(dg.State.Guilds)
dg.AddHandler(messageCreate)
if settings.AltsStatus != "" {
_, _ = dg.UserUpdateStatus(discordgo.Status(settings.AltsStatus))
}
}
}
if index == len(settings.AltsTokens)-1 {
finished <- true
}

}

func deleteEmpty(s []string) []string {
Expand Down Expand Up @@ -249,6 +260,10 @@ func main() {

dg.AddHandler(messageCreate)

if settings.MainStatus != "" {
_, _ = dg.UserUpdateStatus(discordgo.Status(settings.MainStatus))
}

if len(settings.AltsTokens) != 0 {
<-finished
}
Expand Down Expand Up @@ -282,7 +297,7 @@ func main() {
} else if settings.PrivnoteSniper == true {
_, _ = cyan.Print(" and Privnote")
}
_, _ = cyan.Print(" on " + strconv.Itoa(nbServers) + " servers and " + strconv.Itoa(len(settings.AltsTokens)+1) + " accounts 🔫\n\n")
_, _ = cyan.Print(" for " + dg.State.User.Username + " on " + strconv.Itoa(nbServers) + " servers and " + strconv.Itoa(len(settings.AltsTokens)+1) + " accounts 🔫\n\n")

_, _ = magenta.Print(t.Format("15:04:05 "))
fmt.Println("[+] Sniper is ready")
Expand All @@ -297,7 +312,6 @@ func main() {
func checkCode(bodyString string, code string, sender string) {

var response Response

err := json.Unmarshal([]byte(bodyString), &response)

if err != nil {
Expand Down Expand Up @@ -326,6 +340,7 @@ func checkCode(bodyString string, code string, sender string) {
color.Yellow("[?] " + response.Message)
webhook("Nitro Sniped", code, response.Message, sender, "16744975")
}
cache.Set(code, "", 1)

}

Expand All @@ -350,6 +365,16 @@ func checkGiftLink(s *discordgo.Session, m *discordgo.MessageCreate, link string
fmt.Println(" from " + m.Author.String())
return
}

_, found := cache.Get(code[2])
if found {
_, _ = magenta.Print(time.Now().Format("15:04:05 "))
_, _ = red.Print("[=] Auto-detected a duplicate code: ")
_, _ = red.Print(code[2])
fmt.Println(" from " + m.Author.String())
return
}

var strRequestURI = []byte("https://discordapp.com/api/v8/entitlements/gift-codes/" + code[2] + "/redeem")
req := fasthttp.AcquireRequest()
req.Header.SetContentType("application/json")
Expand Down Expand Up @@ -546,7 +571,6 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {

body := res.Body()

println(string(body))
if !rePrivnoteData.Match(body) {
_, _ = magenta.Print(time.Now().Format("15:04:05 "))
_, _ = red.Println("[x] Privnote already destroyed")
Expand Down Expand Up @@ -594,9 +618,8 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
}

_, _ = magenta.Print(time.Now().Format("15:04:05 "))
webhook(s.State.User.Username+" Sniped Privnote", clean, "`"+cryptData+"`", guild.Name+" > "+channel.Name, "2948879")
_, _ = yellow.Print("[-] Wrote the content of the privnote to privnotes.txt")
}

}

}

0 comments on commit ac0486f

Please sign in to comment.