def getBlacklists(self): """ @brief Get The Local Preset Status Code Related Blacklist @param self The Object @return Target Blacklist Dictionary """ blacklists = {} # Target Dictionary (Consists of Status Code Lists) # 400 -> Bad Request, 403 -> Forbidden, 500 ->Internal Server Error db_Path = FileUtils.createPath(self.script_path, 'db') # Local DB Path for status in [400, 403, 500]: blacklistFileName = FileUtils.createPath( # Join Status Code as Filename (e.g. 403_blacklist.txt) db_Path, '{}_blacklist.txt'.format(status)) blacklists[status] = [] # Status Code List Contained In Dictionary if not FileUtils.canRead(blacklistFileName): continue # Skip Unreadable File for line in FileUtils.getLines(blacklistFileName): if line.lstrip().startswith('#'): continue # Skip Comments In The File blacklists[status].append(line) return blacklists
def getLines(self): for line in FileUtils.getLines(self.path): yield line
def __init__(self, script_path, arguments, output): # Load The Local Custom Banner, Version & Author Info global Version_Pattern path_banner = FileUtils.createPath(script_path, "sources", "CLI_Banner.txt") path_version_author = FileUtils.createPath(script_path, "sources", "CLI_Version_Author.txt") CLI_Banner = open(path_banner).read() CLI_Version_Author = open(path_version_author).read().format( **Version_Pattern) self.output = output self.output.header(CLI_Banner) self.output.versionAuthor(CLI_Version_Author) self.arguments = arguments self.script_path = script_path self.savePath = script_path self.blacklists = self.getBlacklists() self.recursive = self.arguments.recursive self.suppressEmpty = self.arguments.suppressEmpty self.excludeSubdirs = (arguments.excludeSubdirs if arguments.excludeSubdirs is not None else []) self.excludeStatusCodes = self.arguments.excludeStatusCodes self.DirQue = Queue() # Standard FIFO Queue --> Storing Dirs self.fuzzer = None self.batch = False self.batchSession = None self.exit = False # Custom Save Path, Reports Path if self.arguments.saveHome: self.savePath = self.saveHomeOption() # Error Logs Path self.errorLog = None self.errorLogPath = None self.errorLogLock = Lock() self.errorLogPath = self.getErrorPath() self.errorLog = open(self.errorLogPath, "w") # Reports & Local Directory Paths self.reportsPath = None self.directoryPath = None self.dictionary = Dictionary( self.arguments.wordlist, self.arguments.extensions, self.arguments.lowercase, self.arguments.forceExtensions) # Auto Save Check if self.arguments.autoSave and len(self.arguments.urlList) > 1: self.setupBatchReports() self.output.newLine("\nAutoSave Path: {0}".format( self.batchDirectoryPath)) # Random Agents Check if self.arguments.useRandomAgents: self.randomAgents = FileUtils.getLines( FileUtils.createPath(script_path, "db", "user-agents.txt")) # Print Out The Custom Extension, Threads Number & Dictionary Size self.printBasicConf() self.dirScanning() # Main Directory Scanning Method self.output.warning("\nScanning Completed !") # Scanning Completed
def parser(self): tmp_dict = [] for line in FileUtils.getLines(self.dicfile): #line的格式为admin:admin tmp_dict.append(line) return tmp_dict