The shell script realizes the network scan Automatic Packet capture protocol analysis Nmap

Source: Internet
Author: User

This article provides thought-based usage: about the automatic detection feature, the various ports and the capture function, the project used for Nmap software, Linux operating system, first we want to install NMAP software project used in the nmap-6.40-7.el7.x86_64 version,

The command format is: #nmap [Scan type] [options] < target host >

Scan type:

-SS (TCP SYN scan half-open)

-st (TCP connection scan full open)

-SU (UDP scan)

-SP (ICMP scan)

-A//perform a full analysis of the target host

Options:

-N//Do not resolve host name

-P//Specify Port

Options

-C number//Specify the number of capture packets

-I interface name//Specify the captured NIC

-W file name//store the captured packet in a file

-A//convert to Acsii code display, slightly more readable

-r file name//read the file inside

Tcpdump-c 3-i eth0 (default)-w/a.txt-a

[Filter conditions]

Type: Host

NET Network

Port ports

Portrange Port Range

Direction

SRC: Source Address

DST: Destination Address

Protocol: TCP UDP IP WLAN ARP

Conditions can be combined: and (and) or (or) not (negate)

Example: Nmap-a-i eth0 TCP port and host 172.40.50.123 or host 172.40.50.148

The TCP protocol implemented here for detecting host 172.40.50.123 80 ports and 172.40.50.148 we can use () to raise or priority to implement 80 ports listening on two hosts () cannot be recognized by the system command, we need to use \ backslash to fetch Eliminate its definition

NMAP-A-i eth0 TCP port and \ (host 172.40.50.123 or host 172.40.50.148\)


Here is a simple script, using the location variable, where the shift to skip the previous definition, so our port port is not entered into the definition of IP address, grep-q meaning to block this output if the open field so return value echo $? =0 made a judgment, you can write a script according to your own requirements.


#!/bin/bash

Port=$1

Shift

For IP in $*

Do

Nmap-n-ss-p $port "172.40.58. $ip" | Grep-q Open

If [$?-eq 0];then

echo "172.40.58. $ip Port $port is open"

Else

echo "172.40.58. $ip Port $port is down"

Fi

Do


The shell script realizes the network scan Automatic Packet capture protocol analysis Nmap

Related Article

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.