Python-nmap use

Source: Internet
Author: User

Installation

[[email protected] ~]# yum-y install nmap[[email protected] ~]# pip install Python-nmap

Use

Import Nmap # Imports nmap.py module NM = Nmap. Portscanner () # Get Portscanner object Nm.scan (' 127.0.0.1 ', ' 22-443 ') # Scan host 127.0.0.1 port number 22-443 nm.command_line () # Get command line for scanning : Nmap-ox-P 22-443 127.0.0.1nm.scaninfo () # Gets the information for this scan {' TCP ': {' services ': ' 22-443 ', ' method ': ' Connect '}}nm.all_hosts ( # Get all scanned hosts nm[' 127.0.0.1 '].hostname () # Get 127.0.0.1 hostname nm[' 127.0.0.1 '].hostnames () # Gets the host name of the list format Dict 127.0.0.1 # such as [ {' name ': ' hostname1 ', ' type ': ' PTR '}, {' name ': ' hostname2 ', ' type ': ' User '}]nm[' 127.0.0.1 '].state () # Gets the state of the host 127.0.0.1 ( up|down|unknown|skipped) nm[' 127.0.0.1 ' [' TCP '].keys () # Get all TCP ports nm[' 127.0.0.1 '].all_tcp () # Get all TCP ports (sorted) nm[' 127.0.0.1 '].all_udp () # ibid. nm[' 127.0.0.1 '].all_ip () # ibid. nm[' 127.0.0.1 '].all_sctp () # ibid. nm[' 127.0.0.1 '].has_tcp (22) # Whether it contains 22 port information for host 127.0.0.1 nm[' 127.0.0.1 ' [' TCP '][22] # get all the information for host 127.0.0.1 22 port (TCP) nm[' 127.0.0.1 '].tcp (22) # Get host 127.0 .0.1 22 Port All information nm[' 127.0.0.1 ' [' TCP '][22][' state '] # Gets the status of host 127.0.0.1 22 port (TCP) (Open|closed|filter)

Python-nmap using

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.