nmap -sP 192.168.1.* or nmap -sn 192.168.1.0/24
Here is what the above code is Doing:
1. We’re importing the nmap module, which is a Python library for interacting with the nmap command.
2. We’re creating a new instance of the PortScanner class, which is the main class in the nmap module.
3. We’re calling the scan() method on our new PortScanner object, which takes two arguments:
– The IP address or hostname of the device we want to scan.
– The port range we want to scan.
4. We’re printing the results of the scan.