-
Notifications
You must be signed in to change notification settings - Fork 3
/
ARPSpoofDetector.py
125 lines (113 loc) · 5.33 KB
/
ARPSpoofDetector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python 3.7.2
# -*- coding: utf-8 -*-
try:
import scapy.all as scapy
except KeyboardInterrupt:
print("[-] CTRL+C basıldı.")
print("[-] Uygulamadan çıkış yapıldı.")
exit()
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import datetime
import time
class Detector():
def __init__(self, email, parola, to_email):
self.about()
self.email = email
self.parola = parola
self.to_email = to_email
self.host = "smtp.gmail.com"
self.port = 587
def mac_bul(self, ip):
arp_istek = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_istek_broadcast = broadcast / arp_istek
cevap = scapy.srp(arp_istek_broadcast, timeout=1, verbose=False)[0]
return cevap[0][1].hwsrc
def sniff(self, interface=""):
try:
if interface == "":
print("[-] Lütfen bir interface belirtiniz!")
else:
scapy.sniff(iface=interface, store=False, prn=self.sniffed_packet)
except (OSError, ValueError):
print("[-] Böyle bir interface bulunmamaktadır.")
def sniffed_packet(self, paket):
if paket.haslayer(scapy.ARP) and paket[scapy.ARP].op == 2:
try:
gercek_mac = self.mac_bul(paket[scapy.ARP].psrc)
paket_mac = paket[scapy.ARP].hwsrc
if paket_mac != gercek_mac:
print("[+] saldırı altındasınız!")
tarih = datetime.datetime.now()
if tarih.second == 00:
self.mailGonder(paket_mac, tarih)
time.sleep(1)
except IndexError:
pass
def uyari(self, mac_adresi, tarih):
mail = MIMEMultipart()
tarih = tarih.strftime("%d-%m-%Y %H:%M:%S")
mail["Subject"] = "Saldırı Altındasınız ~ " + tarih
mail["From"] = self.email
mesaj = """
<html>
<head>
<title>Bir Saldırı girişimi !!!</title>
</head>
<body>
<h1 align="center">Bir Saldırı girişimi !!!</h1>
<p style="font-size:16px;" ><b style="color:lime;background:black"> {mac} </b></h3> mac adresinden <b style="color:lime;background:black;"> {tarih} </b> tarihinde bilgisayarınıza <span style="text-decoration: underline;">ARP Spoofing Saldırısı</span> gerçekleştirildi. </p>
<br>
</body >
</html>
""".format(mac=mac_adresi, tarih=tarih)
part = MIMEText(mesaj, "html")
mail.attach(part)
return mail.as_string()
def mailGonder(self, mac,tarih):
try:
self.server = smtplib.SMTP(self.host, self.port)
self.server.ehlo()
self.server.starttls()
self.server.ehlo()
self.server.login(self.email, self.parola)
self.server.sendmail(self.email, self.to_email, self.uyari(mac,tarih))
self.server.quit()
except smtplib.SMTPException:
print("[-] Sending Mail Hatası!")
except smtplib.SMTPServerDisconnected:
print("[-] SMTP Sunucusu Bağlantısı Kesildi!")
except smtplib.SMTPConnectError:
print("[-] SMTP Bağlantı Hatası!")
def about(self):
print(" _____ _____ _____ __ _____ _ _ ")
print(" /\ | __ \| __ \ / ____| / _| | __ \ | | | | ")
print(" / \ | |__) | |__) | | (___ _ __ ___ ___ | |_ | | | | ___| |_ ___ ___| |_ ___ _ __ ")
print(" / /\ \ | _ /| ___/ \___ \| '_ \ / _ \ / _ \| _| | | | |/ _ \ __/ _ \/ __| __/ _ \| '__|")
print(" / ____ \| | \ \| | ____) | |_) | (_) | (_) | | | |__| | __/ || __/ (__| || (_) | | ")
print(" /_/ \_\_| \_\_| |_____/| .__/ \___/ \___/|_| |_____/ \___|\__\___|\___|\__\___/|_| ")
print(" | | ")
print(" |_| ")
print("# ==============================================================================")
print("# author : Mustafa Dalga")
print("# linkedin : https://www.linkedin.com/in/mustafadalga")
print("# github : https://github.com/mustafadalga")
print("# email : mustafadalgaa < at > gmail[.]com")
print("# description : Bilgisayarınıza yapılan ARP Spoofing saldırılarını tespit eden ARP Spoof Detector Scripti.")
print("# date : 01.07.2019")
print("# version : 1.0")
print("# python_version: 3.7.2")
print("# ==============================================================================")
try:
from_email=""
from_parola=""
to_email=""
interface=""
detector = Detector(from_email,from_parola,to_email)
detector.sniff(interface)
except KeyboardInterrupt:
print("[-] CTRL+C basıldı.")
print("[-] Uygulamadan çıkış yapıldı.")
exit()