Giter Site home page Giter Site logo

futuresharks / rpi-security Goto Github PK

View Code? Open in Web Editor NEW
214.0 214.0 71.0 3.87 MB

A security system written in python to run on a Raspberry Pi with motion detection and mobile notifications

License: GNU General Public License v2.0

Python 99.29% Shell 0.71%
mobile-notifications mobile-phones raspberry-pi security telegram-bot wifi

rpi-security's People

Contributors

futuresharks avatar jnaulty avatar max-rocket-internet avatar qlerebours avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi-security's Issues

Sometimes notifications of motion detection are sent immediately

This creates false positives. In this example log output, monitor_alarm_state doesn't change the state when new packets are detected:

Mar 12 19:56:45 raspberrypi rpis_camera.py:monitor_alarm_state Motion detected!
Mar 12 19:56:45 raspberrypi process_photos.py:process_photos Running arp_ping_macs before sending photos...
Mar 12 19:56:47 raspberrypi rpis_security.py:process_photos MAC 64:a2:f9:a9:2e:a9 did not respond to ARP ping
Mar 12 19:56:48 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195645-0.jpeg
Mar 12 19:56:48 raspberrypi rpis_security.py:process_photos MAC 08:c5:e1:c5:28:1d did not respond to ARP ping
Mar 12 19:56:51 raspberrypi rpis_security.py:process_photos MAC 64:a2:f9:a9:2e:a9 did not respond to ARP ping
Mar 12 19:56:51 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195648-1.jpeg
Mar 12 19:56:52 raspberrypi rpis_security.py:process_photos MAC 08:c5:e1:c5:28:1d did not respond to ARP ping
Mar 12 19:56:53 raspberrypi rpis_camera.py:monitor_alarm_state Motion detected!
Mar 12 19:56:54 raspberrypi capture_packets.py:capture_packets Packet detected from 64:a2:f9:a9:2e:a9
Mar 12 19:56:55 raspberrypi rpis_security.py:process_photos MAC 64:a2:f9:a9:2e:a9 responded to ARP ping with address 192.168.178.71
Mar 12 19:56:56 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195653-0.jpeg
Mar 12 19:56:57 raspberrypi process_photos.py:process_photos Processing the photo: /var/tmp/rpi-security-2019-03-12-195645-box.jpeg
Mar 12 19:56:57 raspberrypi rpis_security.py:process_photos Telegram message Sent: "Motioned detected"
Mar 12 19:56:57 raspberrypi rpis_security.py:process_photos Telegram file sent: /var/tmp/rpi-security-2019-03-12-195645-box.jpeg
Mar 12 19:56:57 raspberrypi process_photos.py:process_photos Processing the photo: /var/tmp/rpi-security-2019-03-12-195645-0.jpeg
Mar 12 19:56:57 raspberrypi rpis_security.py:process_photos Telegram message Sent: "Motioned detected"
Mar 12 19:56:59 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195656-1.jpeg
Mar 12 19:56:59 raspberrypi rpis_camera.py:monitor_alarm_state Motion detected!
Mar 12 19:57:01 raspberrypi rpis_security.py:process_photos Telegram file sent: /var/tmp/rpi-security-2019-03-12-195645-0.jpeg
Mar 12 19:57:01 raspberrypi process_photos.py:process_photos Processing the photo: /var/tmp/rpi-security-2019-03-12-195648-1.jpeg
Mar 12 19:57:01 raspberrypi rpis_security.py:process_photos Telegram message Sent: "Motioned detected"
Mar 12 19:57:02 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195659-0.jpeg
Mar 12 19:57:05 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195702-1.jpeg
Mar 12 19:57:05 raspberrypi rpis_camera.py:monitor_alarm_state Motion detected!
Mar 12 19:57:07 raspberrypi capture_packets.py:capture_packets Packet detected from 64:a2:f9:a9:2e:a9
Mar 12 19:57:08 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195705-0.jpeg
Mar 12 19:57:08 raspberrypi rpis_security.py:process_photos Telegram file sent: /var/tmp/rpi-security-2019-03-12-195648-1.jpeg
Mar 12 19:57:08 raspberrypi process_photos.py:process_photos Processing the photo: /var/tmp/rpi-security-2019-03-12-195653-box.jpeg
Mar 12 19:57:08 raspberrypi rpis_security.py:process_photos Telegram message Sent: "Motioned detected"
Mar 12 19:57:09 raspberrypi rpis_security.py:process_photos Telegram file sent: /var/tmp/rpi-security-2019-03-12-195653-box.jpeg
Mar 12 19:57:09 raspberrypi process_photos.py:process_photos Processing the photo: /var/tmp/rpi-security-2019-03-12-195653-0.jpeg
Mar 12 19:57:09 raspberrypi rpis_security.py:process_photos Telegram message Sent: "Motioned detected"
Mar 12 19:57:14 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195708-1.jpeg
Mar 12 19:57:14 raspberrypi rpis_camera.py:monitor_alarm_state Motion detected!
Mar 12 19:57:15 raspberrypi rpis_security.py:process_photos Telegram file sent: /var/tmp/rpi-security-2019-03-12-195653-0.jpeg
Mar 12 19:57:15 raspberrypi process_photos.py:process_photos Processing the photo: /var/tmp/rpi-security-2019-03-12-195656-1.jpeg
Mar 12 19:57:16 raspberrypi rpis_security.py:process_photos Telegram message Sent: "Motioned detected"
Mar 12 19:57:17 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195714-0.jpeg
Mar 12 19:57:20 raspberrypi rpis_camera.py:monitor_alarm_state Captured image: /var/tmp/rpi-security-2019-03-12-195717-1.jpeg
Mar 12 19:57:20 raspberrypi rpis_security.py:monitor_alarm_state Telegram message Sent: "rpi-security is now disarmed"
Mar 12 19:57:20 raspberrypi rpis_state.py:monitor_alarm_state rpi-security is now disarmed
Mar 12 19:57:22 raspberrypi rpis_security.py:process_photos Telegram file sent: /var/tmp/rpi-security-2019-03-12-195656-1.jpeg
Mar 12 19:58:06 raspberrypi capture_packets.py:capture_packets Packet detected from 64:a2:f9:a9:2e:a9

Can't start service (Control process exited, code=exited status=161)

Hello,
first, thanks for the good work, everything is well explained and the project is nice.

I bought what was necessary (Raspberry PI Zero W, Camera module, Wifi adapter = https://www.amazon.fr/gp/product/B015TCA2EM/ref=oh_aui_detailpage_o04_s01?ie=UTF8&psc=1, etc)

I followed the Readme until i face this error while running sudo systemctl start rpi-security.service:

Jun 17 05:21:44 raspberrypi systemd[1]: rpi-security.service: Control process exited, code=exited status=161
Jun 17 05:21:44 raspberrypi systemd[1]: rpi-security.service: Unit entered failed state.
Jun 17 05:21:44 raspberrypi systemd[1]: rpi-security.service: Failed with result 'exit-code'.

Here is the status:

● rpi-security.service - rpi-security service
   Loaded: loaded (/lib/systemd/system/rpi-security.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-06-17 05:21:44 UTC; 9min ago
  Process: 1006 ExecStartPre=/sbin/iw phy phy0 interface add mon0 type monitor (code=exited, status=161)

The wifi adapter is plugged. Here is the result of ifconfig:

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.27  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::24d1:be4:ce6b:4534  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:36:2a:65  txqueuelen 1000  (Ethernet)
        RX packets 881  bytes 67876 (66.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 599  bytes 108312 (105.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.28  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::3f25:88ee:88cf:e6c9  prefixlen 64  scopeid 0x20<link>
        ether 00:0f:00:58:88:03  txqueuelen 1000  (Ethernet)
        RX packets 736  bytes 169249 (165.2 KiB)
        RX errors 0  dropped 3  overruns 0  frame 0
        TX packets 46  bytes 6157 (6.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I tried the debug option with iw phy phy0 interface add mon0 type monitor
Without sudo it returns Operation not permitted (-1) and with sudo and --debug it returns Operation not supported (-95):

-- Debug: Sent Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 48
    .type = 23 <0x17>
    .flags = 5 <REQUEST,ACK>
    .seq = 1529212815
    .port = -2042625054
  [GENERIC NETLINK HEADER] 4 octets
    .cmd = 7
    .version = 0
    .unused = 0
  [PAYLOAD] 28 octets
    08 00 01 00 00 00 00 00 09 00 04 00 6d 6f 6e 30 ............mon0
    00 00 00 00 08 00 05 00 06 00 00 00             ............
---------------------------  END NETLINK MESSAGE   ---------------------------
-- Debug: Received Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 68
    .type = 2 <ERROR>
    .flags = 0 <>
    .seq = 1529212815
    .port = -2042625054
  [ERRORMSG] 20 octets
    .error = -95 "Operation not supported"
  [ORIGINAL MESSAGE] 16 octets
    .nlmsg_len = 16
    .type = 23 <0x17>
    .flags = 5 <REQUEST,ACK>
    .seq = 1529212815
    .port = -2042625054
---------------------------  END NETLINK MESSAGE   ---------------------------
command failed: Operation not supported (-95)

I don't know why this operation is not supported, i don't know how to be sure that WIFI is working thanks to the USB and not the chipset

Failed to take photo: PiCameraMMALError

Ran into an issue with the /photo command.

Running on a raspberry pi 3+

Not sure if this is related to rpi-security or something in picamera, but posting here first for when I find a proper solution.

pi@raspi-3:~/workspace/rpi-security $ systemctl status rpi-security
● rpi-security.service - rpi-security service
   Loaded: loaded (/lib/systemd/system/rpi-security.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-03-22 21:12:25 GMT; 1min 25s ago
  Process: 6029 ExecStopPost=/sbin/iw dev ${RPI_SEC_MON} del (code=exited, status=0/SUCCESS)
  Process: 5996 ExecStop=/usr/bin/pkill rpi-security.py (code=exited, status=0/SUCCESS)
  Process: 6869 ExecStartPre=/sbin/ip link set ${RPI_SEC_MON} up (code=exited, status=0/SUCCESS)
  Process: 6864 ExecStartPre=/sbin/iw dev ${RPI_SEC_WLAN_ITFC} interface add ${RPI_SEC_MON} type monitor (code=exited, status=0/SUCCESS)
 Main PID: 6877 (rpi-security.py)
   CGroup: /system.slice/rpi-security.service
           └─6877 /usr/bin/python3 /usr/local/bin/rpi-security.py

Mar 22 21:12:30 raspi-3 rpi-security.py[6877]: process_photos.py:process_photos thread running
Mar 22 21:12:30 raspi-3 rpi-security.py[6877]: rpi-security.py:MainThread rpi-security running
Mar 22 21:12:30 raspi-3 rpi-security.py[6877]: telegram_bot.py:telegram_bot thread running
Mar 22 21:12:31 raspi-3 rpi-security.py[6877]: rpis_security.py:MainThread Telegram message Sent: "rpi-security running"
Mar 22 21:13:12 raspi-3 rpi-security.py[6877]: rpis_camera.py:dispatcher Failed to take photo: PiCameraMMALError('Failed to enable component: Out of resources',)
Mar 22 21:13:12 raspi-3 rpi-security.py[6877]: dispatcher.py:dispatcher An uncaught error was raised while processing the update
                                               Traceback (most recent call last):
                                                 File "/usr/local/lib/python3.5/dist-packages/python_telegram_bot-12.0.0b1-py3.5.egg/telegram/ext/dispatcher.py", line 333, in process_update
                                                   handler.handle_update(update, self, check, context)
                                                 File "/usr/local/lib/python3.5/dist-packages/python_telegram_bot-12.0.0b1-py3.5.egg/telegram/ext/handler.py", line 120, in handle_update
                                                   return self.callback(dispatcher.bot, update, **optional_args)
                                                 File "/usr/local/lib/python3.5/dist-packages/rpi_security-1.0-py3.5.egg/rpisec/threads/telegram_bot.py", line 57, in photo
                                                   rpis.telegram_send_file(photo)
                                                 File "/usr/local/lib/python3.5/dist-packages/rpi_security-1.0-py3.5.egg/rpisec/rpis_security.py", line 221, in telegram_send_file
                                                   filename, file_extension = os.path.splitext(file_path)
                                                 File "/usr/lib/python3.5/posixpath.py", line 122, in splitext
                                                   return genericpath._splitext(p, sep, None, extsep)
                                                 File "/usr/lib/python3.5/genericpath.py", line 118, in _splitext
                                                   sepIndex = p.rfind(sep)
                                               AttributeError: 'NoneType' object has no attribute 'rfind'
Mar 22 21:13:27 raspi-3 rpi-security.py[6877]: rpis_security.py:monitor_alarm_state Telegram message Sent: "rpi-security is now armed"
Mar 22 21:13:27 raspi-3 rpi-security.py[6877]: rpis_state.py:monitor_alarm_state rpi-security is now armed
Mar 22 21:13:37 raspi-3 rpi-security.py[6877]: rpis_camera.py:dispatcher Failed to take photo: PiCameraMMALError('Failed to enable component: Out of resources',)
Mar 22 21:13:37 raspi-3 rpi-security.py[6877]: dispatcher.py:dispatcher An uncaught error was raised while processing the update
                                               Traceback (most recent call last):
                                                 File "/usr/local/lib/python3.5/dist-packages/python_telegram_bot-12.0.0b1-py3.5.egg/telegram/ext/dispatcher.py", line 333, in process_update
                                                   handler.handle_update(update, self, check, context)
                                                 File "/usr/local/lib/python3.5/dist-packages/python_telegram_bot-12.0.0b1-py3.5.egg/telegram/ext/handler.py", line 120, in handle_update
                                                   return self.callback(dispatcher.bot, update, **optional_args)
                                                 File "/usr/local/lib/python3.5/dist-packages/rpi_security-1.0-py3.5.egg/rpisec/threads/telegram_bot.py", line 57, in photo
                                                   rpis.telegram_send_file(photo)
                                                 File "/usr/local/lib/python3.5/dist-packages/rpi_security-1.0-py3.5.egg/rpisec/rpis_security.py", line 221, in telegram_send_file
                                                   filename, file_extension = os.path.splitext(file_path)
                                                 File "/usr/lib/python3.5/posixpath.py", line 122, in splitext
                                                   return genericpath._splitext(p, sep, None, extsep)
                                                 File "/usr/lib/python3.5/genericpath.py", line 118, in _splitext
                                                   sepIndex = p.rfind(sep)
                                               AttributeError: 'NoneType' object has no attribute 'rfind'

Rewrite the whole thing

It's quite messy as it was written before I really learned Python. I think the whole project needs a rewrite.

Raspberry PI 4 - Pillow error

Hello,

First of all : Thanks it's a fantastic project you have and I would be so happy to implement it at home.

I have a fresh Buster install and when I try to follow your tuto I face an error message about pillow.
Please find the error below :

Could you tell me what I do wrong ?
Thanks in advance

`pi@raspberrypi:~ $ sudo pip3 install --no-binary :all: https://github.com/FutureSharks/rpi-security/archive/1.4.zip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting https://github.com/FutureSharks/rpi-security/archive/1.4.zip
Downloading https://github.com/FutureSharks/rpi-security/archive/1.4.zip
\ 4.0MB 64.8MB/s
Collecting Pillow==6.2.1 (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/5b/bb/cdc8086db1f15d0664dd22a62c69613cdc00f1dd430b5b19df1bea83f2a3/Pillow-6.2.1.tar.gz (37.7MB)
100% |████████████████████████████████| 37.7MB 11kB/s
Collecting configparser (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/16/4f/48975536bd488d3a272549eb795ac4a13a5f7fcdc8995def77fbef3532ee/configparser-4.0.2.tar.gz (72kB)
100% |████████████████████████████████| 81kB 427kB/s
Installing build dependencies ... done
Collecting imutils==0.5.2 (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/5e/0c/659c2bdae8e8ca5ef810b9da02db28feaa29ea448ff36b65a1664ff28142/imutils-0.5.2.tar.gz
Collecting netaddr (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/0c/13/7cbb180b52201c07c796243eeff4c256b053656da5cfe3916c3f5b57b3a0/netaddr-0.7.19.tar.gz (1.6MB)
100% |████████████████████████████████| 1.6MB 251kB/s
Collecting netifaces (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from rpi-security==1.4) (1.16.2)
Requirement already satisfied: opencv-contrib-python in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.4) (4.1.1.26)
Requirement already satisfied: opencv-contrib-python-headless in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.4) (4.1.1.26)
Requirement already satisfied: picamera==1.13 in /usr/lib/python3/dist-packages (from rpi-security==1.4) (1.13)
Collecting python-telegram-bot==12.2.0 (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/70/ce/da26173402f5714e29958dcf24202b24ad22fe5f4cb3427072a163072f56/python-telegram-bot-12.2.0.tar.gz (234kB)
100% |████████████████████████████████| 235kB 1.5MB/s
Collecting pyyaml (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849582fe/PyYAML-5.1.2.tar.gz (265kB)
100% |████████████████████████████████| 266kB 1.3MB/s
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from rpi-security==1.4) (2.21.0)
Collecting scapy==2.4.3 (from rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/52/e7/464079606a9cf97ad04936c52a5324d14dae36215f9319bf3faa46a7907d/scapy-2.4.3.tar.gz (905kB)
100% |████████████████████████████████| 911kB 437kB/s
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.4) (2018.8.24)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.4) (2.6.1)
Collecting future>=0.16.0 (from python-telegram-bot==12.2.0->rpi-security==1.4)
Downloading https://files.pythonhosted.org/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829kB)
100% |████████████████████████████████| 829kB 499kB/s
Requirement already satisfied: tornado>=5.1 in /usr/lib/python3/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.4) (5.1.1)
Skipping bdist_wheel for rpi-security, due to binaries being disabled for it.
Skipping bdist_wheel for Pillow, due to binaries being disabled for it.
Skipping bdist_wheel for configparser, due to binaries being disabled for it.
Skipping bdist_wheel for imutils, due to binaries being disabled for it.
Skipping bdist_wheel for netaddr, due to binaries being disabled for it.
Skipping bdist_wheel for netifaces, due to binaries being disabled for it.
Skipping bdist_wheel for python-telegram-bot, due to binaries being disabled for it.
Skipping bdist_wheel for pyyaml, due to binaries being disabled for it.
Skipping bdist_wheel for scapy, due to binaries being disabled for it.
Skipping bdist_wheel for future, due to binaries being disabled for it.
Installing collected packages: Pillow, configparser, imutils, netaddr, netifaces, future, python-telegram-bot, pyyaml, scapy, rpi-security
Found existing installation: Pillow 5.4.1
Not uninstalling pillow at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'Pillow'. No files were found to uninstall.
Running setup.py install for Pillow ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-djbvaq6m/Pillow/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-3io734hb/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.7
creating build/lib.linux-armv7l-3.7/PIL
copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/EpsImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageCms.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PdfParser.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/MpegImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageEnhance.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/GimpPaletteFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageGrab.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageWin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PaletteFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/MpoImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageStat.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/CurImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/features.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageChops.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/JpegPresets.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/DdsImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageColor.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/GbrImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/WmfImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/SunImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageMorph.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageMode.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/FpxImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PcdImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImagePath.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageTk.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/IcoImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/TiffImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageFont.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/IptcImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/_version.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/SgiImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageShow.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageFilter.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/GimpGradientFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/BdfFontFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/MspImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PcfFontFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PdfImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImtImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PixarImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/BmpImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PpmImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/_util.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/FontFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PyAccess.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageMath.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/JpegImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImagePalette.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/GifImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/_tkinter_finder.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/MicImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/XpmImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/TiffTags.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageTransform.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageOps.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/main.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageDraw.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PalmImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ContainerIO.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/GdImageFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/XbmImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/WalImageFile.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PcxImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/WebPImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageQt.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/FliImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PsdImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ExifTags.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/BlpImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageSequence.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/_binary.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PSDraw.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/DcxImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/ImageDraw2.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/TarIO.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/init.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/FtexImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/Image.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/PngImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
copying src/PIL/TgaImagePlugin.py -> build/lib.linux-armv7l-3.7/PIL
running egg_info
writing src/Pillow.egg-info/PKG-INFO
writing dependency_links to src/Pillow.egg-info/dependency_links.txt
writing top-level names to src/Pillow.egg-info/top_level.txt
reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '.c'
warning: no files found matching '
.h'
warning: no files found matching '.sh'
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.codecov.yml'
warning: no previously-included files found matching '.editorconfig'
warning: no previously-included files found matching '.readthedocs.yml'
warning: no previously-included files found matching 'azure-pipelines.yml'
warning: no previously-included files matching '.git
' found anywhere in distribution
warning: no previously-included files matching '.pyc' found anywhere in distribution
warning: no previously-included files matching '
.so' found anywhere in distribution
no previously-included directories found matching '.azure-pipelines'
no previously-included directories found matching '.travis'
writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
running build_ext

The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html

Traceback (most recent call last):
  File "/tmp/pip-install-djbvaq6m/Pillow/setup.py", line 888, in <module>
    zip_safe=not (debug_build() or PLATFORM_MINGW),
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/usr/lib/python3.7/distutils/command/install.py", line 589, in run
    self.run_command('build')
  File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.7/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.7/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/tmp/pip-install-djbvaq6m/Pillow/setup.py", line 687, in build_extensions
    raise RequiredDependencyException(f)
__main__.RequiredDependencyException: jpeg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-djbvaq6m/Pillow/setup.py", line 903, in <module>
    raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:

The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html



----------------------------------------

Can't roll back Pillow; was not uninstalled
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-djbvaq6m/Pillow/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-3io734hb/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-djbvaq6m/Pillow/`

rpi-security.service: control process exited, code=exited status=161

Hello FutureSharks, I'm trying to install this software and I keep seeing this output when I enter the sudo systemctl start rpi-security.service command:

rpi-security.service: control process exited, code=exited status=161
Unit rpi-security.service entered failed state.

Do you know how I might be able to troubleshoot this issue?

Thanks for your help!

Configuration error

After running the debug program, I get

Configuration error: Exception('Monitor mode is not enabled for interface mon0 or interface does not exist',)

To setup the wifi adapter, I referred to this link after which I ran the following command:
iw phy phy0 interface add mon0 type monitor

My current network arrangement is

iw dev

phy#0
Interface mon0
ifindex 6
wdev 0x3
addr 20:e8:16:00:e2:d5
type monitor
txpower 20.00 dBm
Interface wlan1
ifindex 4
wdev 0x1
addr 20:e8:16:00:e2:d5
type managed
txpower 20.00 dBm

phy#1
Unnamed/non-netdev interface
wdev 0x100000002
addr ba:27:eb:3f:78:b9
type P2P-device
txpower 31.00 dBm
Interface wlan0
ifindex 3
wdev 0x100000001
addr b8:27:eb:3f:78:b9
ssid Wifi
type managed
channel 6 (2437 MHz), width: 20 MHz, center1: 2437 MHz
txpower 31.00 dBm

The wifi adapter I'm using is mt7601u which has monitor mode according to this.

PIR PIN number issue

Hi,
according to this article,
GPIO.setmode(GPIO.BCM) and GPIO.setmode(GPIO.BOARD) are different in PIN number meaning...
so if user set the PIN number by simply counting, he/she will not get PIR pin to work correctly XD

Does picamera library really need GPIO.setmode(GPIO.BCM) mode? It's a bit confusing~~

Nice project, thank you for sharing!!

edit: I'm using RPi3 board...it seems like GPIO.BCM have different pin number across board version

Wi-Fi adapter

If I would use a non monitor mode adapter will it work?

Scapy ARP request breaks dhcpcd

I use this code to send an ARP request to a MAC to see if it's alive:

answered,unanswered = srp(Ether(dst='64:A2:F9:A9:2E:A9')/ARP(pdst='192.168.178.0/24'), timeout=1, verbose=False)

If the host is alive, then answered[0][1].hwsrc will be the same as the destination MAC, i.e. the host replied.

The problem is, when I run this 4 times in a row on my raspberry pi, I get these errors from dhcpcd:

Dec 29 18:24:10 raspberrypi dhcpcd[505]: wlan1: hardware address 00:00:00:00:00:00 claims 192.168.178.34
Dec 29 18:24:10 raspberrypi dhcpcd[505]: wlan1: 10 second defence failed for 192.168.178.34
Dec 29 18:24:11 raspberrypi dhcpcd[505]: wlan1: deleting route to 192.168.178.0/24
Dec 29 18:24:11 raspberrypi dhcpcd[505]: wlan1: deleting default route via 192.168.178.1
Dec 29 18:24:11 raspberrypi dhcpcd[505]: wlan1: rebinding lease of 192.168.178.34
Dec 29 18:24:11 raspberrypi dhcpcd[505]: wlan1: probing address 192.168.178.34/24
Dec 29 18:24:12 raspberrypi dhcpcd[505]: wlan1: hardware address 00:00:00:00:00:00 claims 192.168.178.34
Dec 29 18:24:12 raspberrypi dhcpcd[505]: wlan1: DAD detected 192.168.178.34
Dec 29 18:24:13 raspberrypi dhcpcd[505]: wlan1: soliciting a DHCP lease
Dec 29 18:24:13 raspberrypi dhcpcd[505]: wlan1: offered 192.168.178.35 from 192.168.178.1
Dec 29 18:24:13 raspberrypi dhcpcd[505]: wlan1: probing address 192.168.178.35/24

With kamene it works fine.

Packet Detected None

Both the "Last MAC detected" in the status command and the "packet detected" messages in /var/log/syslog always indicate "None". The system does arm itself after my phone is off the network and the ARP ping messages in the log do show the correct MAC address.

Horizontal Flip issue

Hi, great project and working really well here.

However one thing I cannot resolve is the Horizontal Flip of the image..
I have tried everything but to no avail. The image is Horizontally flipped the wrong way.

Have you come across this?

Thanks

hello sir, i am getting these issues

Traceback (most recent call last):
File "/usr/local/bin/rpi-security.py", line 9, in
import rpisec
File "/usr/local/lib/python3.7/dist-packages/rpisec/init.py", line 4, in
from .rpis_camera import RpisCamera
File "/usr/local/lib/python3.7/dist-packages/rpisec/rpis_camera.py", line 7, in
import imutils
File "/usr/local/lib/python3.7/dist-packages/imutils/init.py", line 8, in
from .convenience import translate
File "/usr/local/lib/python3.7/dist-packages/imutils/convenience.py", line 65, in
def resize(image, width=None, height=None, inter=cv2.INTER_AREA):
AttributeError: module 'cv2' has no attribute 'INTER_AREA'

usb camera

Hello I would wanna ask how to modify the code to make it work with a usb camera.

Configuration error: KeyError(2,)

I installed it using the steps in the guide but keep getting this error :

**pi@raspberrypi:~ $ sudo rpi-security.py -d

2018-03-19 23:12:48 DEBUG rpis_security.py:69 MainThread Data file read: /var/lib/rpi-security/data.yaml
2018-03-19 23:12:49 CRITICAL exit_clean.py:22 MainThread Configuration error: KeyError(2,)**

Any idea what might be wrong?

Thanks!

Failed to enable unit: Unit file rpi-security.service does not exist

I got some trouble to create the rpi.security service, also I got this weird message
Skipping wheel build for rpi-security, due to binaries being disabled for it.

sudo pip3 install --no-binary :all: https://github.com/FutureSharks/rpi-security/archive/1.5.zip

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting https://github.com/FutureSharks/rpi-security/archive/1.5.zip Downloading https://github.com/FutureSharks/rpi-security/archive/1.5.zip | 2.8 MB 1.2 MB/s Requirement already satisfied (use --upgrade to upgrade): rpi-security==1.5 from https://github.com/FutureSharks/rpi-security/archive/1.5.zip in /usr/local /lib/python3.7/dist-packages Requirement already satisfied: Pillow==6.2.1 in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (6.2.1) Requirement already satisfied: configparser in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (5.0.1) Requirement already satisfied: imutils==0.5.2 in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (0.5.2) Requirement already satisfied: kamene==0.32 in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (0.32) Requirement already satisfied: netaddr in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (0.8.0) Requirement already satisfied: netifaces in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (0.10.9) Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from rpi-security==1.5) (1.16.2) Requirement already satisfied: opencv-contrib-python-headless==3.4.6.27 in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (3.4.6.27) Requirement already satisfied: opencv-contrib-python==3.4.6.27 in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (3.4.6.27) Requirement already satisfied: picamera==1.13 in /usr/lib/python3/dist-packages (from rpi-security==1.5) (1.13) Requirement already satisfied: python-telegram-bot==12.2.0 in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (12.2.0) Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from rpi-security==1.5) (5.3.1) Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from rpi-security==1.5) (2.21.0) Requirement already satisfied: future>=0.16.0 in /usr/local/lib/python3.7/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.5) (0.18.2) Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.5) (2.6.1) Requirement already satisfied: tornado>=5.1 in /usr/lib/python3/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.5) (5.1.1) Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from python-telegram-bot==12.2.0->rpi-security==1.5) (2018.8.24) Skipping wheel build for rpi-security, due to binaries being disabled for it.

pi@PI:~ $ sudo systemctl daemon-reload
pi@PI:~ $ sudo systemctl enable rpi-security.service
Failed to enable unit: Unit file rpi-security.service does not exist.

Thanks in advance for your support

Telegram Bot Security Questions

This is more of a question than an issue.

I noticed some Telegram related error messages in my log at a time when I am certain no activity should have occurred. The system was disarmed and the phone was sitting next to me on the sofa.

Sep 30 10:25:33 raspberrypi rpi-security.py:Dummy-1 Motion detected but current_state is: disarmed
Sep 30 10:26:01 raspberrypi rpi-security.py:dispatcher Update "None" caused error "Invalid server response"
Sep 30 10:26:02 raspberrypi rpi-security.py:dispatcher Update "None" caused error "Invalid server response"
Sep 30 10:26:04 raspberrypi rpi-security.py:dispatcher Update "None" caused error "Invalid server response"
Sep 30 10:26:05 raspberrypi rpi-security.py:dispatcher Update "None" caused error "Invalid server response"
Sep 30 10:26:33 raspberrypi rpi-security.py:Dummy-1 Motion detected but current_state is: disarmed

Could someone else be chatting with my bot?

Is there anything stopping others from issuing commands to my bot?

Or barring that, does anything prevent the bot from acting on those commands?

Thanks

Cannot start service

Hi,

In first place I want to congratulate you for this great project.

I want to do the same using the official NoIR camera and a Pi Zero W. Because monitor mode and AP mode cannot be set with the integrated wireless chipset, I added another wifi adapter. Integrated wifi is in monitor mode (using Nexmon drivers) which works perfectly using "wlan0" and the wifi adapter uses "wlan1".
I edited rpi-security.conf to be able to listen two mac address using wlan0 device which is already in monitor mode.

sudo systemctl status rpi-security.service shows

● rpi-security.service - rpi-security service
Loaded: loaded (/lib/systemd/system/rpi-security.service; enabled)
Active: inactive (dead)

sudo systemctl start rpi-security.service shows nothing but keep on trying to execute

sudo rpi-security.py -d shows

2017-09-16 12:03:13 DEBUG rpis_security.py:69 MainThread Data file read: /var/lib/rpi-security/data.yaml
2017-09-16 12:03:13 CRITICAL exit_clean.py:22 MainThread Configuration error: Exception('Unable to get network address for interface wlan0',)

sudo ifconfig

wlan0 Link encap:UNSPEC HWaddr xxxxxxxx
inet6 addr: xxxxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:362594 errors:0 dropped:360848 overruns:0 frame:0
TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:50732163 (48.3 MiB) TX bytes:5157 (5.0 KiB)

wlan1 Link encap:Ethernet HWaddr xxxxxxxxx
inet addr:192.168.1.xx Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: xxxxxxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3477 errors:0 dropped:121 overruns:0 frame:0
TX packets:2538 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:535112 (522.5 KiB) TX bytes:525482 (513.1 KiB)

sudo iwconfig

wlan1 IEEE 802.11bgn ESSID:"mywifi" Nickname:"rtl_wifi"
Mode:Managed Frequency:2.462 GHz Access Point: xxxxxxx
Bit Rate:150 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:------- Security mode:open
Power Management:off
Link Quality=100/100 Signal level=90/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

wlan0 IEEE 802.11 Mode:Monitor Frequency:2.462 GHz Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on

sudo iw dev

phy#1
Interface wlan0
ifindex 4
wdev 0x100000001
addr xxxxxxxx
ssid mywifi
type monitor
channel 11 (2462 MHz), width: 20 MHz, center1: 2462 MHz

wlan1 is connected to a wpa wifi through wpa_supplicant.

How can I solve it?

Thanks in advance.

Photo processing / ARP Ping activity

Unsure if this is an issue, but there is a great deal of churning when processing photos. There is nearly five minutes of delay before a photo is processed. It seems to be related to the ARP ping false positive checking. Additionally, debug messages are stating that one of my non-monitored devices is sometimes responding to the ARP ping. 192.168.1.101 is my desktop with fixed IP address - its MAC is not one I've put in the config file.

Interesting facts:

  • The first photo to be processed is the first photo taken - I'm not sure if this means that all the others would have been processed eventually. I shut down the service thinking no photos were going to process.
  • You can see that I have added a "motion detected" message. This is why I noticed the issue - there is a very long delay between the message and the first photo coming through.

See the syslog:

Sep 25 18:25:34 raspberrypi systemd[1]: Starting rpi-security service...
Sep 25 18:25:34 raspberrypi systemd[1]: Started rpi-security service.
Sep 25 18:25:36 raspberrypi rpi-security.py:MainThread State file read: /var/lib/rpi-security/state.yaml
Sep 25 18:25:37 raspberrypi rpi-security.py:MainThread Calculated network: 192.168.1.0/24
Sep 25 18:25:54 raspberrypi kernel: [  667.995449] gpiomem-bcm2835 20200000.gpiomem: gpiomem device opened.
Sep 25 18:25:55 raspberrypi rpi-security.py:monitor_alarm_state thread running
Sep 25 18:25:55 raspberrypi rpi-security.py:capture_packets thread running
Sep 25 18:25:55 raspberrypi rpi-security.py:process_photos thread running
Sep 25 18:25:55 raspberrypi rpi-security.py:telegram_bot thread running
Sep 25 18:25:55 raspberrypi kernel: [  668.871548] device mon0 entered promiscuous mode
Sep 25 18:25:55 raspberrypi kernel: [  668.891736] device mon0 left promiscuous mode
Sep 25 18:25:55 raspberrypi kernel: [  668.923962] device mon0 entered promiscuous mode
Sep 25 18:25:57 raspberrypi rpi-security.py:MainThread rpi-security running
Sep 25 18:25:59 raspberrypi rpi-security.py:MainThread Telegram message Sent: "rpi-security: *running*"
Sep 25 18:26:25 raspberrypi kernel: [  698.775901] device wlan0 entered promiscuous mode
Sep 25 18:26:35 raspberrypi kernel: [  708.774992] device wlan0 left promiscuous mode
Sep 25 18:26:35 raspberrypi rpi-security.py:monitor_alarm_state MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:26:40 raspberrypi kernel: [  713.826129] device wlan0 entered promiscuous mode
Sep 25 18:26:51 raspberrypi kernel: [  725.170035] device wlan0 left promiscuous mode
Sep 25 18:26:51 raspberrypi rpi-security.py:monitor_alarm_state MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:26:56 raspberrypi rpi-security.py:monitor_alarm_state rpi-security is now armed
Sep 25 18:26:57 raspberrypi rpi-security.py:monitor_alarm_state Telegram message Sent: "rpi-security: *armed*"
Sep 25 18:27:04 raspberrypi rpi-security.py:Dummy-1 Motion detected
Sep 25 18:27:04 raspberrypi rpi-security.py:Dummy-1 Telegram message Sent: "rpi-security: *motion detected!*"
Sep 25 18:27:05 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182704-0.jpeg
Sep 25 18:27:06 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182704-1.jpeg
Sep 25 18:27:07 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182704-2.jpeg
Sep 25 18:27:08 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182704-3.jpeg
Sep 25 18:27:09 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182704-4.jpeg
Sep 25 18:27:10 raspberrypi kernel: [  743.876571] device wlan0 entered promiscuous mode
Sep 25 18:27:17 raspberrypi rpi-security.py:Dummy-1 Motion detected
Sep 25 18:27:18 raspberrypi rpi-security.py:Dummy-1 Telegram message Sent: "rpi-security: *motion detected!*"
Sep 25 18:27:19 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182718-0.jpeg
Sep 25 18:27:20 raspberrypi kernel: [  754.108334] device wlan0 left promiscuous mode
Sep 25 18:27:20 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:27:20 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182718-1.jpeg
Sep 25 18:27:21 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182718-2.jpeg
Sep 25 18:27:22 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182718-3.jpeg
Sep 25 18:27:22 raspberrypi kernel: [  756.190181] device wlan0 entered promiscuous mode
Sep 25 18:27:23 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182718-4.jpeg
Sep 25 18:27:24 raspberrypi rpi-security.py:Dummy-1 Motion detected
Sep 25 18:27:25 raspberrypi rpi-security.py:Dummy-1 Telegram message Sent: "rpi-security: *motion detected!*"
Sep 25 18:27:26 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182725-0.jpeg
Sep 25 18:27:27 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182725-1.jpeg
Sep 25 18:27:29 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182725-2.jpeg
Sep 25 18:27:30 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182725-3.jpeg
Sep 25 18:27:31 raspberrypi rpi-security.py:Dummy-1 Captured image: /var/tmp/rpi-security-2016-09-25-182725-4.jpeg
Sep 25 18:27:32 raspberrypi kernel: [  766.173209] device wlan0 left promiscuous mode
Sep 25 18:27:32 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:27:34 raspberrypi kernel: [  768.224440] device wlan0 entered promiscuous mode
Sep 25 18:27:44 raspberrypi kernel: [  777.667628] device wlan0 left promiscuous mode
Sep 25 18:27:44 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:27:44 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:27:49 raspberrypi kernel: [  782.725707] device wlan0 entered promiscuous mode
Sep 25 18:27:58 raspberrypi kernel: [  792.248501] device wlan0 left promiscuous mode
Sep 25 18:27:58 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:28:00 raspberrypi kernel: [  794.306233] device wlan0 entered promiscuous mode
Sep 25 18:28:09 raspberrypi kernel: [  803.006495] device wlan0 left promiscuous mode
Sep 25 18:28:09 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:28:11 raspberrypi kernel: [  805.078611] device wlan0 entered promiscuous mode
Sep 25 18:28:20 raspberrypi kernel: [  814.000448] device wlan0 left promiscuous mode
Sep 25 18:28:20 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:28:20 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:28:25 raspberrypi kernel: [  819.059234] device wlan0 entered promiscuous mode
Sep 25 18:28:34 raspberrypi kernel: [  828.145391] device wlan0 left promiscuous mode
Sep 25 18:28:34 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:28:36 raspberrypi kernel: [  830.197810] device wlan0 entered promiscuous mode
Sep 25 18:28:45 raspberrypi kernel: [  839.299724] device wlan0 left promiscuous mode
Sep 25 18:28:45 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:28:47 raspberrypi kernel: [  841.348005] device wlan0 entered promiscuous mode
Sep 25 18:28:56 raspberrypi kernel: [  849.803958] device wlan0 left promiscuous mode
Sep 25 18:28:56 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:28:56 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:29:01 raspberrypi kernel: [  854.864657] device wlan0 entered promiscuous mode
Sep 25 18:29:10 raspberrypi kernel: [  863.721609] device wlan0 left promiscuous mode
Sep 25 18:29:10 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:29:12 raspberrypi kernel: [  865.770097] device wlan0 entered promiscuous mode
Sep 25 18:29:22 raspberrypi kernel: [  875.745668] device wlan0 left promiscuous mode
Sep 25 18:29:22 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:29:24 raspberrypi kernel: [  877.799019] device wlan0 entered promiscuous mode
Sep 25 18:29:32 raspberrypi kernel: [  886.462998] device wlan0 left promiscuous mode
Sep 25 18:29:32 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:29:32 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:29:37 raspberrypi kernel: [  891.526744] device wlan0 entered promiscuous mode
Sep 25 18:29:46 raspberrypi kernel: [  899.852828] device wlan0 left promiscuous mode
Sep 25 18:29:46 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:29:48 raspberrypi kernel: [  901.900666] device wlan0 entered promiscuous mode
Sep 25 18:29:48 raspberrypi systemd[1]: Starting Cleanup of Temporary Directories...
Sep 25 18:29:48 raspberrypi systemd[1]: Started Cleanup of Temporary Directories.
Sep 25 18:29:58 raspberrypi kernel: [  912.307222] device wlan0 left promiscuous mode
Sep 25 18:29:58 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:30:00 raspberrypi kernel: [  914.360230] device wlan0 entered promiscuous mode
Sep 25 18:30:10 raspberrypi kernel: [  924.276652] device wlan0 left promiscuous mode
Sep 25 18:30:10 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:30:10 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:30:15 raspberrypi kernel: [  929.327862] device wlan0 entered promiscuous mode
Sep 25 18:30:24 raspberrypi kernel: [  938.284829] device wlan0 left promiscuous mode
Sep 25 18:30:24 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:30:26 raspberrypi kernel: [  940.334195] device wlan0 entered promiscuous mode
Sep 25 18:30:35 raspberrypi kernel: [  949.026329] device wlan0 left promiscuous mode
Sep 25 18:30:35 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:30:37 raspberrypi kernel: [  951.075062] device wlan0 entered promiscuous mode
Sep 25 18:30:50 raspberrypi kernel: [  963.802832] device wlan0 left promiscuous mode
Sep 25 18:30:50 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:30:50 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:30:55 raspberrypi kernel: [  968.857376] device wlan0 entered promiscuous mode
Sep 25 18:31:09 raspberrypi kernel: [  982.790253] device wlan0 left promiscuous mode
Sep 25 18:31:09 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:31:11 raspberrypi kernel: [  984.886270] device wlan0 entered promiscuous mode
Sep 25 18:31:24 raspberrypi kernel: [  997.716863] device wlan0 left promiscuous mode
Sep 25 18:31:24 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f responded to ARP ping with address 192.168.1.101
Sep 25 18:31:26 raspberrypi kernel: [  999.773546] device wlan0 entered promiscuous mode
Sep 25 18:31:36 raspberrypi kernel: [ 1010.000116] device wlan0 left promiscuous mode
Sep 25 18:31:36 raspberrypi rpi-security.py:process_photos MAC aa:aa:aa:aa:aa:8f did not respond to ARP ping
Sep 25 18:31:36 raspberrypi rpi-security.py:process_photos Starting to process photos
Sep 25 18:31:36 raspberrypi rpi-security.py:process_photos Processing the photo: /var/tmp/rpi-security-2016-09-25-182704-0.jpeg
Sep 25 18:31:57 raspberrypi systemd[1]: Stopping rpi-security service...
Sep 25 18:32:02 raspberrypi rpi-security.py:MainThread rpi-security stopping...
Sep 25 18:32:02 raspberrypi rpi-security.py:MainThread rpi-security stopping...
Sep 25 18:32:04 raspberrypi kernel: [ 1037.849649] device mon0 left promiscuous mode
Sep 25 18:32:04 raspberrypi avahi-daemon[334]: Withdrawing workstation service for mon0.
Sep 25 18:32:04 raspberrypi systemd[1]: Stopped rpi-security service.

I am looking at this code in process_photos:

else:
                logger.debug('Starting to process photos')
                for photo in list(captured_photos):
                    if time.time() - alarm_state['last_packet'] < 300:
                        break
                    logger.debug('Processing the photo: %s' % photo)

If I am reading this right, it is doing nothing until 5 minutes after the last packet was detected?

Changing picamera to USB camera

Hello all,

Quite amazing project!

I don't have picam and I've been struggling to find out where to change the camera from picam to a USB camera.

Could you please let me know where and how to modify the code?

Thank you!

kamene != scapy

Hi,

I'm a Scapy maintainer, and have bumped into this project because it was linked in https://github.com/phaethon/kamene/network/dependents

I've noticed that you were using kamene. I'm assuming you were using scapy-python3 before it was renamed. Please note that kamene is NOT an official Scapy version. Quoting https://scapy.net/

An independent fork of Scapy was created from v2.2.0 in 2015, aimed at supporting only Python3 (scapy3k). The fork diverged, did not follow evolutions and fixes, and has had its own life without contributions back to Scapy. Unfortunately, it has been packaged as python3-scapy in some distributions, and as scapy-python3 on PyPI leading to confusion amongst users. It should not be the case anymore soon. Scapy supports Python3 in addition to Python2 since 2.4.0. Scapy v2.4.0 should be favored as the official Scapy code base. The fork has been renamed as kamene.

Why this is a problem

There are two issues:

  • for you: you are using a version of Scapy that clearly is buggy and not maintained. Development is stopped (or sometimes a few merged PRs now and then) and it's missing many improvements and bug fixes. Moreover we had issues with the owner of this fork trying to mislead users by using a confusing name.
  • for us: we get bug reports that we fixed ages ago because some people still use this fork. This wastes some of our time

I'd advise switching to scapy = the original Scapy. Note that all you need to do is change the import name.

Thanks for your time !

PS: sorry if this feels copy/pasted. It is a bit :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.