本文整理汇总了Python中utils.Utils.isReadable方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.isReadable方法的具体用法?Python Utils.isReadable怎么用?Python Utils.isReadable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Utils
的用法示例。
在下文中一共展示了Utils.isReadable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: displayNmapMenu
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import isReadable [as 别名]
def displayNmapMenu(self):
while True:
self.display.output()
self.display.output("---------------------------------------")
self.display.output()
self.display.output("Current NMAP Settings: ")
self.display.output("Scan Type: %s" % (self.config["scan_type"]))
self.display.output("Flags: %s" % (self.config["scan_flags"]))
self.display.output("Port Range: %s" % (self.config["scan_port_range"]))
self.display.output("Target: %s" % (self.config["scan_target"]))
self.display.output("Target List: %s" % (self.config["scan_target_list"]))
self.display.output("Set: (s)can type, extra (f)lags, (p)ort range, (t)arget, target (l)ist, (m)ain menu")
self.display.output()
userChoice = self.display.input("Choose An Option: ")
if userChoice == "s":
self.config["scan_type"] = self.display.input("Choose S, T, U, ST, SU, TU: ")
elif userChoice == "f":
self.config["scan_flags"] = self.display.input("Set Extra Flags (ex: -A -Pn -T4): ")
elif userChoice == "p":
self.config["scan_port_range"] = self.display.input("Enter Range (1-65535): ")
elif userChoice == "t":
self.config["scan_target"] = self.display.input("Enter Target or Range (X.X.X.X/Y): ")
self.config["scan_target_list"] = None
elif userChoice == "l":
filePath = self.display.input("Enter File Path (/tmp/targets.txt): ")
if Utils.isReadable(filePath):
self.config["scan_target"] = None
self.config["scan_target_list"] = filePath
else:
self.display.error("Unable to read file")
elif userChoice == "m":
break
else:
self.display.error("%s - Not a valid option" % (userChoice))
示例2: loadConfig
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import isReadable [as 别名]
def loadConfig(self):
# does config file exist?
if (("config_filename" in self.config) and (self.config["config_filename"] is not None)):
temp1 = self.config
temp2 = Utils.loadConfig(self.config["config_filename"])
self.config = dict(temp2.items() + temp1.items())
else:
# guess not.. so try to load the default one
if Utils.isReadable(self.config["miscDir"] + "default.cfg"):
self.display.verbose("a CONFIG FILE was not specified... defaulting to [default.cfg]")
temp1 = self.config
temp2 = Utils.loadConfig(self.config["miscDir"] + "default.cfg")
self.config = dict(temp2.items() + temp1.items())
else:
# someone must have removed it!
self.display.error("a CONFIG FILE was not specified...")
self.cleanup()
# set verbosity/debug level
if ("verbose" in self.config):
if (self.config['verbose'] >= 1):
self.display.enableVerbose()
if (self.config['verbose'] > 1):
self.display.enableDebug()
if ((self.config["lhost"] == None) or (self.config["lhost"] == "")):
self.display.error("No IP was able to be determined and one was not provided.")
self.display.error("Please specify one via the [--ip <ip>] argument.")
self.cleanup()
示例3: __init__
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import isReadable [as 别名]
def __init__(self):
self.display = Display()
self.modulelock = RLock()
self.inputModules = {}
self.actionModules = {}
self.reportModules = {}
self.progName = "APT2"
self.version = "None"
try:
self.version = pkg_resources.get_distribution("apt2").version
except:
None
if Utils.isReadable('VERSION'):
version_pattern = "'(\d+\.\d+\.\d+[^']*)'"
self.version = re.search(version_pattern, open('VERSION').read()).group(1)
self.isRunning = True # Conditional to check if user wants to quit
self.inputs = {}
self.config = {}
self.config["homeDir"] = expanduser("~")
self.config["outDir"] = self.config["homeDir"] + "/.apt2/"
self.config["reportDir"] = ""
self.config["logDir"] = ""
self.config["proofsDir"] = ""
self.config["tmpDir"] = ""
self.config["pkgDir"] = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/"
self.config["miscDir"] = ""
self.config['lhost'] = Utils.getIP()
self.setupDirs()
# initialize some config options
self.config["config_filename"] = ""
# default all bool values to False
self.config["verbose"] = False
self.config["always_yes"] = False
self.config["list_modules"] = False
self.config["scan_target"] = None
self.config["scan_target_list"] = None
self.config["safe_level"] = 4
self.config["exclude_types"] = ""
# make temp file for the KB save file
self.kbSaveFile = self.config["proofsDir"] + "KB-" + Utils.getRandStr(10) + ".save"
self.threadcount_thread = None
self.keyevent_thread = None
self.allFinished = False
示例4: loadConfig
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import isReadable [as 别名]
def loadConfig(self):
# does config file exist?
if (("config_filename" in self.config) and (self.config["config_filename"] is not None)):
temp1 = self.config
temp2 = Utils.load_config(self.config["config_filename"])
self.config = dict(temp2.items() + temp1.items())
else:
# guess not.. so try to load the default one
if Utils.isReadable("default.cfg"):
self.display.verbose("a CONFIG FILE was not specified... defaulting to [default.cfg]")
temp1 = self.config
temp2 = Utils.loadConfig("default.cfg")
self.config = dict(temp2.items() + temp1.items())
else:
# someone must have removed it!
self.display.error("a CONFIG FILE was not specified...")
self.cleanup()
# set verbosity/debug level
if ("verbose" in self.config):
if (self.config['verbose'] >= 1):
self.display.enableVerbose()
if (self.config['verbose'] > 1):
self.display.enableDebug()
示例5: parseParameters
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import isReadable [as 别名]
def parseParameters(self, argv):
parser = argparse.ArgumentParser()
# ==================================================
# Input Files
# ==================================================
filesgroup = parser.add_argument_group('inputs')
filesgroup.add_argument("-C",
metavar="<config.txt>",
dest="config_file",
action='store',
help="config file")
filesgroup.add_argument("-f",
metavar="<input file>",
dest="inputs",
default=[],
action='store',
help="one of more input files seperated by spaces",
nargs='*')
filesgroup.add_argument("--target",
metavar="",
dest="scan_target",
action='store',
help="initial scan target(s)")
# ==================================================
# Advanced Flags
# ==================================================
advgroup = parser.add_argument_group('advanced')
advgroup.add_argument("--ip",
metavar="<local IP>",
dest="lhost",
default=Utils.getIP(),
action='store',
help="defaults to %s" % Utils.getIP())
# ==================================================
# Optional Args
# ==================================================
parser.add_argument("-v", "--verbosity",
dest="verbose",
action='count',
help="increase output verbosity")
parser.add_argument("-s", "--safelevel",
dest="safe_level",
action='store',
default=4,
help="set min safe level for modules. 0 is unsafe and 5 is very safe. Default is 4")
parser.add_argument("-x", "--exclude",
dest="exclude_types",
action="store",
default="",
help="specify a comma seperatec list of module types to exclude from running")
# parser.add_argument("-b", "--bypassmenu",
# dest="bypass_menu",
# action='store_true',
# help="bypass menu and run from command line arguments")
# ==================================================
# Misc Flags
# ==================================================
miscgroup = parser.add_argument_group('misc')
miscgroup.add_argument("--listmodules",
dest="list_modules",
action='store_true',
help="list out all current modules and exit")
# parse args
args = parser.parse_args()
# convert parameters to values in the config dict
self.config["config_filename"] = args.config_file
self.config["verbose"] = args.verbose
self.config["list_modules"] = args.list_modules
self.config["scan_target"] = args.scan_target
self.config["safe_level"] = int(args.safe_level)
self.config["exclude_types"] = args.exclude_types
self.config['lhost'] = args.lhost
# self.config["bypass_menu"] = args.bypass_menu
for f in args.inputs:
if (Utils.isReadable(f)):
type = self.idFileType(f)
if (type):
if type in self.inputs:
self.inputs[type].append(f)
else:
self.inputs[type] = [f]
else:
print "Can not access [" + f + "]"