1. 程式人生 > >ARP掃描滲透測試

ARP掃描滲透測試

2017 國賽 信息安全評估

2017年國賽答案
技術分享圖片

from scapy.all import
import optparse
from threading import

def sweep(packet):
try:
reply = srp1(packet,timeout=1,verbose=0,iface="eth0")
print ‘IP:‘ + reply.psrc + ‘ MAC: ‘ + reply.hwsrc
except :
pass

def main():
parser = optparse.OptionParser(‘usage%prog ‘+‘ -H < target host segment/eg :(172.168.1.)‘)

parser.add_option(‘-H‘,dest=‘tgtHost‘,type=‘string‘,help=‘speciffy target h‘)
(options,args)=parser.parse_args()
host = options.tgtHost
if host == None:
print parser.usage
exit(0)

eth =Ether()
eth.dst="ff:ff:ff:ff:ff:ff"
eth.type=0x0806
arp = ARP()

for n in  range(1,254):
    arp.pdst= host +str(n)
    packet  =  eth/arp
    t= Thread(target=sweep,args=(packet))
    t.start()       

if name ==‘main‘:
main()

ARP掃描滲透測試