本文整理汇总了Python中zenmapCore.NmapOptions.NmapOptions.parse_string方法的典型用法代码示例。如果您正苦于以下问题:Python NmapOptions.parse_string方法的具体用法?Python NmapOptions.parse_string怎么用?Python NmapOptions.parse_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zenmapCore.NmapOptions.NmapOptions
的用法示例。
在下文中一共展示了NmapOptions.parse_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _profile_entry_changed
# 需要导入模块: from zenmapCore.NmapOptions import NmapOptions [as 别名]
# 或者: from zenmapCore.NmapOptions.NmapOptions import parse_string [as 别名]
def _profile_entry_changed(self, widget):
"""Update the command based on the contents of the target and profile
entries. If the command corresponding to the current profile is not
blank, use it. Otherwise use the current contents of the command
entry."""
profile_name = self.toolbar.get_selected_profile()
target_string = self.toolbar.get_selected_target()
cmd_profile = CommandProfile()
command_string = cmd_profile.get_command(profile_name)
del(cmd_profile)
if command_string == "":
command_string = self.command_toolbar.get_command()
ops = NmapOptions()
ops.parse_string(command_string)
# Use the targets from the command entry, if there are any, otherwise
# use any targets from the profile.
targets = split_quoted(target_string)
if len(targets) > 0:
ops.target_specs = targets
else:
self.toolbar.set_selected_target(join_quoted(ops.target_specs))
self.set_command_quiet(ops.render_string())
示例2: match_option
# 需要导入模块: from zenmapCore.NmapOptions import NmapOptions [as 别名]
# 或者: from zenmapCore.NmapOptions.NmapOptions import parse_string [as 别名]
def match_option(self, option):
log.debug("Match option: %s" % option)
if option == "*" or option == "":
return True
# NOTE: Option matching treats "_" and "-" the same, just like the
# optcmp function in utils.cc . Also, option matching is
# case-sensitive.
option = option.replace("_", "-")
ops = NmapOptions()
ops.parse_string(self.parsed_scan.get_nmap_command())
if "(" in option and ")" in option:
# The syntax allows matching option arguments as
# "opt:option_name(value)". Since we've received only the
# "option_name(value)" part, we need to parse it.
optname = option[:option.find("(")]
optval = option[option.find("(") + 1:option.find(")")]
val = ops["--" + optname]
if val is None:
val = ops["-" + optname]
if val is None:
return False
return str(val) == optval or str(val) == optval
else:
return (ops["--" + option] is not None or
ops["-" + option] is not None)
示例3: _target_entry_changed
# 需要导入模块: from zenmapCore.NmapOptions import NmapOptions [as 别名]
# 或者: from zenmapCore.NmapOptions.NmapOptions import parse_string [as 别名]
def _target_entry_changed(self, editable):
target_string = self.toolbar.get_selected_target()
targets = split_quoted(target_string)
ops = NmapOptions()
ops.parse_string(self.command_toolbar.get_command())
ops.target_specs = targets
self.set_command_quiet(ops.render_string())
示例4: _command_entry_changed
# 需要导入模块: from zenmapCore.NmapOptions import NmapOptions [as 别名]
# 或者: from zenmapCore.NmapOptions.NmapOptions import parse_string [as 别名]
def _command_entry_changed(self, editable):
ops = NmapOptions()
ops.parse_string(self.command_toolbar.get_command())
# Set the target and profile without propagating the "changed" signal
# back to the command entry.
self.set_target_quiet(join_quoted(ops.target_specs))
self.set_profile_name_quiet("")
示例5: NmapCommand
# 需要导入模块: from zenmapCore.NmapOptions import NmapOptions [as 别名]
# 或者: from zenmapCore.NmapOptions.NmapOptions import parse_string [as 别名]
class NmapCommand(object):
"""This class represents an Nmap command line. It is responsible for
starting, stopping, and returning the results from a command-line scan. A
command line is represented as a string but it is split into a list of
arguments for execution.
The normal output (stdout and stderr) are written to the file object
self.stdout_file."""
def __init__(self, command):
"""Initialize an Nmap command. This creates temporary files for
redirecting the various types of output and sets the backing
command-line string."""
self.command = command
self.command_process = None
self.stdout_file = None
self.ops = NmapOptions()
self.ops.parse_string(command)
# Replace the executable name with the value of nmap_command_path.
self.ops.executable = paths_config.nmap_command_path
# Normally we generate a random temporary filename to save XML output
# to. If we find -oX or -oA, the user has chosen his own output file.
# Set self.xml_is_temp to False and don't delete the file when we're
# done.
self.xml_is_temp = True
self.xml_output_filename = None
if self.ops["-oX"]:
self.xml_is_temp = False
self.xml_output_filename = self.ops["-oX"]
if self.ops["-oA"]:
self.xml_is_temp = False
self.xml_output_filename = self.ops["-oA"] + ".xml"
# Escape '%' to avoid strftime expansion.
for op in ("-oA", "-oX", "-oG", "-oN", "-oS"):
if self.ops[op]:
self.ops[op] = escape_nmap_filename(self.ops[op])
if self.xml_is_temp:
self.xml_output_filename = tempfile.mktemp(
prefix=APP_NAME + "-", suffix=".xml")
self.ops["-oX"] = escape_nmap_filename(self.xml_output_filename)
log.debug(">>> Temporary files:")
log.debug(">>> XML OUTPUT: %s" % self.xml_output_filename)
def close(self):
"""Close and remove temporary output files used by the command."""
self.stdout_file.close()
if self.xml_is_temp:
try:
os.remove(self.xml_output_filename)
except OSError, e:
if e.errno != errno.ENOENT:
raise
示例6: ProfileEditor
# 需要导入模块: from zenmapCore.NmapOptions import NmapOptions [as 别名]
# 或者: from zenmapCore.NmapOptions.NmapOptions import parse_string [as 别名]
class ProfileEditor(HIGWindow):
def __init__(self, command=None, profile_name=None,
deletable=True, overwrite=False):
HIGWindow.__init__(self)
self.connect("delete_event", self.exit)
self.set_title(_('Profile Editor'))
self.set_position(gtk.WIN_POS_CENTER)
self.deletable = deletable
self.profile_name = profile_name
self.overwrite = overwrite
# Used to block recursive updating of the command entry when the
# command entry causes the OptionBuilder widgets to change.
self.inhibit_command_update = False
self.__create_widgets()
self.__pack_widgets()
self.profile = CommandProfile()
self.ops = NmapOptions()
if profile_name:
log.debug("Showing profile %s" % profile_name)
prof = self.profile.get_profile(profile_name)
# Interface settings
self.profile_name_entry.set_text(profile_name)
self.profile_description_text.get_buffer().set_text(
prof['description'])
command_string = prof['command']
self.ops.parse_string(command_string)
if command:
self.ops.parse_string(command)
self.option_builder = OptionBuilder(
Path.profile_editor, self.ops,
self.update_command, self.help_field.get_buffer())
log.debug("Option groups: %s" % str(self.option_builder.groups))
log.debug("Option section names: %s" % str(
self.option_builder.section_names))
#log.debug("Option tabs: %s" % str(self.option_builder.tabs))
for tab in self.option_builder.groups:
self.__create_tab(
_(tab),
_(self.option_builder.section_names[tab]),
self.option_builder.tabs[tab])
self.update_command()
def command_entry_changed_cb(self, widget):
command_string = self.command_entry.get_text().decode("UTF-8")
self.ops.parse_string(command_string)
self.inhibit_command_update = True
self.option_builder.update()
self.inhibit_command_update = False
def update_command(self):
"""Regenerate and display the command."""
if not self.inhibit_command_update:
# Block recursive updating of the OptionBuilder widgets when they
# cause a change in the command entry.
self.command_entry.handler_block(self.command_entry_changed_cb_id)
self.command_entry.set_text(self.ops.render_string())
self.command_entry.handler_unblock(
self.command_entry_changed_cb_id)
def update_help_name(self, widget, extra):
self.help_field.get_buffer().set_text(
"Profile name\n\nThis is how the profile will be identified "
"in the drop-down combo box in the scan tab.")
def update_help_desc(self, widget, extra):
self.help_field.get_buffer().set_text(
"Description\n\nThe description is a full description of what "
"the scan does, which may be long.")
def __create_widgets(self):
###
# Vertical box to keep 3 boxes
self.main_whole_box = HIGVBox()
self.upper_box = HIGHBox()
self.middle_box = HIGHBox()
self.lower_box = HIGHBox()
#self.main_vbox = HIGVBox()
self.command_entry = gtk.Entry()
self.command_entry_changed_cb_id = self.command_entry.connect(
"changed", self.command_entry_changed_cb)
self.scan_button = HIGButton(_("Scan"))
self.scan_button.connect("clicked", self.run_scan)
self.notebook = gtk.Notebook()
# Profile info page
#.........这里部分代码省略.........