コード例 #1
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def new(args):
	try:
		if args[0] == "module":
			try:
				completeName = os.path.join('modules', args[1]+".py")
				if os.path.exists(completeName):
					print(colors.red+"module already exists"+colors.end)

				else:
					mfile = open(completeName, 'w')
					template = os.path.join('core', 'module_template')
					f = open(template, 'r')
					template_contents = f.readlines()
					template_contents[7] = 'name = "'+args[1]+'"\n'
					mfile.writelines(template_contents)
					mfile.close()
					print(colors.green+"module "+ args[1] +".py" +" created to modules folder"+colors.end)
					print(colors.green+"done"+colors.end)
			except(IOError):
				print(colors.red+"something went wrong"+colors.end)

			except(IndexError):
				print(colors.red + "please enter module name"+ colors.end)
		else:
			raise UnknownCommand("unknown command")
	except IndexError:
		raise UnknownCommand("unkown command")
コード例 #2
0
ファイル: cmethods.py プロジェクト: swagkarna/arissploit
	def new(self, args):
		try:
			if args[0] == "module":
				try:
					completeName = os.path.join(getpath.modules(), args[1]+".py")
					if os.path.exists(completeName):
						print(colors.red+"Module already exists!"+colors.end)

					else:
						mfile = open(completeName, 'w')
						template = os.path.join('core', 'module_template')
						f = open(template, 'r')
						template_contents = f.readlines()
						template_contents[5] = "	\"name\": \""+args[1]+"\", # Module's name (should be same as file name)\n"
						template_contents[11] = "	\"initdate\": \""+(time.strftime("%d.%m.%Y"))+"\", # Initial date\n"
						template_contents[12] = "	\"lastmod\": \""+(time.strftime("%d.%m.%Y"))+"\", # Last modification\n"
						mfile.writelines(template_contents)
						mfile.close()
						print(colors.bold+"Module "+ args[1] +".py" +" saved to ./modules"+colors.end)

				except IndexError:
					print(colors.red + "Please enter module name!" + colors.end)

				except PermissionError:
					print(colors.red + "Error: permission denied!" + colors.end)

				except IOError:
					print(colors.red + "Something went wrong!" + colors.end)

			else:
				raise UnknownCommand("Unknown command!")
		except IndexError:
			raise UnknownCommand("Unkown command!")
コード例 #3
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def make(args):
	try:
		if args[0] == "exit":
			sys.exit(0)
		else:
			raise UnknownCommand("unkown command")
	except IndexError:
		raise UnknownCommand("unkown command")
コード例 #4
0
ファイル: cmethods.py プロジェクト: pirenga/arissploit
	def create(self, args):
		try:
			try:
				completeName = os.path.join(getpath.modules(), args[0]+".py")
				if os.path.exists(completeName):
					print("\033[1;31m[-]\033[0m Module already exists!"+colors.end)

				else:
					mfile = open(completeName, 'w')
					template = os.path.join('core', 'module_template')
					f = open(template, 'r')
					template_contents = f.readlines()
					template_contents[5] = "	\"name\": \""+args[0]+"\", # Module's name (should be same as file name)\n"
					template_contents[11] = "	\"initdate\": \""+(time.strftime("%d.%m.%Y"))+"\", # Initial date\n"
					template_contents[12] = "	\"lastmod\": \""+(time.strftime("%d.%m.%Y"))+"\", # Last modification\n"
					mfile.writelines(template_contents)
					mfile.close()
					printSuccess("Saved to modules/"+ args[0] +".py!")

			except IndexError:
				printError("Please enter module name!")

			except PermissionError:
				printError("Permission denied!")

			except IOError:
				printError("Something went wrong!")

		except IndexError:
			raise UnknownCommand("\033[1;31m[-]\033[0m Unrecognized command!")
コード例 #5
0
ファイル: cmethods.py プロジェクト: limkokhole/arissploit
 def back(self, args):
     if self.mm.moduleLoaded == 1:
         self.mm.moduleLoaded = 0
         self.mm.moduleName = ""
     else:
         raise UnknownCommand("[" + colors.bold + colors.red + "err" +
                              colors.end + "] Unrecognized command!")
コード例 #6
0
	def mcu(self, command):
		try:
			if command[0] in self.modadd.customcommands.keys():
				call = getattr(self.modadd, command[0])
				try:
					return call(command[1:])
				except Exception as e:
					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+"] Unrecognized command!")
		except AttributeError:
			raise UnknownCommand("["+colors.bold+colors.red+"err"+colors.end+"] Unrecognized command!")
コード例 #7
0
ファイル: cmethods.py プロジェクト: swagkarna/arissploit
	def list(self, args):
		if args[0] == "dependencies":
			if self.mm.moduleLoaded == 0:
				modules = glob.glob(getpath.modules()+"*.py")
				dependencies = []
				for module in modules:
					try:
						modadd = importlib.import_module("modules."+os.path.basename(module).replace(".py", ""))
						for dep in modadd.conf["dependencies"]:
							if dep not in dependencies:
								dependencies.append(dep)
					except ImportError:
						print(colors.red+"import error: "+os.path.basename(module).replace(".py", "")+colors.end)
						break
					except KeyError:
						pass
				for dep in dependencies:
					print(dep)
			else:
				try:
					for dep in self.modadd.conf["dependencies"]:
						print(dep)
				except KeyError:
					printInfo("This module doesn't require any dependencies!")
		else:
			raise UnknownCommand("Unknown command!")
コード例 #8
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!")
コード例 #9
0
	def init(self, args):
		if self.mm.moduleLoaded == 1:
			try:
				self.modadd.init()
				printSuccess("Module has been initialized!")
			except AttributeError:
				printError("This module doesn't have init function!")
		else:
			raise UnknownCommand("["+colors.bold+colors.red+"err"+colors.end+"] Unrecognized command!")
コード例 #10
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def check(args):
	try:
		if args[0] == "module":
			try:
				modadd = globals()[args[1]]
				print(colors.green+"module found"+colors.end)
				check_module.modadd = modadd
				check_module.check()

			except(IndexError):
				print(colors.red + "please enter module name"+ colors.end)

			except Exception as error:
				print(colors.red + "error: module not found ("+str(error)+")"+ colors.end)
		else:
			raise UnknownCommand("unknown command")
	except IndexError:
		raise UnknownCommand("unkown command")
コード例 #11
0
ファイル: cmethods.py プロジェクト: pirenga/arissploit
	def init(self, args):
		if self.mm.moduleLoaded == 1:
			try:
				self.modadd.init()
				printSuccess("Module has been initialized!")
			except AttributeError:
				printError("This module does not have init function!")
		else:
			raise UnknownCommand("\033[1;31m[-]\033[0m Unrecognized command!")
コード例 #12
0
ファイル: cmethods.py プロジェクト: swagkarna/arissploit
	def init(self, args):
		if self.mm.moduleLoaded == 1:
			try:
				self.modadd.init()
				print("Module initialized!")
			except AttributeError:
				print("This module doesn't have init function!")
		else:
			raise UnknownCommand("Unknown command!")
コード例 #13
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def show(args):
	try:
		if args[0] == "modules" and mm.moduleLoaded == 0:
			t = PrettyTable([colors.green+'Modules:', ''+colors.end])
			t.add_row(['',''])
			t.align = 'l'
			t.valing = 'm'
			t.border = False

			for key, val in module_database.database.items():
					t.add_row([key, val])

			print (t)
		elif args[0] == "options" and mm.moduleLoaded == 1:
			moduleop.printoptions(modadd)
		else:
			raise UnknownCommand("module not loaded or unknown command")
	except IndexError:
		raise UnknownCommand("unknown command")
コード例 #14
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def mcu(command):
	global modadd

	try:
		if command in modadd.customcommands:
			try:
				modadd.terminal = terminal
			except NameError:
				pass
			call = getattr(modadd, command)
			try:
				call()
			except Exception as e:
				print(colors.red+"error: module is corrupted\n")
				traceback.print_exc(file=sys.stdout)
				print(colors.end)
		else:
			raise UnknownCommand("unknown command")
	except AttributeError:
		raise UnknownCommand("unknown command")
コード例 #15
0
    def use(self, args):
        init = False
        if "modules." + args[0] not in sys.modules:
            init = True

        if self.mm.moduleLoaded == 0:
            try:
                self.modadd = importlib.import_module("modules." + args[0])
                self.mm.moduleLoaded = 1
                self.mm.setName(self.modadd.conf["name"])
                try:
                    print(self.modadd.conf["message"])
                except KeyError:
                    pass
                try:
                    if self.modadd.conf["outdated"] == 1:
                        printWarning(
                            "This module is outdated and might not be working!"
                        )
                except KeyError:
                    pass
                try:
                    if self.modadd.conf["needroot"] == 1:
                        if not os.geteuid() == 0:
                            printWarning(
                                "This module requires root permissions!")
                except KeyError:
                    pass
                if init == True:
                    try:
                        self.modadd.init()
                    except AttributeError:
                        pass
            except ImportError:
                print("[" + colors.bold + colors.red + "err" + colors.end +
                      "] Module is not found!")
                raise ModuleNotFound("[" + colors.bold + colors.red + "err" +
                                     colors.end + "] Module is not found!")
            except IndexError:
                print("[" + colors.bold + colors.red + "err" + colors.end +
                      "] Module is not found!")
                raise ModuleNotFound("[" + colors.bold + colors.red + "err" +
                                     colors.end + "] Module is not found!")
            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 in use!")
コード例 #16
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def run(args):
	global modadd

	if mm.moduleLoaded == 1:
		try:
			modadd.run()
		except Exception as error:
			print(colors.red+"error: module is corrupted\n")
			traceback.print_exc(file=sys.stdout)
			print(colors.end)
	else:
		raise UnknownCommand("module not loaded")
コード例 #17
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def use(args):
	global modadd
	if mm.moduleLoaded == 0:
		try:
			modadd = globals()[args[0]]
			mm.moduleLoaded = 1
			mm.setName(modadd.name)
		except KeyError:
			print(colors.red + "module not found" + colors.end)
		except IndexError:
			print(colors.red + "please enter module name" + colors.end)
	else:
		raise UnknownCommand("module in use")
コード例 #18
0
ファイル: cmethods.py プロジェクト: swagkarna/arissploit
	def check(self, args):
		try:
			if args[0] == "module":
				try:
					self.modadd = importlib.import_module("modules."+args[1])
					print(colors.green+"module found"+colors.end)
					check_module(self.modadd)
					print(colors.green+"\ntest passed"+colors.end)

				except IndexError:
					print(colors.red + "Please enter module name!"+ colors.end)

				except ImportError:
					print(colors.red+"Error: module not found!"+colors.end)

				except:
					print(colors.red + "error:\n")
					traceback.print_exc(file=sys.stdout)
					print(colors.end)
			else:
				raise UnknownCommand("Unknown command!")
		except IndexError:
			raise UnknownCommand("Unkown command!")
コード例 #19
0
ファイル: cmethods.py プロジェクト: S0U1SB4N3/arissploit
	def run(self, args):
		if self.mm.moduleLoaded == 1:
			try:
				return self.modadd.run()

			except KeyboardInterrupt:
				print("["+colors.bold+colors.red+"err"+colors.end+"] Module terminated!"+colors.end)
			except PermissionError:
				printError("Permission denied!")
				return "[err] Permission denied!"
			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 is not loaded!")
コード例 #20
0
ファイル: cmethods.py プロジェクト: pirenga/arissploit
	def back(self, args):
		if self.mm.moduleLoaded == 1:
			self.mm.moduleLoaded = 0
			self.mm.moduleName = ""
		else:
			raise UnknownCommand("\033[1;31m[-]\033[0m Unrecognized command!")
コード例 #21
0
ファイル: cmethods.py プロジェクト: clicknull/usploit
def back(args):
	if mm.moduleLoaded == 1:
		mm.moduleLoaded = 0
		mm.moduleName = ""
	else:
		raise UnknownCommand("unknown command")
コード例 #22
0
ファイル: cmethods.py プロジェクト: swagkarna/arissploit
	def back(self, args):
		if self.mm.moduleLoaded == 1:
			self.mm.moduleLoaded = 0
			self.mm.moduleName = ""
		else:
			raise UnknownCommand("Unknown command!")