Advertisement
Guest User

amus3d's IRC bot in Python.

a guest
Mar 21st, 2013
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. #!/usr/bin/python
  2. #
  3. #
  4. # Python IRC bot via Tor
  5. #
  6. # ~ by amus3d
  7. #
  8. #                                  
  9. ######################################
  10.  
  11. import TorCtl
  12. import socks
  13. import socket
  14.  
  15. # Start the proxy shizz.
  16.  
  17. socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
  18.  
  19. __originalSocket = socket.socket
  20.  
  21. # Functions
  22.  
  23. def torify(password):
  24.     socket.socket = __originalSocket
  25.     conn = TorCtl.connect(controlAddr="127.0.0.1", controlPort=9051, passphrase=password)
  26.     TorCtl.Connection.send_signal(conn, "NEWNYM")
  27.     conn.close()
  28.     socket.socket = socks.socksocket
  29.  
  30. # The juicy stuff
  31.  
  32. print "                            ____      _ "
  33. print "                           |___ \   | |"
  34. print "   __ _ _ __ ___  _   _ ___  __) | __| |"
  35. print "  / _` | '_ ` _ \| | | / __||__ < / _` |"
  36. print " | (_| | | | | | | |_| \__ \___) | (_| |"
  37. print "  \__,_|_| |_| |_|\__,_|___|____/ \__,_|"
  38. print "\n"
  39. print "Big hecks, no whammies."
  40.  
  41. password = raw_input('TOR\'s password ~> ')
  42. torify(password)
  43.  
  44. nick    = raw_input('Nick name ~> ')
  45. serber  = raw_input('Server/host ~> ')
  46. port    = raw_input('Port (6667 by default) ~> ')
  47. channel = raw_input('Channel ~> ')
  48.  
  49. irc_cmd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  50.  
  51. # The juicy stuff:
  52.  
  53. irc_cmd.connect((serber,port))
  54. irc_cmd.recv (4096)
  55. irc_cmd.send('NICK ' + nick + '\r\n')
  56. irc_cmd.send('USER sabu sabu sabu sabu :sabu IRC\r\n')
  57. irc_cmd.send('JOIN ' + channel + '\r\n')
  58.  
  59. # Commands shizzle
  60.  
  61. while irc_cmd:
  62.     data    = irc_cmd.recv(1024)
  63.    
  64.     print data
  65.  
  66.     message = raw_input('Enter message to send ~> ')
  67.    
  68.     # you could obvs add something like:
  69.     # help_cmd = "HELP OPTIONS: etc"
  70.     # if '!help' in data:
  71.     #   irc_cmd.send("PRIVMSG " + channel + ": " + help_cmd + "\r\n")
  72.     # but that is if you are l33t hecker.
  73.  
  74.     irc_cmd.send("PRIVMSG " + channel + " :" + message + "\r\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement