This script scans a network then it creates a yaml file with the list of hosts found. ![]() run () # Display the IP address of all the hosts found for i in my_scan. Networkscan ( my_network ) # Run the scan of hosts using pings my_scan. Python script: #!/usr/bin/env python3 # Import Python library import networkscan # Main function if _name_ = '_main_' : # Define the network to scan my_network = "192.168.0.0/24" # Create the object my_scan = networkscan. The following script just scan a network then displays the list of host found. Hosts.yaml: - device1 : hostname : 192.168.0.1 groups : - device_discovered device2 : hostname : 192.168.0.100 groups : - device_discovered device3 : hostname : 192.168.0.101 groups : - device_discovered device4 : hostname : 192.168.0.10 groups : - device_discovered device5 : hostname : 192.168.0.11 groups : - device_discovered device6 : hostname : 192.168.0.12 groups : - device_discovered device7 : hostname : 192.168.0.111 groups : - device_discovered With the command "networkscan.py 192.168.0.0/23 -m -w foo.yaml" you do create a file named "foo.yaml". Please note that when no file is specified with the parameter "-w" then a "hosts.yaml" file is created by default. networkscan.py 192.168.0.0/25 -q >inventory.txtĤ - How to scan a /23 network then save the list of hosts into a yaml file compatible with Nornir syntax (mute mode and creation of a yaml file) networkscan.py 192.168.0.0/28 -qĤ - How to scan a /25 network then to save the list of hosts into a text file (quiet mode and redirection of the output into a file) Number of hosts found: 7 (project1 ) python ]$ģ - How to scan a /28 network displaying just the name of the hosts (quiet mode) ![]() m Mute mode (nothing is displayed on screen ) -q Quiet mode (just the list of hosts found is displayed ) -w Write a yaml host file with an optional filename (default name is hosts.yaml ) (project1 ) python ]$ Here are the available options for the software: (project1 ) python ]$. Networkscan requires python 3 and the following python libraries: it can create a yaml host inventory compatible with Nornir.it can create a list of IP address hosts as a output for easy IP address manipulation.it can be used as a command line program or as a python library.it can perform fast pings (thanks to the use of coroutines).It can be used in command line or as a python library. Networkscan is a fast host scanner written in python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |