From b3d4bb602ea5a42e2589c0bd20b569270e9ee226 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Oct 2019 17:41:41 +0200 Subject: [PATCH 1/5] switch back to scapy --- README.md | 2 +- rpisec/rpis_security.py | 4 ++-- rpisec/threads/capture_packets.py | 14 +++++++------- setup.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 535d856..de53096 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ You can send the Telegram bot commands that trigger certain actions. The application is written in python 3 and large parts of the functionality are provided by the following pip packages: - [picamera](https://github.com/waveform80/picamera) - - [kamene](https://github.com/phaethon/kamene) + - [scapy](https://github.com/secdev/scapy) - [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) - [opencv-python](https://github.com/skvark/opencv-python) diff --git a/rpisec/rpis_security.py b/rpisec/rpis_security.py index 6926255..43433b1 100644 --- a/rpisec/rpis_security.py +++ b/rpisec/rpis_security.py @@ -6,12 +6,12 @@ import yaml import logging -logging.getLogger("kamene.runtime").setLevel(logging.ERROR) +logging.getLogger("scapy.runtime").setLevel(logging.ERROR) from configparser import SafeConfigParser from netaddr import IPNetwork from netifaces import ifaddresses -from kamene.all import srp, Ether, ARP +from scapy.all import srp, Ether, ARP from telegram import Bot as TelegramBot from .exit_clean import exit_error from .rpis_state import RpisState diff --git a/rpisec/threads/capture_packets.py b/rpisec/threads/capture_packets.py index dcd1031..bf60b61 100644 --- a/rpisec/threads/capture_packets.py +++ b/rpisec/threads/capture_packets.py @@ -2,10 +2,10 @@ import _thread import logging -from kamene.all import sniff -from kamene.all import conf as kamene_conf -kamene_conf.promisc=0 -kamene_conf.sniff_promisc=0 +from scapy.all import sniff +from scapy.all import conf as scapy_conf +scapy_conf.promisc=0 +scapy_conf.sniff_promisc=0 logger = logging.getLogger() @@ -13,10 +13,10 @@ def capture_packets(rpis): """ - This function uses kamene to sniff packets for our MAC addresses and updates + This function uses scapy to sniff packets for our MAC addresses and updates the alarm state when packets are detected. """ - logging.getLogger("kamene.runtime").setLevel(logging.ERROR) + logging.getLogger("scapy.runtime").setLevel(logging.ERROR) def update_time(packet): packet_mac = set(rpis.mac_addresses) & set([packet[0].addr2, packet[0].addr3]) packet_mac_str = list(packet_mac)[0] @@ -36,5 +36,5 @@ def calculate_filter(mac_addresses): try: sniff(iface=rpis.network_interface, store=0, prn=update_time, filter=calculate_filter(rpis.mac_addresses)) except Exception as e: - logger.error('kamene failed to sniff packets with error {0}'.format(repr(e))) + logger.error('scapy failed to sniff packets with error {0}'.format(repr(e))) _thread.interrupt_main() diff --git a/setup.py b/setup.py index df2caba..07ac883 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ 'netaddr', 'netifaces', 'pyyaml', - 'kamene', + 'scapy==2.4.3', 'Pillow', 'opencv-contrib-python', 'opencv-contrib-python-headless', From 177948de85c6c685fc1c9ae43b6295657713ad5e Mon Sep 17 00:00:00 2001 From: Max Williams Date: Thu, 24 Oct 2019 17:45:16 +0200 Subject: [PATCH 2/5] pin some package versions and create new release --- README.md | 2 +- setup.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index de53096..f19fe60 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Install open-cv and rpi-security: ```console sudo pip3 install opencv-contrib-python opencv-contrib-python-headless -sudo pip3 install --no-binary :all: https://github.com/FutureSharks/rpi-security/archive/1.3.zip +sudo pip3 install --no-binary :all: https://github.com/FutureSharks/rpi-security/archive/1.4.zip ``` Reload systemd configuration and enable the service: diff --git a/setup.py b/setup.py index 07ac883..7585f83 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name = 'rpi-security', - version = '1.3', + version = '1.4', author = 'Max Williams', author_email = 'futuresharks@gmail.com', url = 'https://github.com/FutureSharks/rpi-security', @@ -20,8 +20,8 @@ ('/var/lib/rpi-security', ['etc/data.yaml']) ], install_requires = [ - 'python-telegram-bot', - 'picamera', + 'python-telegram-bot==12.2.0', + 'picamera==1.13', 'imutils', 'numpy', 'configparser', @@ -31,9 +31,9 @@ 'netifaces', 'pyyaml', 'scapy==2.4.3', - 'Pillow', - 'opencv-contrib-python', - 'opencv-contrib-python-headless', + 'Pillow==6.2.1', + 'opencv-contrib-python==4.1.1.26', + 'opencv-contrib-python-headless==4.1.1.26', ], classifiers = [ 'Environment :: Console', From cd044c398f2d6f7a2cdab8949e76d565c0b00487 Mon Sep 17 00:00:00 2001 From: Max Williams Date: Sat, 26 Oct 2019 18:30:23 +0200 Subject: [PATCH 3/5] fix this version --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 7585f83..d9a04af 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ 'pyyaml', 'scapy==2.4.3', 'Pillow==6.2.1', - 'opencv-contrib-python==4.1.1.26', - 'opencv-contrib-python-headless==4.1.1.26', + 'opencv-contrib-python==3.4.4.19', + 'opencv-contrib-python-headless==3.4.4.19', ], classifiers = [ 'Environment :: Console', From afb2ddd77b97f075a8264f27e5af21f20efa5b5f Mon Sep 17 00:00:00 2001 From: Max Williams Date: Sat, 26 Oct 2019 18:35:22 +0200 Subject: [PATCH 4/5] misc changes --- README.md | 1 - setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f19fe60..74e1708 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,6 @@ sudo apt install -y libhdf5-100 libharfbuzz0b libwebp6 libjasper1 libilmbase12 l Install open-cv and rpi-security: ```console -sudo pip3 install opencv-contrib-python opencv-contrib-python-headless sudo pip3 install --no-binary :all: https://github.com/FutureSharks/rpi-security/archive/1.4.zip ``` diff --git a/setup.py b/setup.py index d9a04af..eab5d98 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ install_requires = [ 'python-telegram-bot==12.2.0', 'picamera==1.13', - 'imutils', + 'imutils==0.5.2', 'numpy', 'configparser', 'requests', From 8449443a626eaa403f45a4f885be926bfe54bee1 Mon Sep 17 00:00:00 2001 From: Max Williams Date: Sat, 26 Oct 2019 19:32:04 +0200 Subject: [PATCH 5/5] more version changes --- README.md | 1 + setup.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74e1708..f19fe60 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ sudo apt install -y libhdf5-100 libharfbuzz0b libwebp6 libjasper1 libilmbase12 l Install open-cv and rpi-security: ```console +sudo pip3 install opencv-contrib-python opencv-contrib-python-headless sudo pip3 install --no-binary :all: https://github.com/FutureSharks/rpi-security/archive/1.4.zip ``` diff --git a/setup.py b/setup.py index eab5d98..876975c 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,8 @@ 'pyyaml', 'scapy==2.4.3', 'Pillow==6.2.1', - 'opencv-contrib-python==3.4.4.19', - 'opencv-contrib-python-headless==3.4.4.19', + 'opencv-contrib-python', + 'opencv-contrib-python-headless', ], classifiers = [ 'Environment :: Console',