Example #1
0
    def __init__(self, name, status = "running", version = "unknonw"):
        ModelObject.__init__(self)

        self._name          = name
        self._status        = status
        self._version       = version
                                                    
        self._services      = {}
Example #2
0
    def __init__(self, name, status="running", version="unknonw"):
        ModelObject.__init__(self)

        self._name = name
        self._status = status
        self._version = version

        self._services = {}
Example #3
0
 def __init__(self, name, os="Unknown", default_gateway=None, dic=None):
     ModelObject.__init__(self)
     self._interfaces = {}
     self._applications = {}
     self.categories = []
     if dic is not None:
         self._fromDict(dic)
     else:
         self.__init(name, os, default_gateway)
Example #4
0
 def __init__(self, name, os = "Unknown", default_gateway=None, dic=None):
     ModelObject.__init__(self)
     self._interfaces            = {}
     self._applications          = {}
     self.categories             = []
     if dic is not None:
         self._fromDict(dic)
     else:
         self.__init(name, os, default_gateway)
Example #5
0
    def __init__(self, name, protocol="TCP", ports=None, status="running", version="unknown", description=""):
        ModelObject.__init__(self)

        self._name = name
        self.description = description
        self._protocol = protocol
        self._ports = []
        self.setPorts(ports)
        self._status = status
        self._version = version
        self._interfaces = {}
        self._applications = {}
        self._creds = {}
Example #6
0
    def __init__(self,
                 name="",
                 mac="00:00:00:00:00:00",
                 ipv4_address="0.0.0.0",
                 ipv4_mask="0.0.0.0",
                 ipv4_gateway="0.0.0.0",
                 ipv4_dns=[],
                 ipv6_address="0000:0000:0000:0000:0000:0000:0000:0000",
                 ipv6_prefix="00",
                 ipv6_gateway="0000:0000:0000:0000:0000:0000:0000:0000",
                 ipv6_dns=[],
                 network_segment="",
                 hostname_resolution=None):

        ModelObject.__init__(self)

        self._name = name
        self.mac = mac
        self.ipv4 = {
            "address": ipv4_address,
            "mask": ipv4_mask,
            "gateway": ipv4_gateway,
            "DNS": ipv4_dns
        }

        self.ipv6 = {
            "address": ipv6_address,
            "prefix": ipv6_prefix,
            "gateway": ipv6_gateway,
            "DNS": ipv6_dns
        }

        self._services = {}

        self.network_segment = network_segment

        self._hostnames = []
        if hostname_resolution is not None:
            if isinstance(hostname_resolution, (str, unicode)):
                self._hostnames.append(hostname_resolution)
            else:
                self._hostnames = hostname_resolution

        self.amount_ports_opened = 0
        self.amount_ports_closed = 0
        self.amount_ports_filtered = 0

        self.getMetadataHistory().pushMetadataForId(self.getID(),
                                                    self.getMetadata())
Example #7
0
    def __init__(self, name = "", mac = "00:00:00:00:00:00",
                 ipv4_address = "0.0.0.0", ipv4_mask = "0.0.0.0",
                 ipv4_gateway = "0.0.0.0", ipv4_dns = [],
                 ipv6_address = "0000:0000:0000:0000:0000:0000:0000:0000", ipv6_prefix = "00",
                 ipv6_gateway = "0000:0000:0000:0000:0000:0000:0000:0000", ipv6_dns = [],
                 network_segment = "", hostname_resolution = None):

        ModelObject.__init__(self)

                              
        self._name         = name
        self.mac           = mac
        self.ipv4          = {
                                "address" : ipv4_address,
                                "mask"    : ipv4_mask,
                                "gateway" : ipv4_gateway,
                                "DNS"     : ipv4_dns
                            }
             
        self.ipv6         = {
                                "address" : ipv6_address,
                                "prefix"    : ipv6_prefix,
                                "gateway" : ipv6_gateway,
                                "DNS"     : ipv6_dns
                            }

                                                    
        self._services      = {}

                                                                      
        self.network_segment       = network_segment

                                                     
        self._hostnames=[]
        if hostname_resolution is not None:
            if isinstance(hostname_resolution, (str,unicode)):
                self._hostnames.append(hostname_resolution)
            else:
                self._hostnames = hostname_resolution

                         
                                                                         
                                                                      
        self.amount_ports_opened   = 0
        self.amount_ports_closed   = 0
        self.amount_ports_filtered = 0

        self.getMetadataHistory().pushMetadataForId(self.getID(), self.getMetadata())
Example #8
0
    def __init__(self,
                 name,
                 protocol="TCP",
                 ports=None,
                 status="running",
                 version="unknown",
                 description=""):
        ModelObject.__init__(self)

        self._name = name
        self.description = description
        self.setProtocol(protocol)
        self._ports = []
        self.setPorts(ports)
        self._status = status
        self._version = version
        self._interfaces = {}
        self._applications = {}
        self._creds = {}
Example #9
0
    def __init__(self, name, qapp, gui_parent, model_controller,
                 plugin_controller, close_callback=None):

        ModelObject.__init__(self)
        self._id = self.get_id()
        self.name = name

        # a reference used to add new hosts
        self._model_controller = model_controller

        # create the widget
        self.widget = ShellWidget(qapp,gui_parent,name)
        self.widget.setupLayout()

        # For safesty we don't use the user shell, we force it to bash
        progname = "/bin/bash"
        # create the session
        #Session(gui, pgm, args, term, sessionid='session-1', cwd=None):
        #self.process_controller = ProcessController()
        self.session = Session(self.widget, progname, [], "xterm", name);

        self.session.setConnect(True)
        self.session.setHistory(HistoryTypeBuffer(1000))
        self._setUpSessionSinalHandlers()

        #self.__last_user_input = None
        #self.__user_input_signal = False

        # flag that determines if output has to be ignored
        self.__ignore_process_output = False
        self.__ignore_process_output_once = False
        self.__first_process_output = True
        self.__save_output_prompt_format = False

        # determines if input is for an interactive command or not
        self.__interactive = False

        #TODO: check if we need to connect to this signal
        self.session.myconnect('done', self.close)

        # instance a new plugin controller
        self.plugin_controller = plugin_controller(self.id)

        self._initial_prompt = ""
        #self._custom_prompt_format = re.compile("\\x1B\[1;32m\[.+@.+\s.+\]>(\$|#)\s+\\x1B\[m")
        #self._custom_prompt_format = re.compile("\[.+@.+\s.+\]>(\$|#)\s+")
        self._custom_prompt_format = re.compile("\[(?P<user>.+)@(?P<host>.+):(?P<path>.+)\]>(\$|#)")
        #TODO: somewhere in the config there should be a list of regexes used to match
        # prompts. Be careful with this because if regexes are too generic they will
        # match more that is needed.
        self._generic_prompt_formats = []
        #XXX: adding this format just as a test! This should be in the config somehow
        # Also this may be is too generic to use...
        self._generic_prompt_formats.append(re.compile("^.+@.+:.+(\$|#)$"))
        
        #This is a reference to MainApplication.deleteShellEnvironment
        self._close_callback = close_callback 
        
        # flag that determines if shell environment is running
        self.__running = False
        
        #Autocomplete
        self._options=[] #only keys
        self._tname="" # last tool executed
        self._lcount=0
        self._optionsh={} #keys + help
        self.__command = ''
Example #10
0
    def __init__(self, name, qapp, gui_parent, model_controller,
                 plugin_controller, close_callback=None):

        ModelObject.__init__(self)
        self._id = self.get_id()
        self.name = name

        # a reference used to add new hosts
        self._model_controller = model_controller

        # create the widget
        self.widget = ShellWidget(qapp,gui_parent,name)
        self.widget.setupLayout()

        # For safesty we don't use the user shell, we force it to bash
        progname = "/bin/bash"
        # create the session
        #Session(gui, pgm, args, term, sessionid='session-1', cwd=None):
        #self.process_controller = ProcessController()
        self.session = Session(self.widget, progname, [], "xterm", name);

        self.session.setConnect(True)
        self.session.setHistory(HistoryTypeBuffer(1000))
        self._setUpSessionSinalHandlers()

        #self.__last_user_input = None
        #self.__user_input_signal = False

        # flag that determines if output has to be ignored
        self.__ignore_process_output = False
        self.__ignore_process_output_once = False
        self.__first_process_output = True
        self.__save_output_prompt_format = False

        # determines if input is for an interactive command or not
        self.__interactive = False

        #TODO: check if we need to connect to this signal
        self.session.myconnect('done', self.close)

        # instance a new plugin controller
        self.plugin_controller = plugin_controller(self.id)

        self._initial_prompt = ""
        #self._custom_prompt_format = re.compile("\\x1B\[1;32m\[.+@.+\s.+\]>(\$|#)\s+\\x1B\[m")
        #self._custom_prompt_format = re.compile("\[.+@.+\s.+\]>(\$|#)\s+")
        self._custom_prompt_format = re.compile("\[(?P<user>.+)@(?P<host>.+):(?P<path>.+)\]>(\$|#)")
        #TODO: somewhere in the config there should be a list of regexes used to match
        # prompts. Be careful with this because if regexes are too generic they will
        # match more that is needed.
        self._generic_prompt_formats = []
        #XXX: adding this format just as a test! This should be in the config somehow
        # Also this may be is too generic to use...
        self._generic_prompt_formats.append(re.compile("^.+@.+:.+(\$|#)$"))
        
        #This is a reference to MainApplication.deleteShellEnvironment
        self._close_callback = close_callback 
        
        # flag that determines if shell environment is running
        self.__running = False
        
        #Autocomplete
        self._options=[] #only keys
        self._tname="" # last tool executed
        self._lcount=0
        self._optionsh={} #keys + help
        self.__command = ''