tools

- collection of tools for supernets sysadmins
git clone git://git.acid.vegas/tools.git
Log | Files | Refs | Archive

5000.go (3996B)

      1 package main
      2 
      3 // Original 5000 bot was written in Python. This is a Go port of it by acidvegas.
      4 
      5 import (
      6 	"bufio"
      7 	"crypto/tls"
      8 	"fmt"
      9 	"log"
     10 	"math/rand"
     11 	"strings"
     12 	"time"
     13 	"unicode/utf16"
     14 )
     15 
     16 var sendChannel chan<- string
     17 
     18 const (
     19 	nickname = "FUCKYOU"
     20 	username = "5000"
     21 	realname = "\x0304THROWN INTO THE FUCKING WALL\x0f"
     22 )
     23 
     24 func randomASCIIString(n int) string {
     25 	const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
     26 	b := make([]byte, n)
     27 	for i := range b {
     28 		b[i] = charset[rand.Intn(len(charset))]
     29 	}
     30 	return string(b)
     31 }
     32 
     33 func unicodeString() string {
     34 	msg := "\u202e\u0007\x03" + fmt.Sprintf("%d", rand.Intn(12)+2)
     35 	for i := 0; i < rand.Intn(101)+200; i++ {
     36 		r := rand.Intn(0x2001) + 0x1000
     37 		if r < 0x10000 {
     38 			msg += string(rune(r))
     39 		} else {
     40 			r -= 0x10000
     41 			msg += string(utf16.DecodeRune(rune(r>>10+0xD800), rune(r&0x3FF+0xDC00)))
     42 		}
     43 	}
     44 	return msg
     45 }
     46 
     47 func attack(target string) {
     48 	sendChannel <- fmt.Sprintf("PRIVMSG #superbowl :I am fucking the shit out of %s right now...", target)
     49 	for i := 0; i < 200; i++ {
     50 		var channels []string
     51 		for i := 0; i < 25; i++ {
     52 			channelName := "#" + randomASCIIString(5)
     53 			channels = append(channels, channelName)
     54 		}
     55 		result := strings.Join(channels, ",")
     56 		sendChannel <- fmt.Sprintf("SAJOIN %s #%s", target, result)
     57 		sendChannel <- fmt.Sprintf("PRIVMSG #5000 :%s oh god %s what is happening %s", unicodeString(), target, unicodeString())
     58 		sendChannel <- fmt.Sprintf("PRIVMSG %s :%s oh god %s what is happening %s", target, unicodeString(), target, unicodeString())
     59 	}
     60 }
     61 
     62 func main() {
     63 	rand.Seed(time.Now().UnixNano())
     64 
     65 	for {
     66 		conn, err := tls.Dial("tcp", "localhost:6697", &tls.Config{InsecureSkipVerify: true})
     67 		if err != nil {
     68 			log.Println("Failed to connect: %v", err)
     69 			time.Sleep(15 * time.Second)
     70 			continue
     71 		}
     72 
     73 		messageChannel := make(chan string, 100) // INCOMING
     74 		sendChannel := make(chan string, 100)    // OUTGOING
     75 		quit := make(chan struct{})
     76 
     77 		timeoutDuration := 300 * time.Second
     78 		timeoutTimer := time.NewTimer(timeoutDuration)
     79 
     80 		go func() {
     81 			reader := bufio.NewReader(conn)
     82 			for {
     83 				line, err := reader.ReadString('\n')
     84 				if err != nil {
     85 					log.Println("Error reading from server:", err)
     86 					conn.Close()
     87 					close(quit)
     88 					return
     89 				}
     90 				select {
     91 				case messageChannel <- line:
     92 					timeoutTimer.Reset(timeoutDuration)
     93 				case <-quit:
     94 					return
     95 				case <-timeoutTimer.C:
     96 					log.Println("No data received for 300 seconds. Reconnecting...")
     97 					conn.Close()
     98 					close(quit)
     99 					return
    100 				}
    101 			}
    102 		}()
    103 
    104 		go func() {
    105 			for {
    106 				select {
    107 				case message := <-sendChannel:
    108 					data := []byte(message)
    109 					if len(data) > 510 {
    110 						data = data[:510]
    111 					}
    112 					_, err := conn.Write(append(data, '\r', '\n'))
    113 					if err != nil {
    114 						log.Println("Error writing to server:", err)
    115 						conn.Close()
    116 						close(quit)
    117 						return
    118 					}
    119 				case <-quit:
    120 					return
    121 				}
    122 			}
    123 		}()
    124 
    125 		sendChannel <- fmt.Sprintf("NICK FUCKYOU")
    126 		sendChannel <- fmt.Sprintf("USER 5000 0 * :THROW INTO THE FUCKING WALL")
    127 
    128 		for {
    129 			handleMessage(<-messageChannel, sendChannel)
    130 		}
    131 
    132 		conn.Close()
    133 		//close(quit)
    134 		time.Sleep(15 * time.Second)
    135 	}
    136 }
    137 
    138 func handleMessage(message string, sendChannel chan<- string) {
    139 	fmt.Println(message)
    140 	parts := strings.Split(message, " ")
    141 	if len(parts) > 1 && parts[0] == "PING" {
    142 		sendChannel <- fmt.Sprintf("PONG %s", parts[1])
    143 	} else if len(parts) > 2 && parts[1] == "001" {
    144 		time.Sleep(5 * time.Second)
    145 		sendChannel <- fmt.Sprintf("MODE FUCKYOU +BDd")
    146 		sendChannel <- fmt.Sprintf("PRIVMSG NickServ IDENTIFY FUCKYOU simps0nsfan420")
    147 		sendChannel <- fmt.Sprintf("PRIVMSG OPER FUCKYOU fartsimps0n420")
    148 		sendChannel <- fmt.Sprintf("JOIN #5000")
    149 		sendChannel <- fmt.Sprintf("JOIN #superbowl")
    150 	} else if len(parts) == 3 {
    151 		if parts[1] == "JOIN" && parts[2] == "#5000" {
    152 			nick := strings.Split(parts[0], "!")[0][1:]
    153 			if nick != "acidvegas" && nick != "ChanServ" && nick != "FUCKYOU" {
    154 				go attack(nick)
    155 			}
    156 		}
    157 	}
    158 }