I got a little bit rusty in Python, could somebody explain what is happening in the following code or give me at least a link to the documentation, where it is explanined?
Actually the part I don't understand is this one:
hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
Here the whole code fragment which it belongs to:
>>> nm.scan(hosts='192.168.1.0/24', arguments='-n -sP -PE -PA21,23,80,3389')
>>> hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
>>> for host, status in hosts_list:
>>> print('{0}:{1}'.host)
192.168.1.0:down
192.168.1.1:up
It uses the Python module python-nmap (https://pypi.python.org/pypi/python-nmap).
What I actually want to archieve is: Print only the IP address that has opened the ports x,y and z.