本文整理汇总了Python中scanner.Scanner.resolve_target方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.resolve_target方法的具体用法?Python Scanner.resolve_target怎么用?Python Scanner.resolve_target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner.Scanner
的用法示例。
在下文中一共展示了Scanner.resolve_target方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import resolve_target [as 别名]
def main():
# Include current path in case we attempt to load modules.
sys.path.append(os.getcwd())
parser = argparse.ArgumentParser("Runs a set of tests against the set of provided URLs")
parser.add_argument("-u", "--url", action="append", dest="targets", help="Add a target to test")
parser.add_argument("-f", "--target-file", action="append", dest="target_files", help="File with URLs to test")
parser.add_argument("-m", "--module", action="append", default = [], dest="modules", help="Load an extension module")
parser.add_argument("-D", "--disable-core", action="store_true", default = False, dest="disable_core", help="Disable corechecks")
parser.add_argument("-p", "--force-passive", action="store_true", default=False, dest="force_passives", help ="Force passives to be run for each active test")
parser.add_argument("-d", "--dns", action="store_false", default=True, dest="resolve_target", help ="Skip DNS resolution when registering a target")
parser.add_argument("-r", "--report", action="store", default="xml", dest="report",help="Load a reporter e.g. -r reporter.AntXmlReporter")
parser.add_argument("-o", "--output", action="store", default="garmr-results.xml", dest="output", help="Default output is garmr-results.xml")
parser.add_argument("-c", "--check", action="append", dest="opts", help="Set a parameter for a check (check:opt=value)" )
parser.add_argument("-e", "--exclude", action="append", dest="exclusions", help="Prevent a check from being run/processed")
parser.add_argument("--save", action="store", dest="dump_path", help="Write out a configuration file based on parameters (won't run scan)")
args = parser.parse_args()
scanner = Scanner()
scanner.force_passives = args.force_passives
scanner.resolve_target = args.resolve_target
scanner.output = args.output
# Start building target list.
if args.targets != None:
for target in args.targets:
scanner.register_target(target)
# Add targets from files to the list.
if args.target_files != None:
for targets in args.target_files:
try:
f = open(targets, "r")
for target in f:
t = target.strip()
if len(t) > 0:
scanner.register_target(t)
except:
Scanner.logger.error("Unable to process the target list in: %s", targets)
# Load built-in modules if required.
if args.disable_core == False:
corechecks.configure(scanner)
# Configure modules.
# TODO: change the module loading to scan the list of classes in a module and automagically
# detect any tests defined.
if args.modules != None:
for module in args.modules:
try:
__import__(module)
m = sys.modules[module]
m.configure(scanner)
except Exception, e:
Scanner.logger.fatal("Unable to load the requested module [%s]: %s", module, e)
quit()