ICMP port-unreachable
python脚本:
#! /usr/bin/python
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
import time
import sys
if len(sys.argv) != 4:
print "Usage ./udp_scan.py [Target-IP] [First Port] [End Port]"
sys.exit()
ip = sys.argv[1]
start = int(sys.argv[2])
end = int(sys.argv[3])
for port in range(start, end):
a = sr1(IP(dst = ip)/UDP(dport = port), timeout = 5, verbose = 0)
time.sleep(1)
if a == None:
print port
else:
pass
nmap -sU 1.1.1.1 默认1000个端口,udp扫描
nmap 1.1.1.1 -sU -p 53 53端口
nmap -iL iplist.txt -sU -p 1-200
隐蔽扫描:只发送SYS包,返回ACK,SYS包则开放,应用层日志不会记录,网络层日志可能记录
僵尸扫描:极其隐蔽,条件苛刻,扫描发起方可以地址伪造,必须要有僵尸机(机器闲置,但不被控制,操作系统IPID递增,在IP包头里的ID字段,linux与windows系统的ID随机产生,早期的wndows系统是顺序产生的),有扫描发起者向僵尸机发送SYN,ACK包,TCP协议会返回RST,包的IPID等于x时,扫描者向目标服务器发送SYN包,发送时IP伪造为僵尸机,端口开放的话会向僵尸机发送SYN,ACK,僵尸机返回RST包,IPID为x+1,扫描者再向僵尸机发送SYN,ACK包,僵尸机返回RST包,IPID为x+2。如果端口未开放,返回RST包给僵尸机,扫描者再次向僵尸机发送SYN,ACK包返回RST,IPID为x+1.
SYN,ACK,flag值为18
Windows,445端口开放,防火墙会组织端口探测
隐蔽端口扫描:
nmap -sS 1.1.1.1 -p 80,21,25,110,443
nmap -sS 1.1.1.1 -p 1-65535 --open
nmap -sS 1.1.1.1 -p - --open 全端口
nmap -sS -iL iplist.txt -p 80,21,22,23
hping3 1.1.1.1 --scan 80 -S
hping3 1.1.1.1 --scan 80,21,25,443 -S
hping3 1.1.1.1 --scan 0-65535 -S
hping3 -c 10 -S --spoof 1.1.1.2 -p ++1 1.1.1.3 伪造ip为1.1.1.2,从1号端口开始每次加一,目标为1.1.1.3
全连接端口扫描:
脚本:
#! /usr/bin/python
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
response = sr1(IP(dst = "192.168.1.2")/TCP(dport = 80, flags = "S"))
reply = sr1(IP(dst = "192.168.1.2")/TCP(dport = 80, flags = "A", ack = (response[TCP].seq+1)))
由于操作系统自动返回的RST包,建立三次握手失败
iptables -A OUTPUT -p tcp --tcp-flags RST RST -d 192.168.20.2 -j DROP 禁用向192.168.20.2发送的RST包
iptables -L iptables的规则
nmap全连接扫描
nmap -sT 1.1.1.1 -p 80
nmap -sT 1.1.1.1 -p 80,21,25
nmap -sT 1.1.1.1 -p 80-2000
nmap -sT -iL iplist.txt -p 80
dmitry工具
dmitry -p 172.16.36.135
dmitry -p 172.16.36.135 -o output
nc工具
nc -nv -w 1 -z 192.168.60.4 1-100 -w超时,-z扫描模式
for x in $(seq 20 30); do nc -nv -w 1 -z 1.1.1.1 $x; done | grep open
for x in $(seq 1 254); do nc -nv -w 1 -z 1.1.1.$x 80; done
僵尸扫描:
send()命令发包不接收,sr1()发包接收
脚本:
#! /usr/bin/python
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
import time
import sys
def ipid(zombie):
reply1=sr1(IP(dst=zombie)/TCP(flags="SA"),timeout=2,verbose=0)
send(IP(dst=zombie)/TCP(flags="SA"))
reply2=sr1(IP(dst=zombie)/TCP(flags="SA"),timeout=2,verbose=0)
if reply2[IP].id==(reply1[IP].id+2):
print"IPID sequence is incremental and target seems to be idel, ZOMBIE LOCATED"
response=raw_input("Do you want to use this zombie to perform a scan?(Y/N): ")
if(response=='Y'):
target=raw_input("Enter the IP address of the target: ")
zombiescan(target, zombie)
else:
print"IPID sequence is not incremental and target is not idel, ZOMBIE NOT FOUND"
def zombiescan(target, zombie):
print"\nScanning target "+target+" with the zombie "+zombie
print"\n------Open Ports On Target------\n"
for port in range(1,1000):
try:
start_val=sr1(IP(dst=zombie)/TCP(flags="SA"),timeout=2,verbose=0)
send(IP(src=zombie,dst=target)/TCP(flags="S",dport=port),verbose=0)
end_val=sr1(IP(dst=zombie)/TCP(flags="SA"),timeout=2,verbose=0)
if end_val[IP].id==(start_val[IP].id+2):
print port
except:
pass
print"------Zombie Scan Suite------\n"
print"1.Identify Zombie Host\n"
print"2.Perform Zombie Scan\n"
ans=raw_input("Select One Option: ")
if ans=="1":
zombie=raw_input("Enter the IP address the test IPID: ")
ipid(zombie)
else:
if ans=="2":
zombie=raw_input("Enter the IP address of zombie host: ")
target=raw_input("Enter the IP address of target host: ")
zombiescan(target,zombie)
smb文件共享139,445端口,windows开放
nmap僵尸扫描
发现僵尸机:nmap -p445 192.168.1.105 --script=ipidseq.nse
僵尸扫描:nmap 192.168.1.107 -sI 192.168.1.105 -Pn -p 0-100-sI指定僵尸机
ftp21端口