目前常见的端口扫描技术一般有如下几类: TCP Connect、TCP SYN、TCP ACK、TCP FIN。
Metasploit中的端口扫描器
Metasploit的辅助模块中提供了几款实用的端口扫描器。可以输入search portscan命令找到相关的端口扫描器。如下
root@kali:~# msfconsole
...... msf > search portscan Matching Modules
================ Name Disclosure Date Rank Description
---- --------------- ---- -----------
auxiliary/scanner/http/wordpress_pingback_access normal Wordpress Pingback Locator
auxiliary/scanner/natpmp/natpmp_portscan normal NAT-PMP External Port Scanner
auxiliary/scanner/portscan/ack normal TCP ACK Firewall Scanner
auxiliary/scanner/portscan/ftpbounce normal FTP Bounce Port Scanner
auxiliary/scanner/portscan/syn normal TCP SYN Port Scanner
auxiliary/scanner/portscan/tcp normal TCP Port Scanner
auxiliary/scanner/portscan/xmas normal TCP "XMas" Port Scanner
auxiliary/scanner/sap/sap_router_portscanner normal SAPRouter Port Scanner msf >
Metasploit中ack扫描模块的使用过程
msf > use auxiliary/scanner/portscan/ack
msf auxiliary(ack) > set RHOSTS 202.193.58.13
RHOSTS => 202.193.58.13
msf auxiliary(ack) > set THREADS
THREADS =>
msf auxiliary(ack) > run
Metasploit中ftpbounce扫描模块的使用过程
msf > use auxiliary/scanner/portscan/ftpbounce
msf auxiliary(ftpbounce) > set RHOSTS 202.193.58.13
RHOSTS => 202.193.58.13
msf auxiliary(ftpbounce) > set THREADS
THREADS =>
msf auxiliary(ftpbounce) > run
[-] Auxiliary failed: Msf::OptionValidateError The following options failed to validate: BOUNCEHOST.
msf auxiliary(ftpbounce) >
Metasploit中tcp扫描模块的使用过程
msf > use auxiliary/scanner/portscan/tcp
msf auxiliary(tcp) > set RHOSTS 202.193.58.13
RHOSTS => 202.193.58.13
msf auxiliary(tcp) > set THREADS
THREADS =>
msf auxiliary(tcp) > run [*] 202.193.58.13: - 202.193.58.13: - TCP OPEN
[*] 202.193.58.13: - 202.193.58.13: - TCP OPEN
[*] 202.193.58.13: - 202.193.58.13: - TCP OPEN
[*] 202.193.58.13: - 202.193.58.13: - TCP OPEN
Metasploit中xmas扫描模块的使用过程
msf > use auxiliary/scanner/portscan/xmas
msf auxiliary(xmas) > set RHOSTS 202.193.58.13
RHOSTS => 202.193.58.13
msf auxiliary(xmas) > set THREADS
THREADS =>
msf auxiliary(xmas) > run [*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
[*] TCP OPEN|FILTERED 202.193.58.13:
Metasploit中syn扫描模块的使用过程
在一般的情况下,推荐使用syn端口扫描器,因为它的扫描速度较快、结果准确切不容易被对方察觉。下面是针对网关服务器(Ubuntu Metasploitable)主机的扫描结果,可以看出与Nmap的扫描结果基本一致。如下。
msf > use auxiliary/scanner/portscan/syn
msf auxiliary(syn) > set RHOSTS 202.193.58.13
RHOSTS => 202.193.58.13
msf auxiliary(syn) > set THREADS 20
THREADS => 20
msf auxiliary(syn) > run [*] TCP OPEN 202.193.58.13:21
[*] TCP OPEN 202.193.58.13:22
[*] TCP OPEN 202.193.58.13:23
[*] TCP OPEN 202.193.58.13:25
[*] TCP OPEN 202.193.58.13:53
[*] TCP OPEN 202.193.58.13:80
[*] TCP OPEN 202.193.58.13:111
[*] TCP OPEN 202.193.58.13:139
[*] TCP OPEN 202.193.58.13:445
[*] TCP OPEN 202.193.58.13:512
[*] TCP OPEN 202.193.58.13:513
当然,大家也可以拿下面的主机来扫描
Metasploit中sap_router_portscanner扫描模块的使用过程
msf > use auxiliary/scanner/sap/sap_router_portscanner
msf auxiliary(sap_router_portscanner) > set RHOSTS 202.193.58.13
RHOSTS => 202.193.58.13
msf auxiliary(sap_router_portscanner) > set THREADS
THREADS =>
msf auxiliary(sap_router_portscanner) > run
[-] Auxiliary failed: Msf::OptionValidateError The following options failed to validate: RHOST, TARGETS.
msf auxiliary(sap_router_portscanner) >
Metasploit中也可以使用namp
常用nmap扫描类型参数:
-sT:TCP connect扫描
-sS:TCP syn扫描
-sF/-sX/-sN:通过发送一些标志位以避开设备或软件的检测
-sP:ICMP扫描
-sU:探测目标主机开放了哪些UDP端口
-sA:TCP ACk扫描
扫描选项:
-Pn:在扫描之前,不发送ICMP echo请求测试目标是否活跃
-O:辨识操作系统等信息
-F:快速扫描模式
-p<端口范围>:指定端口扫描范围
msf auxiliary(syn) > nmap -sS -Pn 202.193.58.13
[*] exec: nmap -sS -Pn 202.193.58.13 Starting Nmap 7.31 ( https://nmap.org ) at 2017-05-17 22:17 CST
Nmap scan report for 13.58.193.202.in-addr.arpa (202.193.58.13)
Host is up (.0014s latency).
Not shown: closed ports
PORT STATE SERVICE
/tcp open ftp
/tcp open ssh
/tcp open telnet
/tcp open smtp
/tcp open domain
/tcp open http
/tcp open rpcbind
/tcp open netbios-ssn
/tcp open microsoft-ds
/tcp open exec
/tcp open login
/tcp open shell
/tcp open rmiregistry
/tcp open ingreslock
/tcp open nfs
/tcp open ccproxy-ftp
/tcp open mysql
/tcp open postgresql
/tcp open vnc
/tcp open X11
/tcp open irc
/tcp open ajp13
/tcp open unknown
MAC Address: :AD::::5C (Unknown) Nmap done: IP address ( host up) scanned in 1.49 seconds
msf auxiliary(syn) >
msf auxiliary(syn) > nmap -sV -Pn 202.193.58.13
[*] exec: nmap -sV -Pn 202.193.58.13 Starting Nmap 7.31 ( https://nmap.org ) at 2017-05-17 22:18 CST
Nmap scan report for 13.58.193.202.in-addr.arpa (202.193.58.13)
Host is up (.0016s latency).
Not shown: closed ports
PORT STATE SERVICE VERSION
/tcp open ftp vsftpd 2.3.
/tcp open ssh OpenSSH .7p1 Debian 8ubuntu1 (protocol 2.0)
/tcp open telnet Linux telnetd
/tcp open smtp Postfix smtpd
/tcp open domain?
/tcp open http?
/tcp open rpcbind?
/tcp open netbios-ssn?
/tcp open microsoft-ds?
/tcp open exec netkit-rsh rexecd
/tcp open login?
/tcp open shell Netkit rshd
/tcp open rmiregistry?
/tcp open shell Metasploitable root shell
/tcp open nfs?
/tcp open ccproxy-ftp?
/tcp open mysql MySQL 5.0.51a-3ubuntu5
/tcp open postgresql?
/tcp open vnc VNC (protocol 3.3)
/tcp open X11?
/tcp open irc Unreal ircd
/tcp open ajp13?
/tcp open unknown
MAC Address: :AD::::5C (Unknown)
Service Info: Hosts: metasploitable.localdomain, irc.Metasploitable.LAN; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: IP address ( host up) scanned in 22.50 seconds
msf auxiliary(syn) >
可以,与下面进行对比。
kali 2.0 linux中的Nmap的端口扫描功能
当然,大家也可以拿下面的主机来扫描