kali渗透学习-主动信息收集(二)端口扫描

UDP端口扫描
基于端口的扫描,都是针对存活的主机而言的,使用UDP端口扫描时,如果端口开放,则目标系统不响应(可能产生误判),如果端口不开放,则目标系统会响应端口不可达,代表该端口没有开放;
scapy测试
端口关闭:ICMP port-unreachable;
端口开放:没有回包;

root@root:~# scapy
WARNING: No route found for IPv6 destination :: (no default route?)
INFO: Can't import python ecdsa lib. Disabled certificate manipulation tools
Welcome to Scapy (2.3.3)
>>> a=sr1(IP(dst="192.168.37.128")/UDP(dport=53),timeout=1,verbose=0)
>>> a.display()         #报错是因为端口开放,没有回包
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'display'
>>> a=sr1(IP(dst="192.168.37.128")/UDP(dport=90),timeout=1,verbose=0)
>>> a.display()        #目标主机的该端口没有开放
###[ IP ]### 
  version= 4L
  ihl= 5L
  tos= 0x0
  len= 56
  id= 3342
  flags= 
  frag= 0L
  ttl= 128
  proto= icmp
  chksum= 0x6163
  src= 192.168.37.128
  dst= 192.168.37.131
  \options\
###[ ICMP ]### 
     type= dest-unreach
     code= port-unreachable
     chksum= 0xc96a
     reserved= 0
     length= 0
     nexthopmtu= 0
###[ IP in ICMP ]### 
        version= 4L
        ihl= 5L
        tos= 0x0
        len= 28
        id= 1
        flags= 
        frag= 0L
        ttl= 64
        proto= udp
        chksum= 0xae7c
        src= 192.168.37.131
        dst= 192.168.37.128
        \options\
###[ UDP in ICMP ]### 
           sport= domain
           dport= 90
           len= 8
           chksum= 0x32fb

脚本实现扫描

#!/usr/bin/python 
#Author:橘子女侠
#该脚本用于实现扫描多个端口
 
from scapy.all import*
import time 
import sys 
if len( sys.argv ) !=4: 
	print "Example - ./udp_scan.py 1.1.1.1 1 100" 
	sys.exit() 
 
ip=sys.argv[1] 
start=int(sys.argv[2]) 
end=int(sys.argv[3]) 
for port in range(start,end+1): 
	a=sr1(IP(dst=ip)/UDP(dport=port),timeout=5,verbose=0) 
	time.sleep(1)   #防止因扫描过快,造成误判
	if a==None: 
		print(port)
	else: 
		pass

Nmap

nmap -sU 1.1.1.1
默认的1000个参数端口
基于ICMP host-unreachable ICMP返回值为1
namp 1.1.1.1 -sU -p 53
namp -iL iplist.txt -sU -P 1-200
-P -默认针对6W个端口扫描

TCP端口扫描
基于三次握手连接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值