#!/usr/bin/python
# Amaterasu is tool for defense and counter attack againts arp spoofing
# created by Alvin Aditya
# and TDBP group
# ver 1.0 Beta
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
# ATTENTION !
# before use this tool make sure :
# "python-scapy" "python-notify" "python-gtk2" is installed
# This tool just support GNU/Linux Distro eg: Ubuntu, Fedora(not tested)
# HOW TO RUN :
# sudo ./amaterasu.py
import sys
from scapy.all import * # use python-scapy
import pygtk #
pygtk.require('2.0') # pygtk and pynotify required
import pynotify # for send notif to Desktop
pynotify.init("Urgency")
def Get_parameter(cmd):
try:
x=os.popen(cmd,'r')
parameter=x.readline()
parameter=parameter.strip('\n')
return parameter
except :
return Get_parameter(cmd)
# get the default gateway ip address
gwip=Get_parameter('ip route list | grep "default" | cut -d" " -f3')
print "gwip = ",gwip
# get the default gateway mac address
ans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=gwip+"/30"),timeout=2)
gwmac=str(ans[0][0][1].hwsrc)
print "gwmac = ",gwmac
# monitor
def arp_monitor_callback(pkt):
if ARP in pkt and pkt[ARP].op in (1,2): # who-has or is-at
#print str(pkt[ARP].hwsrc)+" "+str(pkt[ARP].psrc)
if str(pkt[ARP].psrc) == gwip and str(pkt[ARP].hwsrc) != gwmac:
spoofed = "00:12:aa:0b:ac:00"
if str(pkt[ARP].hwsrc) != spoofed: # prevent our attack detected as attack packet from enemy
print "spoof detected from "+str(pkt[ARP].hwsrc)+" "+str(pkt[ARP].psrc)
# Critical Urgency
n = pynotify.Notification("Spoof Detected !", "from "+str(pkt[ARP].hwsrc)+" "+str(pkt[ARP].psrc))
n.set_urgency(pynotify.URGENCY_CRITICAL)
n.set_timeout(3000) # 3 seconds
if not n.show():
print "Failed to send notification"
# attack
# arp spoof the attacker
srp(Ether(dst=str(pkt[ARP].hwsrc))/ARP(op="is-at",psrc=gwip,hwsrc=spoofed),timeout=1)
# flood the attacker
# recovery
srp(Ether(dst=gwmac)/ARP(op="is-at",pdst=gwip+"/24"),timeout=1)
# main function
sniff(prn=arp_monitor_callback, filter="arp", store=0)