Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.23 KB | None | 0 0
  1. #! /usr/bin/env python3
  2.  
  3. import os
  4. import re
  5. import ssl
  6. import sys
  7. #import bs4 # apt-get install python3-bs4
  8. import time
  9. import json
  10. import socket
  11. import string
  12. import threading
  13. import subprocess
  14.  
  15. #from rottentomatoes import RT
  16.  
  17. # Setup the IRC connection
  18. irc = socket.socket()
  19. irc = ssl.wrap_socket(irc)
  20.  
  21. # List of currently active threads
  22. threadlist = []
  23.  
  24. # Edit these values for your server
  25. ircServer = "irc.blackcatz.org"
  26. ircSSLPort = 6697
  27. ircNick = "[Z]NotifyMaster"
  28. # What the bot uses as a command character
  29. ircCKey = ircNick
  30. # List of channels to connect to
  31. channelList = ['#howtohack','#bots']
  32. owner = "eve"
  33. # Radio link
  34. radioLink = "https://radio.zempirians.com"
  35. # Bot help command
  36. botList = ['[Z]NotifyMaster','Contains basic help command and notifies bot owners when their bot is down','help'
  37. ,'+[Z]Citadel','Searches for the databases in which your string is found','!email string'
  38. ,'+[Z]Googler','Searches google with the given string, gives you the top result','[Z]Googler: help'
  39. ,'+[Z]MEGABOT','Contains multiple helpful commands that didn\'t require their own bot','[Z]MEGABOT: help'
  40. ,'+[Z]RadioBot','Manages the radio on '+radioLink+'!','[Z]RadioBot: help'
  41. ,'+[Z]RssFeeder','Automatically posts new articles from websites we are subscribed to','[RssFeeder]: help'
  42. ,'+[Z]Titler','Automatically pulls the title of links posted in the chat','[Z]Titler: help'
  43. ,'&Zempire','Administrative bot for the operators','[Z]Zempire: help'
  44. ]
  45. rules = ['[Z] represents a bot, +[Z] represents an official bot and & represents an administrative bot.'
  46. ,'The command \"[Z]BotName: help\" allows you to get the commands of a bot.'
  47. ,'Don\'t make mom jokes. Only Bulwark\'s mom can get those.'
  48. ]
  49. helpList = ['help','Displays the help command of bot and the other general bot commands.'
  50. ,'radio','Returns the radio link.'
  51. ,'die','Kills the bot, if your the owner.'
  52. ]
  53.  
  54. def rawSend(data):
  55. print(data)
  56. irc.send(str(data + "\r\n").encode())
  57.  
  58. def ircConnect():
  59. irc.connect((ircServer, ircSSLPort))
  60.  
  61. def ircMessage(msg, channel):
  62. rawSend("PRIVMSG " + str(channel) + " :" + str(msg) + "\r\n")
  63.  
  64. def ircRegister():
  65. rawSend("USER " + ircNick + " 0 * " + ":" + ircNick + "\r\n")
  66.  
  67. def ircSendNick():
  68. rawSend("NICK " + ircNick + "\r\n")
  69.  
  70. def ircJoin(channel):
  71. rawSend("JOIN " + channel + "\r\n")
  72.  
  73. def ircPassword():
  74. rawSend("PASS " + ircPass + "\r\n")
  75.  
  76. def ircDisconnect(msg):
  77. rawSend("QUIT " + msg + "\r\n")
  78.  
  79. def msgFind(msg, data):
  80. if bytes(msg,"utf-8") in data:
  81. return True
  82. return False
  83. def msgAnalyze(msg, data):
  84. if msgFind(msg, data) and msgFind(ircNick, data):
  85. return True
  86. return False
  87.  
  88. def Initialize():
  89. time.sleep(5)
  90. ircConnect()
  91. ircRegister()
  92. ircSendNick()
  93.  
  94. def channelRequests(channel, data):
  95. user = str(data).split('!')[0].split(':')[1]
  96. print(owner+":"+user+":")
  97. if msgAnalyze("help", data):
  98. #if bytes("help","utf-8") not in data.split()[len(data.split())-1]:
  99. #user = re.match(r"\w+",str(str(data).split()[len(data.split())-1])).group()
  100. #ircMessage(user+": look at your private messages!", channel)
  101. #ircMessage("General rules:", user)
  102. #for z in range(len(rules)):
  103. #ircMessage("Rule "+str(int(z)+1)+": "+rules[z], user)
  104. #ircMessage("General bots:", user)
  105. print(str(len(botList))+"END")
  106. print(str(data)+"END")
  107. print(user+"END")
  108. for z in range(0,len(botList)-1,3):
  109. print(z)
  110. ircMessage("General bots:", user)
  111. #ircMessage("Bot: "+str(botList[z])+", description: "+str(botList[z+1])+", main command: "+str(botList[z+2]), user)
  112. #ircMessage(ircNick+"'s commands:", user)
  113. #for z in range(0,len(helpList),2):
  114. #ircMessage("Command: "+helpList[z]+", Function: "+helpList[z+1], user)
  115. elif msgAnalyze("radio", data):
  116. ircMessage("Tune in here: "+radioLink+"!", channel)
  117. #elif user == owner:
  118. #finalArgument = re.match(r"\w+",str(str(data).split()[len(data.split())-1])).group()
  119. #if finalArgument == "die":
  120. #ircDisconnect("Good night!")
  121. #irc.close()
  122. #sys.exit()
  123. #elif finalArgument == "rainbow":
  124. #for z in range(9):
  125. #for i in range(9):
  126. #ircMessage(chr(3)+str(z)+","+str(i)+"RAINBOW", channel)
  127. # Per RFC 1149.5
  128. #if msgFind(ircCKey + "random", data):
  129. #ircMessage("4", channel)
  130.  
  131. Initialize()
  132. print("Connected.")
  133. while True:
  134. data = irc.recv(512)
  135. if len(str(data)) is not 3:
  136. print(data)
  137. print(len(str(data)))
  138. else:
  139. irc.close()
  140. irc = socket.socket()
  141. irc = ssl.wrap_socket(irc)
  142. Initialize()
  143. if str(data)[2:8] == "PING :":
  144. #b'PING :`b@VTMj`\\q\r\n:
  145. rawSend(str(data).split(r"\r\n")[0].replace("IN", "ON").split("'")[1])
  146. continue
  147. if msgFind("MODE "+ircNick, data) and msgFind("PRIVMSG", data) is False:
  148. #Nick confirmed
  149. for channel in channelList:
  150. ircJoin(channel)
  151. continue
  152.  
  153. for channel in channelList:
  154. if msgFind("PRIVMSG " + channel, data) or msgFind("PRIVMSG " + ircNick, data):
  155. t = threading.Thread(target=channelRequests, args=(channel, data))
  156. t.daemon = True
  157. t.start()
  158. continue
  159.  
  160.  
  161.  
  162. LOG:
  163. b'ch ~doctoor +[Z]RadioBot dopE \r\n:us1.blackcatz.org 366 [Z]NotifyMaster #howtohack :\x033End of /NAMES list.\x0f\r\n'
  164. 120
  165. 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'
  166. 222
  167. 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'
  168. 231
  169. eve:fuckoo:
  170. eve:fuckoo:
  171. 24END
  172. 24END
  173. 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
  174. 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
  175. fuckooEND
  176. fuckooEND
  177. 0
  178. PRIVMSG fuckoo :General bots:
  179. 0
  180.  
  181. PRIVMSG fuckoo :General bots:
  182.  
  183. 3
  184. PRIVMSG fuckoo :General bots:
  185.  
  186. Exception in thread Thread-2:
  187. Traceback (most recent call last):
  188. File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
  189. self.run()
  190. File "/usr/lib/python3.6/threading.py", line 864, in run
  191. self._target(*self._args, **self._kwargs)
  192. File "./sslircbot.py", line 110, in channelRequests
  193. ircMessage("General bots:", user)
  194. File "./sslircbot.py", line 62, in ircMessage
  195. rawSend("PRIVMSG " + str(channel) + " :" + str(msg) + "\r\n")
  196. File "./sslircbot.py", line 56, in rawSend
  197. irc.send(str(data + "\r\n").encode())
  198. File "/usr/lib/python3.6/ssl.py", line 941, in send
  199. return self._sslobj.write(data)
  200. File "/usr/lib/python3.6/ssl.py", line 642, in write
  201. return self._sslobj.write(data)
  202. OSError: [Errno 14] Bad address
  203.  
  204. Exception in thread Thread-1:
  205. Traceback (most recent call last):
  206. File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
  207. self.run()
  208. File "/usr/lib/python3.6/threading.py", line 864, in run
  209. self._target(*self._args, **self._kwargs)
  210. File "./sslircbot.py", line 110, in channelRequests
  211. ircMessage("General bots:", user)
  212. File "./sslircbot.py", line 62, in ircMessage
  213. rawSend("PRIVMSG " + str(channel) + " :" + str(msg) + "\r\n")
  214. File "./sslircbot.py", line 56, in rawSend
  215. irc.send(str(data + "\r\n").encode())
  216. File "/usr/lib/python3.6/ssl.py", line 941, in send
  217. return self._sslobj.write(data)
  218. File "/usr/lib/python3.6/ssl.py", line 642, in write
  219. return self._sslobj.write(data)
  220. OSError: [Errno 14] Bad address
  221.  
  222. Traceback (most recent call last):
  223. File "./sslircbot.py", line 134, in <module>
  224. data = irc.recv(512)
  225. File "/usr/lib/python3.6/ssl.py", line 994, in recv
  226. return self.read(buflen)
  227. File "/usr/lib/python3.6/ssl.py", line 871, in read
  228. return self._sslobj.read(len, buffer)
  229. File "/usr/lib/python3.6/ssl.py", line 633, in read
  230. v = self._sslobj.read(len)
  231. 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