aws_playground- experiments in aws with terraform |
git clone git://git.acid.vegas/aws_playground.git |
Log | Files | Refs | Archive | README |
lambda_function.py (1228B)
1 #!/usr/bin/env python 2 import random,socket,ssl,time 3 def lambda_handler(event, context): 4 def raw(msg) : sock.send(bytes(msg + '\r\n', 'utf-8')) 5 def rnd(size): return ''.join(random.choices('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789', k=size)) 6 sock = ssl.wrap_socket(socket.socket()) 7 sock.connect(('irc.supernets.org', 6697)) 8 raw(f'USER {rnd(5)} 0 * :' + rnd(5)) 9 raw('NICK ' + rnd(5)) 10 while True: 11 try: 12 data = sock.recv(1024).decode('utf-8') 13 for line in (line for line in data.split('\r\n') if len(line.split()) >= 2): 14 args = line.split() 15 if args[0] == 'PING' : raw('PONG ' + args[1][1:]) 16 elif args[1] == '001': 17 time.sleep(3) 18 raw('JOIN #dev') 19 elif args[1] == 'PRIVMSG' and len(args) == 4: 20 msg = ' '.join(args[3:])[1:] 21 if msg == '.go': 22 curr = 4096 23 while True: 24 unistr = [chr(item) for item in range(curr,curr+50)] 25 sender = '' 26 for item in unistr: 27 sender = sender + '\x03'+str(random.randint(2,256)) + random.choice(['\x1f','\x02','\x16','']) + item + '\x0f' 28 raw('PRIVMSG #dev :' + sender) 29 curr = random.randint(4096,1114100) 30 time.sleep(0.05) 31 except (UnicodeDecodeError,UnicodeEncodeError): 32 pass