Skip to content

Commit 6dd34bb

Browse files
committed
added arpspoof detector
1 parent 1c42878 commit 6dd34bb

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed
Binary file not shown.
Binary file not shown.

Diff for: machine-learning/speech-emotion-recognition/ser.py

-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@
4747
if not os.path.isdir("result"):
4848
os.mkdir("result")
4949

50-
5150
pickle.dump(model, open("result/mlp_classifier.model", "wb"))

Diff for: machine-learning/speech-emotion-recognition/utils.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,18 @@ def extract_feature(file_name, **kwargs):
6969
def load_data(test_size=0.2):
7070
X, y = [], []
7171
for file in glob.glob("data/Actor_*/*.wav"):
72+
# get the base name of the audio file
7273
basename = os.path.basename(file)
74+
# get the emotion label
7375
emotion = int2emotion[basename.split("-")[2]]
76+
# we allow only AVAILABLE_EMOTIONS we set
7477
if emotion not in AVAILABLE_EMOTIONS:
7578
continue
79+
# extract speech features
7680
features = extract_feature(file, mfcc=True, chroma=True, mel=True)
81+
# add to data
7782
X.append(features)
7883
y.append(emotion)
79-
84+
# split the data to training and testing and return it
8085
return train_test_split(np.array(X), y, test_size=test_size, random_state=7)
8186

Diff for: scapy/arp-spoof-detector/detect_arpspoof.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from scapy.all import Ether, ARP, srp, sniff, conf
2+
3+
def get_mac(ip):
4+
"""
5+
Returns the MAC address of `ip`, if it is unable to find it
6+
for some reason, throws `IndexError`
7+
"""
8+
p = Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip)
9+
result = srp(p, timeout=3, verbose=False)[0]
10+
return result[0][1].hwsrc
11+
12+
13+
def process(packet):
14+
# if the packet is an ARP packet
15+
if packet.haslayer(ARP):
16+
# if it is an ARP response (ARP reply)
17+
if packet[ARP].op == 2:
18+
try:
19+
# get the real MAC address of the sender
20+
real_mac = get_mac(packet[ARP].psrc)
21+
# get the MAC address from the packet sent to us
22+
response_mac = packet[ARP].hwsrc
23+
# if they're different, definetely there is an attack
24+
if real_mac != response_mac:
25+
print(f"[!] You are under attack, REAL-MAC: {real_mac.upper()}, FAKE-MAC: {response_mac.upper()}")
26+
except IndexError:
27+
# unable to find the real mac
28+
# may be a fake IP or firewall is blocking packets
29+
pass
30+
31+
32+
if __name__ == "__main__":
33+
import sys
34+
try:
35+
iface = sys.argv[1]
36+
except IndexError:
37+
iface = conf.iface
38+
sniff(store=False, prn=process, iface=iface)
2.37 KB
Binary file not shown.

0 commit comments

Comments
 (0)