Пример #1
0
Файл: main.go Проект: hako/ghost
// generateAccount creates a new Snapchat account based on Snapchat's registration requirements.
// NOTE: This will save sensitive credentials. Use with caution.
func generateAccount(gmail, gpassword, key, secret string) *GeneratedSCAccount {
	genSnapchatAccount := &GeneratedSCAccount{
		CasperAPIKey:    key,
		CasperAPISecret: secret,
	}

	fakedate := faker.Date().Birthday(13, 34).Format("2006-01-02")
	age, err := ghost.CalculateAge(fakedate)
	if err != nil {
		fmt.Println(err)
	}

	genSnapchatAccount.Username = faker.Internet().UserName() + faker.Number().Hexadecimal(4)
	genSnapchatAccount.Email = faker.Internet().Email()
	genSnapchatAccount.Age = age
	genSnapchatAccount.Password = faker.Internet().Password(10, 20)
	genSnapchatAccount.Gmail = gmail
	genSnapchatAccount.Birthday = fakedate
	genSnapchatAccount.GmailPassword = gpassword

	return genSnapchatAccount
}
Пример #2
0
Файл: main.go Проект: hako/ghost
// manualSetup is a function to manually setup a Snapchat account.
func manualSetup(opts map[string]interface{}) (string, error) {
	var uncheckedMap map[string]string

	// Show the fancy notice graphic.
	fmt.Println(notice)

	rl, err := readline.NewEx(&readline.Config{
		AutoComplete: autocompleter,
	})
	if err != nil {
		return "", err
	}

	// Enter your desired username.
	rl.SetPrompt("Enter your desired Snapchat username: "******"", errors.New("Cancelled.")
	}

	// Enter your desired password.
	password, err := enterPassword("Enter your desired Snapchat password: "******"", errors.New("Cancelled.")
	}

	// Enter your email address.
	rl.SetPrompt("Enter your email address: ")
	email, err := rl.Readline()
	if err != nil {
		return "", errors.New("Cancelled.")
	}

	// Enter your birthday.
	rl.SetPrompt("Enter your birthday (YYYY-MM-DD): ")
	birthday, err := rl.Readline()
	if err != nil {
		return "", errors.New("Cancelled.")
	}

	age, err := ghost.CalculateAge(birthday)
	if err != nil {
		return "", errors.New("Sorry! " + "\"" + birthday + "\"" + " is not a valid birthday date!")
	}

	// Enter your Gmail address.
	rl.SetPrompt("Enter your Gmail address: ")
	gmail, err := rl.Readline()
	if err != nil {
		return "", errors.New("Cancelled.")
	}

	// Enter your Gmail password.
	gmailPassword, err := enterPassword("Enter your Gmail password: "******"", errors.New("Cancelled.")
	}

	// Enter your Casper API Key.
	rl.SetPrompt("Enter your Casper API Key: ")
	casperAPIKey, err := rl.Readline()
	if err != nil {
		return "", errors.New("Cancelled.")
	}

	// Enter your Casper API Secret.
	rl.SetPrompt("Enter your Casper API Secret: ")
	casperAPISecret, err := rl.Readline()
	if err != nil {
		return "", errors.New("Cancelled.")
	}

	// Unchecked setup map.
	uncheckedMap = map[string]string{
		"username":          username,
		"password":          password,
		"email":             email,
		"birthday":          birthday,
		"age":               age,
		"gmail":             gmail,
		"gmail_password":    gmailPassword,
		"casper_api_key":    casperAPIKey,
		"casper_api_secret": casperAPISecret,
	}

	// Check the setup map.
	checkedMap, checkedMapErr := checkKeys(uncheckedMap)
	if checkedMapErr != nil {
		return "", checkedMapErr
	}

	// Ask if the user wants to save to file.
	rl.SetPrompt("Registration file will be saved as " + checkedMap["username"] + ".json. Continue? [ Y / N ] ")
	var choice string
	for {
		decision, err := rl.Readline()
		if err != nil {
			return "", err
		}
		checkChoice, err := checkYesNo(decision)
		if err != nil {
			fmt.Println(err)
		} else {
			choice = checkChoice
			finalMap = checkedMap
			break
		}
	}

	defer rl.Close()
	return choice, nil
}
Пример #3
0
Файл: main.go Проект: hako/ghost
func main() {
	opts, _ := docopt.Parse(usage, nil, true, "version "+version, false)

	if opts["--debug"] == true || opts["-d"] == true {
		debug = true
	} else {
		debug = false
	}

	if opts["-p"] != nil {
		proxy = opts["-p"].(string)
	} else {
		proxy = ""
	}

	if opts["about"] == true || opts["--about"] == true || opts["-a"] == true {
		fmt.Println("Snapchat Registration CLI " + version + " by Wesley Hill (@hako/@hakobyte)")
		return
	}

	if opts["teehee"] == true {
		fmt.Println("\033[37mteehee!\033[39m")
		return
	}

	if opts["generate"] == true {
		key := opts["<key>"].(string)
		secret := opts["<secret>"].(string)
		gmail := opts["<gmail>"].(string)
		gpassword := opts["<gpassword>"].(string)

		snapchat := generateAccount(gmail, gpassword, key, secret)

		jsonbytes, err := json.Marshal(snapchat)
		if err != nil {
			fmt.Println(err)
		}
		ioutil.WriteFile(snapchat.Username+".json", jsonbytes, 0644)
		fmt.Println("Generated account \"" + snapchat.Username + "\" and saved to " + snapchat.Username + ".json")
		return
	}

	if opts["-f"] != nil {
		filename := opts["-f"].(string)

		b, err := ioutil.ReadFile(filename)
		if err != nil {
			fmt.Println("Unable to parse the given file.")
			os.Exit(1)
		}

		if err := json.Unmarshal(b, &data); err != nil {
			fmt.Println("Unable to parse the given file.")
			os.Exit(1)
		}

		finalMap = map[string]string{
			"username":          data.Username,
			"password":          data.Password,
			"email":             data.Email,
			"birthday":          data.Birthday,
			"age":               data.Age,
			"gmail":             data.Gmail,
			"gmail_password":    data.GmailPassword,
			"casper_api_key":    data.CasperAPIKey,
			"casper_api_secret": data.CasperAPISecret,
		}
		registerAccount(opts)
	} else if opts["-i"] == true {
		// CLI input setup.
		age, err := ghost.CalculateAge(opts["<birthday>"].(string))
		if err != nil {
			fmt.Println(errors.New("[ X ] Sorry! " + "\"" + opts["<birthday>"].(string) + "\"" + " is not a valid birthday date!"))
			os.Exit(1)
		}
		uncheckedMap := map[string]string{
			"username":          opts["<username>"].(string),
			"password":          opts["<password>"].(string),
			"email":             opts["<email>"].(string),
			"birthday":          opts["<birthday>"].(string),
			"age":               age,
			"gmail":             opts["<gmail>"].(string),
			"gmail_password":    opts["<gpassword>"].(string),
			"casper_api_key":    opts["<key>"].(string),
			"casper_api_secret": opts["<secret>"].(string),
		}
		// Check the uncheckedMap, (Just in case.)
		checkedMap, err := checkKeys(uncheckedMap)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		finalMap = checkedMap
		registerAccount(opts)
	} else {
		// Manual setup.
		choice, err := manualSetup(opts)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		// TODO decouple huge if statement. WTH
		if choice == "Y" {
			var verificationOption string

			data.Username = finalMap["username"]
			data.Password = finalMap["password"]
			data.Email = finalMap["email"]
			data.Birthday = finalMap["birthday"]
			data.Age = finalMap["age"]
			data.Gmail = finalMap["gmail"]
			data.GmailPassword = finalMap["gmail_password"]
			data.CasperAPIKey = finalMap["casper_api_key"]
			data.CasperAPISecret = finalMap["casper_api_secret"]

			jsonbytes, err := json.MarshalIndent(data, "", " ")
			if err != nil {
				fmt.Println(err)
				os.Exit(1)
			}
			ioutil.WriteFile(data.Username+".json", jsonbytes, 0644)
			fmt.Println("Account \"" + data.Username + "\" and saved to " + data.Username + ".json")

			rl, err := readline.NewEx(&readline.Config{
				AutoComplete: autocompleter,
			})

			fmt.Println(string(jsonbytes))

			// Get the registration option.
			if opts["--captcha"] == true {
				verificationOption = "This is your registration data. Register now with captcha verification? [Y / N] "
			}
			if opts["--phone"] == true {
				verificationOption = "This is your registration data. Register now with phone verification? [Y / N] "
			}

			rl.SetPrompt(verificationOption)

			if err != nil {
				fmt.Println(err)
				os.Exit(1)
			}

			var regChoice string
			for {
				decision, err := rl.Readline()
				if err != nil {
					fmt.Println(err)
				}
				checkChoice, err := checkYesNo(decision)
				if err != nil {
					fmt.Println(err)
				} else {
					regChoice = checkChoice
					break
				}
			}

			defer rl.Close()

			if regChoice == "Y" {
				registerAccount(opts)
			} else {
				fmt.Println("You can register later using srcli register -f " + data.Username + ".json" + " --captcha | --phone=<number>")
				return
			}

		} else {
			fmt.Println("Cancelled.")
			os.Exit(0)
		}
	}
}