Exemplo n.º 1
0
def get_options(req):
    options = NmapOptions(Path.options)
    opt_list = [options.get_option(id) for id in options.get_options_list() \
            if req.POST.get("search", "").lower() in id.lower()]
    str_opt = []
    for option in opt_list:
        data = ["'%s': '%s'" % item for item in option.items()]
        str_opt.append("{%s}" % ",".join(data))
    return HttpResponse("[%s]" % ",".join(str_opt))
Exemplo n.º 2
0
    def __fill_sections(self, root_node):
        groups = root_node.getElementsByTagName(
            "groups")[0].getElementsByTagName("group")
        nmapOptions = NmapOptions(Path.options)
        for group in groups:
            name = group.getAttribute("name")
            element = root_node.getElementsByTagName(name)[0]
            dic = {}
            dic[name] = dict(label=element.getAttribute("label"), options=[])

            for node in element.childNodes:
                if node.__class__ is minidom.Element:
                    option = dict(label=node.getAttribute("label"))
                    if node.tagName == "option_list":
                        option["type"] = "list"
                        option["options"] = []
                        for opt in node.childNodes:
                            if opt.__class__ == minidom.Element:
                                option_name = opt.getAttribute("name").replace(
                                    "'", "\\'")
                                x = {
                                    "name":
                                    option_name,
                                    "command":
                                    nmapOptions.get_option(option_name)
                                    ['option']
                                }
                                option["options"].append(x)
                    elif node.tagName == "option_check":
                        option["type"] = "check"
                        option["option"] = node.getAttribute("option")
                        option["command"] = nmapOptions.get_option(
                            node.getAttribute("option"))["option"]
                        if node.getAttribute("arg_type"):
                            option["arg_type"] = node.getAttribute("arg_type")
                    dic[name]['options'].append(option)
            self.sections.append(dic)
Exemplo n.º 3
0
 def __init__(self, options={}):
     self.options = {}
     self.option_profile = NmapOptions(options_file)
     for k, v in options.items():
         self.add_option(k, v, False)  # TODO: check this place further