題記
Kali的scapy模塊IP與ICMP接口有問題啊,老報錯,不過腳本編寫思路與前面類似。就是改改發包形式。能掃描外網主機了。
ICMP(scapy)
import sys
if len(sys.argv) != 2 :
print ('usage:icmpPing <ip>\n eg:icmpPing 192.168.0.1')
sys.exit(1)
from scapy.all import sr,IP,ICMP
ans,unans=sr(ip(sys.argv[1])/ICMP())
for snd,rcv in ans :
print rcv.sprintf("%IP.src% is alive")
ICMP(nmap)
import sys
if len(sys.argv) != 2:
print ('usage:icmpPing <ip>\n eg:icmpPing 192.168.0.1')
sys.exit(1)
import nmap
nm=nmap.PortScanner()
nm.scan(sys.argv[1],arguments="-sn -PE")
for host in nm.all_hosts():
print ("-----------------------------")
print ('Host:%s(%s)'%(host,nm[host].hostname()))
print ('State:%s'% nm[host].state())
TCP(scapy)
import sys
if len(sys.argv) != 3
print ('usage:tcpPing <ip>\n eg:tcpPing 192.168.0.1 80')
sys.exit(1)
from scapy.all import sr,TCP,IP
ans,unans=sr(ip(dst=sys.argv[1])/TCP(dport=int(sys.argv[2]),flags='s'))
for snd,rcv in ans :
print rcv.sprintf("%IP.src% is alive")
TCP(nmap)
import sys
if len(sys.argv) != 2:
print ('usage:tcpPing <ip>\n eg:tcpPing 192.168.0.1')
sys.exit(1)
import nmap
nm=nmap.PortScanner()
nm.scan(sys.argv[1],arguments="-sT")
for host in nm.all_hosts():
print ("-----------------------------------------")
print ('Host:%s(%s)'%(host,nm[host].hostname()))
print ('State:%s'% nm[host].state())

