Madmouse

not a trojan :P

Jul 19th, 2015
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.84 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import socket, ssl, time, base64, random, os
  3.  
  4.      
  5. server = "irc.hackthissite.org"
  6. port = 6697
  7. channel = "#hell"
  8.  
  9. # entity lists
  10. noneuter_list = ["madmouse"]
  11. neuter_list = ["kage", "weekend", "#hackthissite", "nickserv", "chanserv", "memoserv"]
  12. dicks = ["test", "_3uph0ny", "stan", "vbaaaa", "knuckle_head", "agro", "linearinterpol", "wisdomewaze"]
  13.  
  14. # conversation
  15. greetings = ["hey", "hi", "hello", "welcome", "hai", "<3"]
  16. slurs = ["Go fuck yourself you conceited bastard ;)", "You sir, are a nigger if you don't mind me saying.", "Shut up whore", "Go die bitch", "Hello :D", "B===D"]
  17.  
  18. # net lists
  19. youtube_list = ["https://www.youtube.com/watch?v=HgunNdurZOI", "https://www.youtube.com/watch?v=8bD3LRxjtJ4"]
  20. code_list = []
  21.  
  22. # dicts
  23. copycats = {}
  24.  
  25. def is_url(url):
  26.     import re
  27.     regex = re.compile(
  28.         r'^https?://'  # http:// or https://
  29.         r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|'  # domain...
  30.         r'localhost|'  # localhost...
  31.         r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
  32.         r'(?::\d+)?'  # optional port
  33.         r'(?:/?|[/?]\S+)$', re.IGNORECASE)
  34.     return url is not None and regex.search(url)
  35.  
  36. def reconnect():
  37.     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  38.     ircsock = ssl.wrap_socket(s)
  39.     ircsock.connect((server, port))
  40.  
  41. def sendmsg(chan , msg):
  42.     ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\r\n")
  43.  
  44. def joinchan(chan):
  45.     ircsock.send("JOIN "+ chan +"\r\n")
  46.  
  47. def hello(person):
  48.     random.seed(time.time())
  49.     sendmsg(person, random.choice(slurs))
  50.  
  51. def copy(nick,chan):
  52.     copycats[nick] = chan
  53.    
  54. def register():
  55.     random.seed(time.time())
  56.     botnick = base64.b64encode(str(time.time()*random.randint(0, 10)))
  57.     botnick = ''.join(random.sample(botnick,len(botnick)))[:5]
  58.     ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :"+botnick+"\r\n")
  59.     ircsock.send("NICK "+ botnick +"\r\n")
  60.  
  61. def quit(msg):
  62.     ircsock.send("QUIT :"+ msg +"\r\n")
  63.  
  64. def bomb(cunt):
  65.     random.seed(time.time())
  66.     sendmsg(cunt, random.choice(slurs))
  67.  
  68. def youtube(person, command, option):
  69.     if command == "add" and option not in youtube_list:
  70.         if not is_url(option):
  71.             return
  72.         youtube_list.insert(0, option)
  73.         with open(os.path.expanduser("~/tools/bot/lists/youtube"), "a") as f:
  74.             f.write(option+'\n')
  75.     elif command == "random":
  76.         random.seed(time.time())
  77.         sendmsg(person, random.choice(youtube_list))
  78.         return
  79.     elif command == "list":
  80.         sendmsg(person, str(youtube_list))
  81.  
  82. def code(person, command, option):
  83.     if command == "add" and option not in code_list:
  84.         if not is_url(option):
  85.             return
  86.         code_list.insert(0, option)
  87.         with open(os.path.expanduser("~/tools/bot/lists/code"), "a") as f:
  88.             f.write(option+'\n')
  89.     elif command == "random":
  90.         random.seed(time.time())
  91.         sendmsg(person, random.choice(code_list))
  92.         return
  93.     elif command == "list":
  94.         sendmsg(person, str(code_list))
  95.  
  96. def slur(person, command, option):
  97.     if command == "add" and option not in slurs:
  98.         slurs.insert(0, option)
  99.         with open(os.path.expanduser("~/tools/bot/lists/slurs"), "a") as f:
  100.             f.write(option+'\n')
  101.     elif command == "random":
  102.         random.seed(time.time())
  103.         sendmsg(person, random.choice(slurs))
  104.         return
  105.     elif command == "list":
  106.         sendmsg(person, str(slurs))
  107.  
  108.  
  109. # load files
  110. with open(os.path.expanduser("~/tools/bot/lists/youtube")) as f:
  111.     youtube_list = youtube_list + [line.rstrip('\n') for line in f]
  112.  
  113. with open(os.path.expanduser("~/tools/bot/lists/code")) as f:
  114.     code_list = code_list + [line.rstrip('\n') for line in f]
  115.  
  116. with open(os.path.expanduser("~/tools/bot/lists/neuter")) as f:
  117.     neuter_list = neuter_list + [line.rstrip('\n') for line in f]
  118.  
  119. with open(os.path.expanduser("~/tools/bot/lists/noneuter")) as f:
  120.     noneuter_list = noneuter_list + [line.rstrip('\n') for line in f]
  121.  
  122. with open(os.path.expanduser("~/tools/bot/lists/slurs")) as f:
  123.     slurs = slurs + [line.rstrip('\n') for line in f]
  124.  
  125.  
  126. # connect to irc
  127. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  128. ircsock = ssl.wrap_socket(s)
  129. ircsock.connect((server, port))
  130. register()
  131. while 1:
  132.     ircmsg = ircsock.recv(2048)
  133.     if len(ircmsg) == 0:
  134.         ircsock.close()
  135.         time.sleep(3)
  136.         reconnect()
  137.         register()
  138.         continue
  139.     if ircmsg.find("PING ") != -1:
  140.         x = ircmsg.find("PING ")
  141.         ircmsg = ircmsg[x:]
  142.         y = ircmsg.find("\r\n")
  143.         ircsock.send("PONG "+ircmsg[6:y+2])
  144.         print("PONG "+ircmsg[6:y])
  145.         joinchan(channel)
  146.         continue
  147.     command = ircmsg.split()
  148.     print(command)
  149.  
  150.     try:
  151.         if command[1] == "432":
  152.             register()
  153.             continue
  154.         elif command[1] == "451" or command[1] == "001":
  155.             joinchan(channel)
  156.             continue
  157.     # special actions
  158.         elif command[0].split("!")[0][1:].lower() in neuter_list:
  159.             continue
  160.         elif command[0].split("!")[0][1:].lower() in dicks or command[2].lower() in dicks:
  161.             bomb(command[2])
  162.             continue
  163.         # commands
  164.         keyword = command[3].translate(None, ":").lower()
  165.         if keyword in greetings:
  166.             hello(command[2])
  167.             continue
  168.         if len(command) >= 5 and command[4].lower() in neuter_list:
  169.             sendmsg(command[2], "This entity is neuter_listed, give up.")
  170.             continue
  171.         elif keyword == "@youtube":
  172.            if len(command) == 6:
  173.               youtube(command[2], command[4], command[5])
  174.            elif len(command) == 5:
  175.               youtube(command[2], command[4], 0)
  176.            continue
  177.         elif keyword == "@slur":
  178.            if len(command) >= 6:
  179.               slur(command[2], command[4], " ".join(command[5:]))
  180.            elif len(command) == 5:
  181.               slur(command[2], command[4], 0)
  182.            continue
  183.  
  184.         elif keyword == "@code":
  185.            if len(command) == 6:
  186.               code(command[2], command[4], command[5])
  187.            elif len(command) == 5:
  188.               code(command[2], command[4], 0)
  189.            continue
  190.         elif keyword == "@join":
  191.             joinchan(command[4])
  192.             continue
  193.         elif keyword == "@penis" and command[4].lower() not in noneuter_list:
  194.             dicks.insert(0, command[4].lower())
  195.             sendmsg(command[2], str(dicks))
  196.             continue
  197.         elif keyword == "@rpenis":
  198.             dicks.remove(command[4].lower())
  199.             sendmsg(command[2], str(dicks))
  200.             continue
  201.         elif keyword == "@neuter" and command[4].lower() not in noneuter_list and command[4].lower() not in neuter_list:
  202.             with open(os.path.expanduser("~/tools/bot/lists/neuter"), "a") as f:
  203.                 f.write(command[4].lower()+'\n')
  204.             neuter_list.insert(0, command[4].lower())
  205.             sendmsg(command[2], str(neuter_list))
  206.             continue
  207.         elif keyword == "@noneuter" and command[4].lower() not in noneuter_list:
  208.             with open(os.path.expanduser("~/tools/bot/lists/noneuter"), "a") as f:
  209.                 f.write(command[4].lower()+'\n')
  210.             noneuter_list.insert(0, command[4].lower())
  211.             sendmsg(command[2], str(noneuter_list))
  212.             continue
  213.         elif keyword == "@say":
  214.             sendmsg(command[4],' '.join(command[5:]))
  215.             continue
  216.         elif keyword == "@copy":
  217.             if command[5].lower() in neuter_list:
  218.                 sendmsg(command[2], "This entity is neuter_listed, give up.")
  219.                 continue
  220.             else:
  221.                 copy(command[4].lower(), command[5].lower())
  222.                 sendmsg(command[2], str(copycats))
  223.                 continue
  224.         elif keyword == "@rcopy":
  225.             del copycats[command[4].lower()]
  226.             continue
  227.         elif keyword == "@nick":
  228.             botnick = command[4]
  229.             ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :"+botnick+"\r\n")
  230.             ircsock.send("NICK "+ botnick +"\r\n")
  231.             continue
  232.         elif keyword == "@renew":
  233.             register()
  234.             continue
  235.         elif keyword == "@bomb":
  236.             bomb(command[4])
  237.             continue
  238.         elif keyword == "@sepuku":
  239.             if len(command) >= 5:
  240.                 quit(' '.join(command[4:]))
  241.                 exit(0)
  242.             else:
  243.                 quit("bye")
  244.                 exit(0)
  245.         elif command[0].split("!")[0][1:].lower() in copycats:
  246.             sendmsg(copycats[command[0].split("!")[0][1:]], command[3][1:]+" "+" ".join(command[4:]))
  247.         elif command[2].lower() in copycats:
  248.             sendmsg(copycats[command[2]], command[3][1:]+" "+" ".join(command[4:]))
  249.  
  250.     except:
  251.         print("I make a pop poo\r\n")
Add Comment
Please, Sign In to add comment