Initial commit
This commit is contained in:
163
tasks/mega-account.go
Normal file
163
tasks/mega-account.go
Normal file
@@ -0,0 +1,163 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MegaAccountTask struct{}
|
||||
|
||||
// jim
|
||||
// fnkezq4o3a@zudpck.com
|
||||
// 7xIz9GqR1CRvRpLv
|
||||
|
||||
func (t *MegaAccountTask) Run() error {
|
||||
firstName, lastName, err := t.getRandomName()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("First Name:", firstName)
|
||||
fmt.Println("Last Name:", lastName)
|
||||
|
||||
pwd, err := t.getRandomPassword()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Password:", pwd)
|
||||
|
||||
tempMail, err := t.createTempMail()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Temp Mail:", tempMail)
|
||||
|
||||
verificationLink, err := t.getVerificationLink(tempMail)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Verification Link:", verificationLink)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *MegaAccountTask) getRandomName() (string, string, error) {
|
||||
apiUrl := "https://randomuser.me/api/"
|
||||
resp, err := http.Get(apiUrl)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var jsonData struct {
|
||||
Results []struct {
|
||||
Name struct {
|
||||
Title string `json:"title"`
|
||||
First string `json:"first"`
|
||||
Last string `json:"last"`
|
||||
} `json:"name"`
|
||||
} `json:"results"`
|
||||
}
|
||||
|
||||
if err := json.NewDecoder(resp.Body).Decode(&jsonData); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return jsonData.Results[0].Name.First, jsonData.Results[0].Name.Last, nil
|
||||
}
|
||||
|
||||
func (t *MegaAccountTask) getRandomPassword() (string, error) {
|
||||
apiUrl := "https://passwordwolf.com/api/?special=off&length=16&repeat=1"
|
||||
resp, err := http.Get(apiUrl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var jsonData []struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
if err := json.NewDecoder(resp.Body).Decode(&jsonData); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return jsonData[0].Password, nil
|
||||
}
|
||||
|
||||
func (t *MegaAccountTask) createTempMail() (string, error) {
|
||||
url := "https://api.internal.temp-mail.io/api/v3/email/new"
|
||||
data := map[string]int{
|
||||
"min_name_length": 10,
|
||||
"max_name_length": 10,
|
||||
}
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var rawEmail map[string]interface{}
|
||||
if err := json.Unmarshal(body, &rawEmail); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return rawEmail["email"].(string), nil
|
||||
}
|
||||
|
||||
func (t *MegaAccountTask) getVerificationLink(email string) (string, error) {
|
||||
url := fmt.Sprintf("https://api.internal.temp-mail.io/api/v3/email/%s/messages", email)
|
||||
|
||||
fmt.Println("Waiting for verification link...")
|
||||
for {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var emails []struct {
|
||||
Id string `json:"id"`
|
||||
From string `json:"from"`
|
||||
Subject string `json:"subject"`
|
||||
BodyText string `json:"body_text"`
|
||||
BodyHTML string `json:"body_html"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &emails); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(emails) == 0 {
|
||||
// Retry
|
||||
time.Sleep(10 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
emailText := emails[0].BodyText
|
||||
reg := regexp.MustCompile(`(https:\/\/mega.nz\/#[a-zA-Z0-9\-_]+)`)
|
||||
matches := reg.FindStringSubmatch(emailText)
|
||||
if len(matches) < 2 {
|
||||
return "", fmt.Errorf("verification link not found in email")
|
||||
}
|
||||
|
||||
return matches[1], nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user