Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- import os
- import re
- import ssl
- import sys
- #import bs4 # apt-get install python3-bs4
- import time
- import json
- import socket
- import string
- import threading
- import subprocess
- #from rottentomatoes import RT
- # Setup the IRC connection
- irc = socket.socket()
- irc = ssl.wrap_socket(irc)
- # List of currently active threads
- threadlist = []
- # Edit these values for your server
- ircServer = "irc.blackcatz.org"
- ircSSLPort = 6697
- ircNick = "[Z]NotifyMaster"
- # What the bot uses as a command character
- ircCKey = ircNick
- # List of channels to connect to
- channelList = ['#howtohack','#bots']
- owner = "eve"
- # Radio link
- radioLink = "https://radio.zempirians.com"
- # Bot help command
- botList = ['[Z]NotifyMaster','Contains basic help command and notifies bot owners when their bot is down','help'
- ,'+[Z]Citadel','Searches for the databases in which your string is found','!email string'
- ,'+[Z]Googler','Searches google with the given string, gives you the top result','[Z]Googler: help'
- ,'+[Z]MEGABOT','Contains multiple helpful commands that didn\'t require their own bot','[Z]MEGABOT: help'
- ,'+[Z]RadioBot','Manages the radio on '+radioLink+'!','[Z]RadioBot: help'
- ,'+[Z]RssFeeder','Automatically posts new articles from websites we are subscribed to','[RssFeeder]: help'
- ,'+[Z]Titler','Automatically pulls the title of links posted in the chat','[Z]Titler: help'
- ,'&Zempire','Administrative bot for the operators','[Z]Zempire: help'
- ]
- rules = ['[Z] represents a bot, +[Z] represents an official bot and & represents an administrative bot.'
- ,'The command \"[Z]BotName: help\" allows you to get the commands of a bot.'
- ,'Don\'t make mom jokes. Only Bulwark\'s mom can get those.'
- ]
- helpList = ['help','Displays the help command of bot and the other general bot commands.'
- ,'radio','Returns the radio link.'
- ,'die','Kills the bot, if your the owner.'
- ]
- def rawSend(data):
- print(data)
- irc.send(str(data + "\r\n").encode())
- def ircConnect():
- irc.connect((ircServer, ircSSLPort))
- def ircMessage(msg, channel):
- rawSend("PRIVMSG " + str(channel) + " :" + str(msg) + "\r\n")
- def ircRegister():
- rawSend("USER " + ircNick + " 0 * " + ":" + ircNick + "\r\n")
- def ircSendNick():
- rawSend("NICK " + ircNick + "\r\n")
- def ircJoin(channel):
- rawSend("JOIN " + channel + "\r\n")
- def ircPassword():
- rawSend("PASS " + ircPass + "\r\n")
- def ircDisconnect(msg):
- rawSend("QUIT " + msg + "\r\n")
- def msgFind(msg, data):
- if bytes(msg,"utf-8") in data:
- return True
- return False
- def msgAnalyze(msg, data):
- if msgFind(msg, data) and msgFind(ircNick, data):
- return True
- return False
- def Initialize():
- time.sleep(5)
- ircConnect()
- ircRegister()
- ircSendNick()
- def channelRequests(channel, data):
- user = str(data).split('!')[0].split(':')[1]
- print(owner+":"+user+":")
- if msgAnalyze("help", data):
- #if bytes("help","utf-8") not in data.split()[len(data.split())-1]:
- #user = re.match(r"\w+",str(str(data).split()[len(data.split())-1])).group()
- #ircMessage(user+": look at your private messages!", channel)
- #ircMessage("General rules:", user)
- #for z in range(len(rules)):
- #ircMessage("Rule "+str(int(z)+1)+": "+rules[z], user)
- #ircMessage("General bots:", user)
- print(str(len(botList))+"END")
- print(str(data)+"END")
- print(user+"END")
- for z in range(0,len(botList)-1,3):
- print(z)
- ircMessage("General bots:", user)
- #ircMessage("Bot: "+str(botList[z])+", description: "+str(botList[z+1])+", main command: "+str(botList[z+2]), user)
- #ircMessage(ircNick+"'s commands:", user)
- #for z in range(0,len(helpList),2):
- #ircMessage("Command: "+helpList[z]+", Function: "+helpList[z+1], user)
- elif msgAnalyze("radio", data):
- ircMessage("Tune in here: "+radioLink+"!", channel)
- #elif user == owner:
- #finalArgument = re.match(r"\w+",str(str(data).split()[len(data.split())-1])).group()
- #if finalArgument == "die":
- #ircDisconnect("Good night!")
- #irc.close()
- #sys.exit()
- #elif finalArgument == "rainbow":
- #for z in range(9):
- #for i in range(9):
- #ircMessage(chr(3)+str(z)+","+str(i)+"RAINBOW", channel)
- # Per RFC 1149.5
- #if msgFind(ircCKey + "random", data):
- #ircMessage("4", channel)
- Initialize()
- print("Connected.")
- while True:
- data = irc.recv(512)
- if len(str(data)) is not 3:
- print(data)
- print(len(str(data)))
- else:
- irc.close()
- irc = socket.socket()
- irc = ssl.wrap_socket(irc)
- Initialize()
- if str(data)[2:8] == "PING :":
- #b'PING :`b@VTMj`\\q\r\n:
- rawSend(str(data).split(r"\r\n")[0].replace("IN", "ON").split("'")[1])
- continue
- if msgFind("MODE "+ircNick, data) and msgFind("PRIVMSG", data) is False:
- #Nick confirmed
- for channel in channelList:
- ircJoin(channel)
- continue
- for channel in channelList:
- if msgFind("PRIVMSG " + channel, data) or msgFind("PRIVMSG " + ircNick, data):
- t = threading.Thread(target=channelRequests, args=(channel, data))
- t.daemon = True
- t.start()
- continue
- LOG:
- b'ch ~doctoor +[Z]RadioBot dopE \r\n:us1.blackcatz.org 366 [Z]NotifyMaster #howtohack :\x033End of /NAMES list.\x0f\r\n'
- 120
- b':[Z]NotifyMaster![Z]NotifyMa@blackcatz-m9f.89j.e4173a.IP JOIN :#bots\r\n:us1.blackcatz.org 353 [Z]NotifyMaster = #bots :@[Z]NotifyMaster \r\n:us1.blackcatz.org 366 [Z]NotifyMaster #bots :\x036End of /NAMES list.\x0f\r\n'
- 222
- b':fuckoo!anon@blackcatz-689.e52.j0u5o5.IP PRIVMSG [Z]NotifyMaster ::eve!user@blackcatz-v1u.klh.seedjm.IP PRIVMSG #howtohack :[Z]NotifyMaster help:eve!user@blackcatz-v1u.klh.seedjm.IP PRIVMSG #howtohack :[Z]NotifyMaster help\r\n'
- 231
- eve:fuckoo:
- eve:fuckoo:
- 24END
- 24END
- b':fuckoo!anon@blackcatz-689.e52.j0u5o5.IP PRIVMSG [Z]NotifyMaster ::eve!user@blackcatz-v1u.klh.seedjm.IP PRIVMSG #howtohack :[Z]NotifyMaster help:eve!user@blackcatz-v1u.klh.seedjm.IP PRIVMSG #howtohack :[Z]NotifyMaster help\r\n'END
- b':fuckoo!anon@blackcatz-689.e52.j0u5o5.IP PRIVMSG [Z]NotifyMaster ::eve!user@blackcatz-v1u.klh.seedjm.IP PRIVMSG #howtohack :[Z]NotifyMaster help:eve!user@blackcatz-v1u.klh.seedjm.IP PRIVMSG #howtohack :[Z]NotifyMaster help\r\n'END
- fuckooEND
- fuckooEND
- 0
- PRIVMSG fuckoo :General bots:
- 0
- PRIVMSG fuckoo :General bots:
- 3
- PRIVMSG fuckoo :General bots:
- Exception in thread Thread-2:
- Traceback (most recent call last):
- File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
- self.run()
- File "/usr/lib/python3.6/threading.py", line 864, in run
- self._target(*self._args, **self._kwargs)
- File "./sslircbot.py", line 110, in channelRequests
- ircMessage("General bots:", user)
- File "./sslircbot.py", line 62, in ircMessage
- rawSend("PRIVMSG " + str(channel) + " :" + str(msg) + "\r\n")
- File "./sslircbot.py", line 56, in rawSend
- irc.send(str(data + "\r\n").encode())
- File "/usr/lib/python3.6/ssl.py", line 941, in send
- return self._sslobj.write(data)
- File "/usr/lib/python3.6/ssl.py", line 642, in write
- return self._sslobj.write(data)
- OSError: [Errno 14] Bad address
- Exception in thread Thread-1:
- Traceback (most recent call last):
- File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
- self.run()
- File "/usr/lib/python3.6/threading.py", line 864, in run
- self._target(*self._args, **self._kwargs)
- File "./sslircbot.py", line 110, in channelRequests
- ircMessage("General bots:", user)
- File "./sslircbot.py", line 62, in ircMessage
- rawSend("PRIVMSG " + str(channel) + " :" + str(msg) + "\r\n")
- File "./sslircbot.py", line 56, in rawSend
- irc.send(str(data + "\r\n").encode())
- File "/usr/lib/python3.6/ssl.py", line 941, in send
- return self._sslobj.write(data)
- File "/usr/lib/python3.6/ssl.py", line 642, in write
- return self._sslobj.write(data)
- OSError: [Errno 14] Bad address
- Traceback (most recent call last):
- File "./sslircbot.py", line 134, in <module>
- data = irc.recv(512)
- File "/usr/lib/python3.6/ssl.py", line 994, in recv
- return self.read(buflen)
- File "/usr/lib/python3.6/ssl.py", line 871, in read
- return self._sslobj.read(len, buffer)
- File "/usr/lib/python3.6/ssl.py", line 633, in read
- v = self._sslobj.read(len)
- ssl.SSLError: [SSL: SSLV3_ALERT_BAD_RECORD_MAC] sslv3 alert bad record mac (_ssl.c:2217)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement