Exemple #1
0
def nick_identify(nick, uhost, target, arg):
	if nick == "NickServ":
		if arg.lower().find("wenn du ihn nicht innerhalb einer minute identifizierst") != -1:
			ns_pw = c.get("SERVICES", "nickserv")
			putf("PRIVMSG NickServ :IDENTIFY %s" % ns_pw)
		elif arg.lower().find("nickname is registered") != -1:
			ns_pw = c.get("SERVICES", "nickserv")
			putf("PRIVMSG NickServ :IDENTIFY %s" % ns_pw)
Exemple #2
0
def nick_identify(nick, uhost, target, arg):
    if nick == "NickServ":
        if arg.lower().find(
                "wenn du ihn nicht innerhalb einer minute identifizierst"
        ) != -1:
            ns_pw = c.get("SERVICES", "nickserv")
            putf("PRIVMSG NickServ :IDENTIFY %s" % ns_pw)
        elif arg.lower().find("nickname is registered") != -1:
            ns_pw = c.get("SERVICES", "nickserv")
            putf("PRIVMSG NickServ :IDENTIFY %s" % ns_pw)
Exemple #3
0
def channel_register(nick,uhost,arg):
	password = arg.split()[0]
	channel = arg.split()[1]

	if password == c.get("ADMIN", "password"):
		_chandb.execute("insert into list values ('%s')" % channel)
		put("JOIN %s" % channel)
		put("NOTICE %s :%s has been added to the database ... You got owner flags" % (nick,channel))
		_chandb.execute("insert into channel values ('%s','%s','n')" % (channel,getauth(nick)))
		_chandb.execute("insert into info values ('%s','','')" % channel)
Exemple #4
0
def channel_drop(nick,uhost,arg):
	password = arg.split()[0]
	channel = arg.split()[1]

	if password == c.get("ADMIN", "password"):
		_chandb.execute("delete from list where channel='%s'" % channel)
		put("PART %s" % channel)
		put("NOTICE %s :%s has been removed from the database" % (nick,channel))
		_chandb.execute("delete from channel where channel='%s'" % channel)
		_chandb.execute("delete from info where channel='%s'" % channel)
Exemple #5
0
def channel_drop(nick, uhost, arg):
    password = arg.split()[0]
    channel = arg.split()[1]

    if password == c.get("ADMIN", "password"):
        _chandb.execute("delete from list where channel='%s'" % channel)
        put("PART %s" % channel)
        put("NOTICE %s :%s has been removed from the database" %
            (nick, channel))
        _chandb.execute("delete from channel where channel='%s'" % channel)
        _chandb.execute("delete from info where channel='%s'" % channel)
Exemple #6
0
def channel_register(nick, uhost, arg):
    password = arg.split()[0]
    channel = arg.split()[1]

    if password == c.get("ADMIN", "password"):
        _chandb.execute("insert into list values ('%s')" % channel)
        put("JOIN %s" % channel)
        put("NOTICE %s :%s has been added to the database ... You got owner flags"
            % (nick, channel))
        _chandb.execute("insert into channel values ('%s','%s','n')" %
                        (channel, getauth(nick)))
        _chandb.execute("insert into info values ('%s','','')" % channel)
Exemple #7
0
def quakenet_mode_x(nick, host, target, arg):
    react = "are now logged in as " + c.get("SERVICES",
                                            "quakenet").split()[0] + "."

    if arg == react:
        putf("MODE %s +x" % target)
Exemple #8
0
def quakenet_auth(text):
    if c.get("SERVICES", "quakenet") != "" and len(
            c.get("SERVICES", "quakenet").split()) == 2:
        putf("AUTH %s" % c.get("SERVICES", "quakenet"))
Exemple #9
0
def channel_join(text):
    putf("JOIN %s" % c.get("BOT", "channels"))

    for data in _chandb.execute("select channel from list"):
        put("JOIN %s" % data[0])
Exemple #10
0
def quakenet_mode_x(nick,host,target,arg):
	react = "are now logged in as "+c.get("SERVICES","quakenet").split()[0]+"."

	if arg == react:
		putf("MODE %s +x" % target)
Exemple #11
0
def quakenet_auth(text):
	if c.get("SERVICES", "quakenet") != "" and len(c.get("SERVICES", "quakenet").split()) == 2:
		putf("AUTH %s" % c.get("SERVICES", "quakenet"))
Exemple #12
0
def check_user(text):
    if not c.get("SERVER", "address").lower().endswith(".quakenet.org"):
        whois(text.split()[7])
Exemple #13
0
    def client(self, sock, addr, servsock):
        try:
            printc("!! conntected with " + addr + " !!")
            self.send(sock, "Hello. I am %s." % c.get("BOT", "username"))
            self.send(sock, "Welcome to the remote interface of PIRB.")
            self.send(sock,
                      "Please enter the administrators password to unlock!")

            if str(sock.recv(100)).rstrip() == c.get("ADMIN", "password"):
                self.send(sock, "Access granted.")
                printc("!! " + addr + " logged in !!")
            else:
                self.send(sock, "Access denied.")
                printc("!! " + addr + " failed login !!")
                sock.close()

            while 1:
                raw = sock.recv(1024)
                data = raw.rstrip()

                if not data:
                    printc("!! losed connection with " + addr + " !!")
                    sock.close()

                if data:
                    cmd = data.split()[0].lower()

                    if cmd == "crypt":
                        sha = hashlib.sha1()
                        sha.update(data[6:])
                        self.send(sock, "Hash: %s" % str(sha.hexdigest()))
                    elif cmd == "put":
                        open(".put_query", "a").write(data[4:] + "\n")
                        self.send(sock, "Sent: %s" % data[4:])
                    elif cmd == "restart":
                        if os.access("pirb.pid", os.F_OK):
                            self.send(sock, "Restarting ...")
                            servsock.close()
                            sock.close()
                            shell("sh pirb restart")
                        else:
                            self.send(sock,
                                      "Cannot restart when debug is running")
                    elif cmd == "update":
                        _file = open("version", "r")
                        _old = _file.read()
                        _file.close()
                        _web = urllib2.urlopen(
                            "https://raw.github.com/Pythonz/PIRB/master/version"
                        )
                        _new = _web.read()
                        _web.close()

                        if _old != _new:
                            self.send(sock, "{0} -> {1}".format(_old, _new))
                            __cache = len(os.listdir("database/updates/cache"))
                            __chan = len(os.listdir("database/updates/chan"))
                            __user = len(os.listdir("database/updates/user"))
                            shell("git add .")
                            shell("git rm --cached database/*.db")
                            shell("git commit -m 'Save'")
                            shell("git pull")
                            ___cache = os.listdir("database/updates/cache")

                            if __cache < len(___cache):
                                while __cache != len(___cache):
                                    __cache += 1

                                    for sql in ___cache:
                                        if sql.startswith(str(__cache) + "_"):
                                            self.send(
                                                sock,
                                                " - Insert 'cache/{0}'".format(
                                                    sql))
                                            shell(
                                                "sqlite3 database/cache.db < database/updates/cache/{0}"
                                                .format(sql))

                            ___chan == os.listdir("database/updates/chan")

                            if __chan < len(___chan):
                                while __chan != len(___chan):
                                    __chan += 1

                                    for sql in ___chan:
                                        if sql.startswith(str(__chan) + "_"):
                                            self.send(
                                                sock,
                                                " - Insert 'chan/{0}'".format(
                                                    sql))
                                            shell(
                                                "sqlite3 database/chan.db < database/updates/chan/{0}"
                                                .format(sql))

                            ___user == os.listdir("database/updates/user")

                            if __user < len(___user):
                                while __user != len(___user):
                                    __user += 1

                                    for sql in ___user:
                                        if sql.startswith(str(__user) + "_"):
                                            self.send(
                                                sock,
                                                " - Insert 'user/{0}'".format(
                                                    sql))
                                            shell(
                                                "sqlite3 database/user.db < database/updates/user/{0}"
                                                .format(sql))

                            put("QUIT :Updating...")
                            servsock.close()
                            sock.close()
                            shell("sh pirb restart")
                        else:
                            self.send(sock, "No update available.")
                    elif cmd == "version":
                        file = open("version", "r")
                        self.send(sock, "PIRB " + file.read())
                        file.close()
                    elif cmd == "quit":
                        self.send(sock, "Bye :(")
                        sock.close()
                    elif cmd == "die":
                        servsock.close()
                        sock.close()
                        if os.access("pirb.pid", os.F_OK):
                            shell("sh pirb stop")
                        else:
                            sys.exit(2)
                    elif cmd == "help":
                        tbl = list()
                        tbl.append("help")
                        tbl.append("crypt")
                        tbl.append("put")
                        tbl.append("restart")
                        tbl.append("update")
                        tbl.append("version")
                        tbl.append("die")
                        tbl.append("quit")
                        for command in tbl:
                            self.send(sock, command.upper())
                    else:
                        self.send(
                            sock,
                            "unknown command '%s'. try 'HELP'" % cmd.upper())

        except Exception, e:
            printe(e)
Exemple #14
0
 def __init__(self):
     self.ip = c.get("TELNET", "ip")
     self.port = c.get("TELNET", "port")
Exemple #15
0
def check_user(text):
	if not c.get("SERVER", "address").lower().endswith(".quakenet.org"):
		whois(text.split()[7])
Exemple #16
0
	def client(self,sock,addr,servsock):
		try:
			printc("!! conntected with "+addr+" !!")
			self.send(sock,"Hello. I am %s." % c.get("BOT","username"))
			self.send(sock,"Welcome to the remote interface of PIRB.")
			self.send(sock,"Please enter the administrators password to unlock!")

			if str(sock.recv(100)).rstrip() == c.get("ADMIN", "password"):
				self.send(sock,"Access granted.")
				printc("!! "+addr+" logged in !!")
			else:
				self.send(sock,"Access denied.")
				printc("!! "+addr+" failed login !!")
				sock.close()

			while 1:
				raw = sock.recv(1024)
				data = raw.rstrip()

				if not data:
					printc("!! losed connection with "+addr+ " !!")
					sock.close()

				if data:
					cmd = data.split()[0].lower()

					if cmd == "crypt":
						sha = hashlib.sha1()
						sha.update(data[6:])
						self.send(sock,"Hash: %s" % str(sha.hexdigest()))
					elif cmd == "put":
						open(".put_query", "a").write(data[4:]+"\n")
						self.send(sock,"Sent: %s" % data[4:])
					elif cmd == "restart":
						if os.access("pirb.pid", os.F_OK):
							self.send(sock,"Restarting ...")
							servsock.close()
							sock.close()
							shell("sh pirb restart")
						else:
							self.send(sock,"Cannot restart when debug is running")
					elif cmd == "update":
						_file = open("version", "r")
						_old = _file.read()
						_file.close()
						_web = urllib2.urlopen("https://raw.github.com/Pythonz/PIRB/master/version")
						_new = _web.read()
						_web.close()

						if _old != _new:
							self.send(sock, "{0} -> {1}".format(_old, _new))
							__cache = len(os.listdir("database/updates/cache"))
							__chan = len(os.listdir("database/updates/chan"))
							__user = len(os.listdir("database/updates/user"))
							shell("git add .")
							shell("git rm --cached database/*.db")
							shell("git commit -m 'Save'")
							shell("git pull")
							___cache = os.listdir("database/updates/cache")

							if __cache < len(___cache):
								while __cache != len(___cache):
									__cache += 1

									for sql in ___cache:
										if sql.startswith(str(__cache)+"_"):
											self.send(sock, " - Insert 'cache/{0}'".format(sql))
											shell("sqlite3 database/cache.db < database/updates/cache/{0}".format(sql))

							___chan == os.listdir("database/updates/chan")

							if __chan < len(___chan):
								while __chan != len(___chan):
									__chan += 1

									for sql in ___chan:
										if sql.startswith(str(__chan)+"_"):
											self.send(sock, " - Insert 'chan/{0}'".format(sql))
											shell("sqlite3 database/chan.db < database/updates/chan/{0}".format(sql))

							___user == os.listdir("database/updates/user")

							if __user < len(___user):
								while __user != len(___user):
									__user += 1

									for sql in ___user:
										if sql.startswith(str(__user)+"_"):
											self.send(sock, " - Insert 'user/{0}'".format(sql))
											shell("sqlite3 database/user.db < database/updates/user/{0}".format(sql))

							put("QUIT :Updating...")
							servsock.close()
							sock.close()
							shell("sh pirb restart")
						else:
							self.send(sock, "No update available.")
					elif cmd == "version":
						file = open("version", "r")
						self.send(sock, "PIRB "+file.read())
						file.close()
					elif cmd == "quit":
						self.send(sock,"Bye :(")
						sock.close()
					elif cmd == "die":
						servsock.close()
						sock.close()
						if os.access("pirb.pid", os.F_OK):
							shell("sh pirb stop")
						else: sys.exit(2)
					elif cmd == "help":
						tbl = list()
						tbl.append("help")
						tbl.append("crypt")
						tbl.append("put")
						tbl.append("restart")
						tbl.append("update")
						tbl.append("version")
						tbl.append("die")
						tbl.append("quit")
						for command in tbl:
							self.send(sock, command.upper())
					else:
						self.send(sock,"unknown command '%s'. try 'HELP'" % cmd.upper())

		except Exception,e: printe(e)
Exemple #17
0
	def __init__(self):
		self.ip = c.get("TELNET", "ip")
		self.port = c.get("TELNET", "port")
Exemple #18
0
def channel_join(text):
	putf("JOIN %s" % c.get("BOT", "channels"))

	for data in _chandb.execute("select channel from list"):
		put("JOIN %s" % data[0])