(Aug-04-2020, 04:36 PM)Axel_Erfurt Wrote: [ -> ]x = {'host': 'xxx.xx.xxx.x', 'protocol': 'tcp', 'portid': '1', 'state': 'filtered', 'reason': 'no-response'}
print(f"host: {x['host']}\nprotocol: {x['protocol']}\nportid: {x['portid']}\nstate: {x['state']}")
Hello Axel
It's a good idea but in reality X is a string and not a dictionary and I can't seem to change it.
your idea fonction but with dictionary.
Excuse me I don't mention this
(Aug-05-2020, 04:23 AM)buran Wrote: [ -> ]your x looks like poorly formatted json - i.e. you have opening [ and {, but not closing them. Also you use " around the key "xxx.xx.xxx.x" and your string is enclosed in "", i.e. sample x will raise error anyway.
post actual value of x (i.e. I am asking for properly formatted example, not "real" values).
then, if I am right - you can use json to parse it or maybe ast.literal_eval
Thank you for your reponse buran but the key enclosed in "" is the spelling of Nmap fonction .
X is an part of a Nmap tram
the full tram is:
but I can suppr {"172.217.23.131": [
x = {"172.217.23.131": [{'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '1', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'tcpmux', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '2', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'compressnet', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '3', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'compressnet', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '4', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '5', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'rje', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '6', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '7', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'echo', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '8', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '9', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'discard', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '10', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf':'3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '11', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'systat', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '12', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '13', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl':'0', 'service': {'name': 'daytime', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '14', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '15', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl':'0', 'service': {'name': 'netstat', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '16', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'unknown', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '17', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl':'0', 'service': {'name': 'qotd', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '18', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'msp', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '19', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'chargen', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '20', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'ftp-data', 'method': 'table', 'conf': '3'}},{'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '21', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'ftp', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '22', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'ssh', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '23', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'telnet', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '24', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'priv-mail', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '25', 'state': 'open', 'reason': 'syn-ack', 'reason_ttl': '0', 'service': {'name': 'smtp', 'method': 'table', 'conf': '3'}}, {'host': '172.217.23.131', 'protocol': 'tcp', 'portid': '26', 'state': 'filtered', 'reason': 'no-response', 'reason_ttl': '0', 'service': {'name': 'rsftp', 'method': 'table', 'conf': '3'}}]}