-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patharp.py
57 lines (48 loc) · 2.01 KB
/
arp.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
## repurpose: ac:63:be:de:a0:63 (NSS)
## multivitamins: f0:27:2d:4a:96:a9 (NSS)
## wilsonjones: 84:d6:d0:da:43:b4 (no label - NSS Guest)
## MilkBaby: 0c:47:c9:ac:35:56 (NSS Guest)
## Pets: 68:54:fd:38:e1:8c (home)
## The Laundress: 44:65:0d:10:21:a9 (home, but flakey)
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
from take_pic import pic
from rasp_camera import vid
from time import sleep
from send_text import SMStext
import datetime
timestamp = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
file = "".join(["doorbell pressed!! Time: ", timestamp])
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
#if pkt[ARP].psrc:
# Photo Trigger
if pkt[ARP].hwsrc == '0c:47:c9:ac:35:56':
print(file)
pic()
# Video Trigger
elif pkt[ARP].hwsrc == '84:d6:d0:da:43:b4':
print(file)
vid()
if __name__ == "__main__":
sniff(prn=arp_display, filter="arp", store=0, count=0)
##https://phaethon.github.io/scapy/getting-started/
##sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] +
## L2ListenSocket args) -> list of packets
##
## count: number of packets to capture. 0 means infinity
## store: wether to store sniffed packets or discard them
## prn: function to apply to each packet. If something is returned,
## it is displayed. Ex:
## ex: prn = lambda x: x.summary()
##lfilter: python function applied to each packet to determine
## if further action may be done
## ex: lfilter = lambda x: x.haslayer(Padding)
##offline: pcap file to read packets from, instead of sniffing them
##timeout: stop sniffing after a given time (default: None)
##L2socket: use the provided L2socket
##opened_socket: provide an object ready to use .recv() on
##stop_filter: python function applied to each packet to determine
## if we have to stop the capture after this packet
## ex: stop_filter = lambda x: x.haslayer(TCP)