Advertisement
Guest User

Python IRC Bot

a guest
Sep 10th, 2011
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. # Created by Pathogen @ www.hakhub.tk
  2.  
  3. import random,subprocess,sys,socket,string,re
  4.  
  5. num = str(random.randint(1,1000))
  6. host = "irc.yourserver.org"
  7. port = 6667
  8. iden = "CIA-"+num
  9. nick = "CIA-"+num
  10. rname = "George Orwell"
  11. chan = "#CIA"
  12. rbuf = ""
  13.  
  14. sock = socket.socket()
  15. sock.connect((host,port))
  16. sock.send("NICK %s\r\n" % nick)
  17. sock.send("USER %s %s bla :%s\r\n" %(iden,host,rname))
  18. sock.send("JOIN : %s\r\n" % chan)
  19. sock.send("PRIVMSG %s :%s\r\n" % (chan, "Activated."))
  20.  
  21. print 'Message sent!'
  22. while 1:
  23. rbuf = rbuf + sock.recv(1024)
  24. tmp = str.split(rbuf,"\n")
  25. print tmp
  26. rbuf = tmp.pop()
  27. for line in tmp:
  28. line = str.rstrip(line)
  29. line = str.split(line)
  30.  
  31. if(line[0] == "PING"):
  32. sock.send("PONG %s\r\n" % line[1])
  33. elif re.findall("Hello",str(tmp)):
  34. sock.send("PRIVMSG %s :%s\r\n" % (chan, "Hello There!"))
  35. elif re.findall("scanit",str(tmp)):
  36. string = re.split(" ",str(tmp[0]))
  37. if re.match("127",str.strip(string[4])) or re.match("192",str.strip(string[4])) or str.strip(string[4]) == "localhost" :
  38. sock.send("PRIVMSG %s :%s\r\n" % (chan, "NO! You may not play with my ports."))
  39. break
  40. command = str("nmap -PN -T5 " + str.strip(string[4]))
  41. res = subprocess.Popen(command,stdout=subprocess.PIPE,shell=True)
  42. results = res.stdout.read()
  43. line = results.split("\n")
  44. for each in line:
  45. sock.send("PRIVMSG %s :%s\r\n" % (chan, each))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement