package main
import (
"crypto/md5"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"net/url"
"os"
"strings"
"sync"
"time"
"github.com/PuerkitoBio/goquery"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func randSeq(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}
func byteContentToObj(content []byte, v interface{}) {
err := json.Unmarshal(content, &v)
if err != nil {
log.Println(string(content))
panic(err)
}
}
type OwnMail struct {
Login string
Domain string
Password string
}
func (o OwnMail) ToString() string {
return fmt.Sprintf("%s@%s;%s", o.Login, o.Domain, o.Password)
}
func GetMD5Hash(text string) string {
hash := md5.Sum([]byte(text))
return hex.EncodeToString(hash[:])
}
func generateMails(count int) []OwnMail {
mailList := []OwnMail{}
var ml []string
resp, err := http.Get(fmt.Sprintf("https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=%d", count))
if err != nil {
panic(err)
}
bc, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
byteContentToObj(bc, &ml)
for _, ma := range ml {
split := strings.Split(ma, "@")
mailList = append(mailList, OwnMail{
Login: split[0],
Domain: split[1],
Password: fmt.Sprintf("%s!", randSeq(7)),
})
}
return mailList
}
type TempMailMessageShort struct {
ID int `json:"id"`
From string `json:"from"`
Subject string `json:"subject"`
Date string `json:"date"`
}
type TempMailMessageExtended struct {
ID int `json:"id"`
From string `json:"from"`
Subject string `json:"subject"`
Date string `json:"date"`
Attachments []struct {
Filename string `json:"filename"`
ContentType string `json:"contentType"`
Size int `json:"size"`
} `json:"attachments"`
Body string `json:"body"`
TextBody string `json:"textBody"`
HTMLBody string `json:"htmlBody"`
}
func (o OwnMail) getLetter() string {
var v []TempMailMessageShort
url := fmt.Sprintf("https://www.1secmail.com/api/v1/?action=getMessages&login=%s&domain=%s", o.Login, o.Domain)
resp, err := http.Get(url)
if err != nil {
panic(err)
}
bc, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
byteContentToObj(bc, &v)
if len(v) > 0 {
desc := v[0]
var x TempMailMessageExtended
resp, err := http.Get(fmt.Sprintf("https://www.1secmail.com/api/v1/?action=readMessage&login=%s&domain=%s&id=%d", o.Login, o.Domain, desc.ID))
if err != nil {
panic(err)
}
bc, err = ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
byteContentToObj(bc, &x)
return x.Body
}
return ""
}
func (o OwnMail) RegOnMyGames() bool {
client := http.Client{}
form := url.Values{}
form.Add("csrfmiddlewaretoken_jwt", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidmxhZHlzbGF2LmtoaXNtYXR1bGluQGJrLnJ1In0.M3U8lyJ3ODGo-P79tGbHOadsW8Pb2te4fbVwAuNbm2I")
form.Add("client_id", "")
form.Add("continue", "https://auth-ac.my.games/sdc?from=https%3A%2F%2Fapi.my.games%2Fgamecenter%2Flogin_tracking%2F")
form.Add("lang", "ru_RU")
form.Add("adId", "0")
form.Add("method", "email")
form.Add("verification_continue", "https://account.my.games/email_verify/?ok=1")
form.Add("verification_letter_id", "2724")
form.Set("email", fmt.Sprintf("%s@%s", o.Login, o.Domain))
form.Set("password", o.Password)
req, err := http.NewRequest("POST", "https://account.my.games/signup_email/", strings.NewReader(form.Encode()))
if err != nil {
panic(err)
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
bc, _ := ioutil.ReadAll(resp.Body)
var v map[string]interface{}
byteContentToObj(bc, &v)
if v["status"] != nil && v["status"].(string) == "fail" {
bc, err = json.Marshal(v["body"])
if err != nil {
panic(err)
}
var vb map[string]interface{}
json.Unmarshal(bc, &vb)
if vb["timeout"] != nil && vb["timeout"].(float64) > 0 {
time.Sleep(time.Duration(vb["timeout"].(float64)) * time.Second)
return o.RegOnMyGames()
} else {
time.Sleep(10 * time.Second)
return o.RegOnMyGames()
}
}
return true
}
func (o OwnMail) ActivateMyGames() {
txt := ""
for txt == "" {
time.Sleep(1 * time.Second)
txt = o.getLetter()
}
doc, err := goquery.NewDocumentFromReader(strings.NewReader(txt))
if err != nil {
panic(err)
}
activateBtn := doc.Find(".btn__inner")
v, x := activateBtn.Attr("href")
if x {
http.Get(v)
} else {
o.ActivateMyGames()
}
}
func w2file(mailList []OwnMail, filename string) {
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
panic(err)
}
defer f.Close()
wg := sync.WaitGroup{}
for _, v := range mailList {
wg.Add(1)
go func(v OwnMail) {
defer wg.Done()
v.RegOnMyGames()
v.ActivateMyGames()
if _, err = f.WriteString(fmt.Sprintf("%s\n", v.ToString())); err != nil {
panic(err)
}
}(v)
}
wg.Wait()
}
func main() {
w2file(generateMails(10), fmt.Sprintf("result_%d.txt", time.Now().Unix()))
}