예제 #1
0
    def modules(self, args):
        t = PrettyTable([colors.bold + 'Modules:', '' + colors.end])
        t.align = 'l'
        t.valing = 'm'
        t.border = False
        xml = moddbparser.parsemoddb()
        root = xml[0]
        for category in root:
            if category.tag == "category":
                t.add_row(["", ""])
                t.add_row([
                    colors.red + colors.uline + category.attrib["name"] +
                    colors.end,
                    colors.red + colors.uline + "Description" + colors.end
                ])

            for item in category:
                if item.tag == "module":
                    for child in item:
                        if child.tag == "shortdesc":
                            t.add_row([item.attrib["name"], child.text])
                            break
        print("")
        print(t)
        print("")
예제 #2
0
def addtodb(modadd):
    xml = moddbparser.parsemoddb()
    root = xml[0]
    tree = xml[1]

    new = True
    newcat = True

    for category in root:
        if category.tag == "category":
            for item in category:
                if item.tag == "module" and item.attrib["name"] == modadd.conf[
                        "name"]:
                    for info in item:
                        if info.tag == "shortdesc":
                            info.text = modadd.conf["shortdesc"]
                            new = False
                            tree.write(getpath.core() + "module_database.xml")
                            printSuccess("database updated")
                            return
    if new == True:
        printInfo(modadd.conf["name"] + " doesn't exist in database\n",
                  start="\n")
        print("available categories keys:" + colors.yellow)
        for category in root:
            if category.tag == "category":
                print(category.attrib["key"])
        print(colors.end, end="")
        catkey = input("\nGive new or exist key? ")

        for category in root:
            if category.tag == "category" and category.attrib["key"] == catkey:
                module = ElementTree.Element("module")
                shortdesc = ElementTree.Element("shortdesc")
                shortdesc.text = modadd.conf["shortdesc"]
                module.set("name", modadd.conf["name"])
                module.append(shortdesc)
                category.append(module)
                writedb(root)
                newcat = False
                printSuccess("Module added to " + category.attrib["name"])
                break

        if newcat == True:
            printInfo("Category not found!")
            printInfo("Going to add new category...")
            catname = input("Give new category name: ")
            newcat = ElementTree.Element("category")
            newcat.set("name", catname)
            newcat.set("key", catkey)
            module = ElementTree.Element("module")
            shortdesc = ElementTree.Element("shortdesc")
            shortdesc.text = modadd.conf["shortdesc"]
            module.set("name", modadd.conf["name"])
            module.append(shortdesc)
            newcat.append(module)
            root.append(newcat)
            writedb(root)
            printSuccess("New category created!")
            printSuccess("Module added to " + newcat.attrib["name"])
예제 #3
0
def addtodb(modadd):
	xml = moddbparser.parsemoddb()
	root = xml[0]
	tree = xml[1]

	new = True
	newcat = True

	for category in root:
		if category.tag == "category":
			for item in category:
				if item.tag == "module" and item.attrib["name"] == modadd.conf["name"]:
					for info in item:
						if info.tag == "shortdesc":
							info.text = modadd.conf["shortdesc"]
							new = False
							tree.write(getpath.core()+"module_database.xml")
							printSuccess("database updated")
							return
	if new == True:
		printInfo(modadd.conf["name"]+" doesn't exist in database\n", start="\n")
		print("available categories keys:"+colors.yellow)
		for category in root:
			if category.tag == "category":
				print(category.attrib["key"])
		print(colors.end, end="")
		catkey = input("\ngive new or exist key? ")

		for category in root:
			if category.tag == "category" and category.attrib["key"] == catkey:
				module = ElementTree.Element("module")
				shortdesc = ElementTree.Element("shortdesc")
				shortdesc.text = modadd.conf["shortdesc"]
				module.set("name", modadd.conf["name"])
				module.append(shortdesc)
				category.append(module)
				writedb(root)
				newcat = False
				printSuccess("module added to "+category.attrib["name"])
				break

		if newcat == True:
			printInfo("category not found")
			printInfo("going to add new category")
			catname = input("give new category name: ")
			newcat = ElementTree.Element("category")
			newcat.set("name", catname)
			newcat.set("key", catkey)
			module = ElementTree.Element("module")
			shortdesc = ElementTree.Element("shortdesc")
			shortdesc.text = modadd.conf["shortdesc"]
			module.set("name", modadd.conf["name"])
			module.append(shortdesc)
			newcat.append(module)
			root.append(newcat)
			writedb(root)
			printSuccess("new category created")
			printSuccess("module added to "+newcat.attrib["name"])
예제 #4
0
    def show(self, args):
        try:
            if args[0] == "modules":
                t = PrettyTable([colors.bold + 'Modules:', '' + colors.end])
                t.align = 'l'
                t.valing = 'm'
                t.border = False
                xml = moddbparser.parsemoddb()
                root = xml[0]
                for category in root:
                    if category.tag == "category":
                        t.add_row(["", ""])
                        t.add_row([
                            colors.red + colors.uline +
                            category.attrib["name"] + colors.end, colors.red +
                            colors.uline + "Description" + colors.end
                        ])

                    for item in category:
                        if item.tag == "module":
                            for child in item:
                                if child.tag == "shortdesc":
                                    t.add_row(
                                        [item.attrib["name"], child.text])
                                    break
                print("")
                print(t)
                print("")

            elif args[0] == "options" and self.mm.moduleLoaded == 1:
                try:
                    moduleop.printoptions(self.modadd)
                except:
                    print("[" + colors.bold + colors.red + "err" + colors.end +
                          "] Unexpected error in module:\n")
                    traceback.print_exc(file=sys.stdout)
                    print(colors.end)
                    if api.enabled == True:
                        raise
            else:
                raise UnknownCommand(
                    "[" + colors.bold + colors.red + "err" + colors.end +
                    "] Module not loaded or Unrecognized command!")
        except IndexError:
            raise UnknownCommand("[" + colors.bold + colors.red + "err" +
                                 colors.end + "] Unrecognized command!")
예제 #5
0
	def show(self, args):
		try:
			if args[0] == "modules":
				t = PrettyTable([colors.bold+'Modules:', ''+colors.end])
				t.align = 'l'
				t.valing = 'm'
				t.border = False
				xml = moddbparser.parsemoddb()
				root = xml[0]
				for category in root:
					if category.tag == "category":
						t.add_row(["", ""])
						t.add_row([colors.red+colors.uline+category.attrib["name"]+colors.end, colors.red+colors.uline+"Description"+colors.end])

					for item in category:
						if item.tag == "module":
							for child in item:
								if child.tag == "shortdesc":
									t.add_row([item.attrib["name"], child.text])
									break

				print(t)				

			elif args[0] == "options" and self.mm.moduleLoaded == 1:
				try:
					moduleop.printoptions(self.modadd)
				except:
					print(colors.red+"unexpected error in module:\n")
					traceback.print_exc(file=sys.stdout)
					print(colors.end)
					if api.enabled == True:
						raise
			else:
				raise UnknownCommand("module not loaded or unknown command")
		except IndexError:
			raise UnknownCommand("unknown command")
예제 #6
0
def addtodb(modadd):
	xml = moddbparser.parsemoddb()
	root = xml[0]
	tree = xml[1]

	new = True
	newcat = True

	for category in root:
		if category.tag == "category":
			for item in category:
				if item.tag == "module" and item.attrib["name"] == modadd.conf["name"]:
					for info in item:
						if info.tag == "shortdesc":
							info.text = modadd.conf["shortdesc"]
							new = False
							tree.write(getpath.core()+"module_database.xml")
							printSuccess("database updated")
							return
	if new == True:
		printInfo("Module "+modadd.conf["name"]+" doesn't exist in modules database!")
		printInfo("Going to add this module to modules database...")
		dome = input(colors.purple+"Add module to [old/new] "+colors.end)
		if dome == "old":
			pass
		if dome == "new":
			printInfo("Going to add new category...")
			catname = input(colors.purple+"Category: "+colors.end)
			newcat = ElementTree.Element("category")
			newcat.set("name", catname)
			newcat.set("key", catname)
			module = ElementTree.Element("module")
			shortdesc = ElementTree.Element("shortdesc")
			shortdesc.text = modadd.conf["shortdesc"]
			module.set("name", modadd.conf["name"])
			module.append(shortdesc)
			newcat.append(module)
			root.append(newcat)
			writedb(root)
			printSuccess("New category created!")
			printSuccess("Module added to "+newcat.attrib["name"])
			return
		print(colors.purple+"Categories:"+colors.yellow)
		for category in root:
			if category.tag == "category":
				print(category.attrib["key"])
		print(colors.end, end="")
		catkey = input(colors.purple+"Category: "+colors.end)

		for category in root:
			if category.tag == "category" and category.attrib["key"] == catkey:
				module = ElementTree.Element("module")
				shortdesc = ElementTree.Element("shortdesc")
				shortdesc.text = modadd.conf["shortdesc"]
				module.set("name", modadd.conf["name"])
				module.append(shortdesc)
				category.append(module)
				writedb(root)
				newcat = False
				printSuccess("Module added to "+category.attrib["name"])
				break

		if newcat == True:
			printInfo("Category not found!")
			printInfo("Going to add new category...")
			catname = input(colors.purple+"Category: "+colors.end)
			newcat = ElementTree.Element("category")
			newcat.set("name", catname)
			newcat.set("key", catkey)
			module = ElementTree.Element("module")
			shortdesc = ElementTree.Element("shortdesc")
			shortdesc.text = modadd.conf["shortdesc"]
			module.set("name", modadd.conf["name"])
			module.append(shortdesc)
			newcat.append(module)
			root.append(newcat)
			writedb(root)
			printSuccess("New category created!")
			printSuccess("Module added to "+newcat.attrib["name"])