LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > Linux教程 >

使用nmap扫描服务器端口的一次操作

时间:2012-11-03 14:09来源:V客小站 编辑:admin 点击:
nmap是Linux下常用的端口扫描工具,它可以检测主机是否在线,是否开启了某个服务端口,使用了何种操作系统等。我经常用它来检测远程的Windows服务器的ip地址,因为不是固定ip地址,该
nmap是Linux下常用的端口扫描工具,它可以检测主机是否在线,是否开启了某个服务端口,使用了何种操作系统等。我经常用它来检测远程的Windows服务器的ip地址,因为不是固定ip地址,该服务器的ip地址会经常变化,但是有个规律,只在一个网段内变化,这样就给ip地址的确定带来了方便。

1. 如果没有安装nmap,就安装

 yum install -y nmap

2. 扫描指定网段的远程桌面连接端口

nmap -sT -p3389 218.206.112.0/24

3. 如果觉得输出太多,可以用 grep 命令过滤

nmap -sT -p3389 218.206.112.0/24 | grep -B2 open


下面是操作的消息记录,备查。

[root@node18 opt]# nmap
-bash: nmap: command not found
[root@node18 opt]# yum install -y nmap
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.163.com
 * extras: ftp.iij.ad.jp
 * updates: rsync.atworks.co.jp
base                                                                                                                                             | 1.1 kB     00:00     
extras                                                                                                                                           | 1.9 kB     00:00     
extras/primary_db                                                                                                                                | 172 kB     00:00     
updates                                                                                                                                          | 1.9 kB     00:00     
updates/primary_db                                                                                                                               | 828 kB     00:03     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nmap.i386 2:4.11-2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                Arch                                   Version                                     Repository                              Size
========================================================================================================================================================================
Installing:
 nmap                                   i386                                   2:4.11-2                                    base                                   660 k

Transaction Summary
========================================================================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 660 k
Downloading Packages:
nmap-4.11-2.i386.rpm                                                                                                                             | 660 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : nmap                                                                                                                                             1/1

Installed:
  nmap.i386 2:4.11-2                                                                                                                                                    

Complete!
[root@node18 opt]# nmap
Nmap 4.11 ( http://www.insecure.org/nmap/ )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
  Can pass hostnames, IP addresses, networks, etc.
  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
  -iL <inputfilename>: Input from list of hosts/networks
  -iR <num hosts>: Choose random targets
  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
  --excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
  -sL: List Scan - simply list targets to scan
  -sP: Ping Scan - go no further than determining if host is online
  -P0: Treat all hosts as online -- skip host discovery
  -PS/PA/PU [portlist]: TCP SYN/ACK or UDP discovery to given ports
  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
  -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
  --system-dns: Use OS's DNS resolver
SCAN TECHNIQUES:
  -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
  -sN/sF/sX: TCP Null, FIN, and Xmas scans
  --scanflags <flags>: Customize TCP scan flags
  -sI <zombie host[:probeport]>: Idlescan
  -sO: IP protocol scan
  -b <ftp relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
  -p <port ranges>: Only scan specified ports
    Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080
  -F: Fast - Scan only the ports listed in the nmap-services file)
  -r: Scan ports consecutively - don't randomize
SERVICE/VERSION DETECTION:
  -sV: Probe open ports to determine service/version info
  --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
  --version-light: Limit to most likely probes (intensity 2)
  --version-all: Try every single probe (intensity 9)
  --version-trace: Show detailed version scan activity (for debugging)
OS DETECTION:
  -O: Enable OS detection
  --osscan-limit: Limit OS detection to promising targets
  --osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
  Options which take <time> are in milliseconds, unless you append 's'
  (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
  -T[0-5]: Set timing template (higher is faster)
  --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
  --min-parallelism/max-parallelism <time>: Probe parallelization
  --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
      probe round trip time.
  --max-retries <tries>: Caps number of port scan probe retransmissions.
  --host-timeout <time>: Give up on target after this long
  --scan-delay/--max-scan-delay <time>: Adjust delay between probes
FIREWALL/IDS EVASION AND SPOOFING:
  -f; --mtu <val>: fragment packets (optionally w/given MTU)
  -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
  -S <IP_Address>: Spoof source address
  -e <iface>: Use specified interface
  -g/--source-port <portnum>: Use given port number
  --data-length <num>: Append random data to sent packets
  --ttl <val>: Set IP time-to-live field
  --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
  --badsum: Send packets with a bogus TCP/UDP checksum
OUTPUT:
  -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
     and Grepable format, respectively, to the given filename.
  -oA <basename>: Output in the three major formats at once
  -v: Increase verbosity level (use twice for more effect)
  -d[level]: Set or increase debugging level (Up to 9 is meaningful)
  --packet-trace: Show all packets sent and received
  --iflist: Print host interfaces and routes (for debugging)
  --log-errors: Log errors/warnings to the normal-format output file
  --append-output: Append to rather than clobber specified output files
  --resume <filename>: Resume an aborted scan
  --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
  --webxml: Reference stylesheet from Insecure.Org for more portable XML
  --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
  -6: Enable IPv6 scanning
  -A: Enables OS detection and Version detection
  --datadir <dirname>: Specify custom Nmap data file location
  --send-eth/--send-ip: Send using raw ethernet frames or IP packets
  --privileged: Assume that the user is fully privileged
  -V: Print version number
  -h: Print this help summary page.
EXAMPLES:
  nmap -v -A scanme.nmap.org
  nmap -v -sP 192.168.0.0/16 10.0.0.0/8
  nmap -v -iR 10000 -P0 -p 80
SEE THE MAN PAGE FOR MANY MORE OPTIONS, DESCRIPTIONS, AND EXAMPLES
[root@node18 opt]#

[root@node18 opt]# nmap -sT -p3389 218.206.112.0/24

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-10-26 15:36 CST
Interesting ports on 218.206.112.1:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.11:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.16:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.39:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.40:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.41:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.49:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.51:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.56:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.59:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.65:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.68:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.69:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.71:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.72:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.74:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.77:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.78:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.80:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.81:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.82:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.83:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.87:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.88:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.94:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.95:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.96:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.100:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.102:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.103:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.105:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.107:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.108:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.109:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.110:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.111:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.116:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.117:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.119:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.121:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.123:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.129:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.131:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.132:
PORT     STATE SERVICE
3389/tcp open  ms-term-serv

Interesting ports on 218.206.112.134:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.136:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.144:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.147:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.150:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.156:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.157:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.160:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.163:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.165:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.179:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.181:
PORT     STATE  SERVICE
3389/tcp closed ms-term-serv

Interesting ports on 218.206.112.188:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Interesting ports on 218.206.112.190:
PORT     STATE    SERVICE
3389/tcp filtered ms-term-serv

Nmap finished: 256 IP addresses (58 hosts up) scanned in 22.497 seconds
[root@node18 opt]#
[root@node18 opt]#
[root@node18 opt]#
[root@node18 opt]# nmap -sT -p3389 218.206.112.0/24 | grep -B2 open
Interesting ports on 218.206.112.100:
PORT     STATE SERVICE
3389/tcp open  ms-term-serv
--
Interesting ports on 218.206.112.132:
PORT     STATE SERVICE
3389/tcp open  ms-term-serv

转载请保留固定链接: https://linuxeye.com/Linux/893.html

------分隔线----------------------------
标签:nmap
栏目列表
推荐内容