diff --git a/libnmap/objects/host.py b/libnmap/objects/host.py index 03181c9..3706ec4 100644 --- a/libnmap/objects/host.py +++ b/libnmap/objects/host.py @@ -434,9 +434,13 @@ def extraports_state(self): dictionnary containing state and amount of extra ports scanned for which a common state, usually, closed was discovered. - :return: dict with keys 'state' and 'count' + :return: dict with keys 'state' and 'count' or None """ - _xtrports = self._extras['extraports'] + _xtrports = self._extras.get('extraports', None) + + if _xtrports is None: + return None + return {'state': _xtrports['state'], 'count': _xtrports['count']} @property @@ -445,9 +449,11 @@ def extraports_reasons(self): dictionnary containing reasons why extra ports scanned for which a common state, usually, closed was discovered. - :return: array of dict containing keys 'state' and 'count' + :return: array of dict containing keys 'state' and 'count' or None """ - return self._extras['extraports']['reasons'] + r = self._extras.get('extraports', {}) + + return r.get('reasons', None) def get_dict(self): """