Skip to content

Commit

Permalink
Switch back to scapy, pin some package versions, create new release (#49
Browse files Browse the repository at this point in the history
)

* switch back to scapy

* pin some package versions and create new release

* fix this version

* misc changes
  • Loading branch information
FutureSharks authored Oct 27, 2019
2 parents 2ddb2ab + 8449443 commit 6115c03
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions rpisec/rpis_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions rpisec/threads/capture_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

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()


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]
Expand All @@ -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()
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name = 'rpi-security',
version = '1.3',
version = '1.4',
author = 'Max Williams',
author_email = '[email protected]',
url = 'https://github.com/FutureSharks/rpi-security',
Expand All @@ -20,18 +20,18 @@
('/var/lib/rpi-security', ['etc/data.yaml'])
],
install_requires = [
'python-telegram-bot',
'picamera',
'imutils',
'python-telegram-bot==12.2.0',
'picamera==1.13',
'imutils==0.5.2',
'numpy',
'configparser',
'requests',
'requests[security]',
'netaddr',
'netifaces',
'pyyaml',
'kamene',
'Pillow',
'scapy==2.4.3',
'Pillow==6.2.1',
'opencv-contrib-python',
'opencv-contrib-python-headless',
],
Expand Down

0 comments on commit 6115c03

Please sign in to comment.