Big Brother Farm
This project is about securing and wiring up a big farm. A quite large farm in northern Europe recently became my reponsibility. My first task is to secure it as I am not there every day. First step is to use security cameras etc. Second step is to improve the setup. Third step is to setup a fully autonomous drone surveillance system where drones take off on their own and land to charge. This takes inspiration from the cold war when Americans always had at least one B-52 airborne. Anyway, let's get back to step one which is described on this page. There are a thousand and one pieces to this project so this might take a while...
Ingredients:
- Router with SIM slot
- SIM card
- Range extender(s)
- Yagi antenna?
- Outdoor IP cameras
- Indoor IP cameras
- Wifi range extenders
- USB memory (multiple)
- USB camera
- USB microphone
- Raspberry Pi (multiple?)
- Floodlights
- Motion sensors
- Styrofoam box (for keeping the router and Raspberry Pi warm during winter.)
- Storage boxes
- Electrical timer switch
- Cables
- Warning signs
- Fake things (cameras etc.)
- Baits
- Honeypot wifi networks (For example Starbucks wifi, free airport wifi, etc.. anything that a bad guy might have configured on the phone.)
- UPS
Raspberry Pi scripts etc:
- Startup script
- Syncthing
- vsftpd
- fswebcam
- arecord
- Bluetooth sniffer script (trespassers will be sniffed)
- Uploader scripts
- Cleanup scripts
- Organizer scripts
- Remote command system (without VPN etc.)
- Uptime announce script
- Trigger scripts
Command and control server scripts:
- SSL connection
- Uptime receiver system
- Remote command text file (not yet fully implemented)
- Page for latest photos?
Home base Raspberry Pi:
- Syncthing
- Folders for storing stuff locally. Also for nightly zips which are copied to Synced folders.
- Folders for syncing to other devices via Syncthing
- Organizer scripts
- Active Syncthing folder for camera photos from the last hour.
Mobile device:
- Syncthing
- Home screen shortcuts to Syncthing folders (Android)
Current network topology:
- Zyxel LTE3301 and a 4G LTE SIM card used for the internet connection. Currently not getting full 4G speeds as the cell tower is several km away.
- Raspberry Pi 3 used as an internal server.
- One low resolution IP camera that uploads photos over FTP to the Raspberry Pi. Photos taken every 20 seconds.
- Two high resolution IP cameras that upload photos over FTP to the Raspberry Pi. Photos taken every 20 seconds.
- Syncthing syncs everything from the Raspberry Pi to the world and SSH scp scripts upload a latest photo to a web server elsewhere. Please see a later section called "Syncthing woes" for more.
- In total we have 3 cams x 4320 pics = 12960 pics per day (approx). On top of this there are videos where motion detection happened. These videos are .mkv and only a few megabytes a piece. On a typical day the movement of trees, foxes, rabbits, owls, deer, bugs on the camera lens, etc cause maybe around a dozen of these videos to be taken. The nightly zip of one of the HD cameras is somewhere between 200-600 MB depending on how much action there was during that day.
Things that don't seem to work:
- Running fswebcam via a cron job on the Raspberry Pi (+ USB camera) seems to freeze the whole system after an hour. USB camera setup will be dealt with later in the future.
- Recording audio using arecord and a USB microphone doesn't work as advertised. Something wrong with the syntax. Will be dealt with later when I have the time to read the man pages for the 27th time.
Syncthing woes section:
As mentioned before I'm using Syncthing for sending photos and other data to the devices and computers elsewhere. Syncthing is great when it works but when it doesn't work it really sucks and causes problems.
My rapid update folder with images from the last hour gets errors all the time. The Syncthing dashboard also claims that it is "Out of sync" and "isn't making progress" but there is no clear reason for this. The folder still works somehow and usually has images from roughly the last hour in it. I have a bash script on the master server deleting any images that are older than an hour and in that folder (apparently this is why Syncthing goes haywire).
My most recent problem is this: images from random days from the last month just won't go away. Deleting them on all the devices doesn't help. They just keep coming back!
Also checking the list of "out of sync files" from the Syncthing dashboard shows a bunch of files from last month that are "being synced". Thanks to my bash script those files should no longer exist! Currently my devices are eternally trying to sync a backlog of 70000+ non existing files and counting!
I have come to the conclusion that a faster folder rescan interval would probably remove these issues but that setting doesn't work well either. No matter what you change the folder rescan interval to.. it will always revert back to 3600 seconds!
Also the exclusion of MacOS .DS_Store files through folder settings doesn't work. They just keep on reappearing. And yes, I have tried excluding old files such as cam1-201806*.jpg - It works but stops all others files from being synced too.
Yes, I am running the latest version as Syncthing auto updates itself. At least that works.
Problems solved:
- Zyxel LTE3301 broadcasts 802.11bgn by default. Raspberry Pi cannot see this kind of a wifi network. I switched it to 802.11gn and now it works. Well.. b is too outdated anyway. Thanks Zyxel!
- Syncthing failed to mount any USB attached storage upon reboot. This resulted in permission errors. I made a simple script that makes Syncthing wait for one minute during system reboot. This gives enough time for the OS to mount USB disks and for Syncthing to access them.
Security impact so far:
- Several uninvited cars and individuals have visited the farm. In the countryside word travels fast that there is an unattended house somewhere. What I did was I uploaded some of the security camera videos as unlisted videos to YouTube and sent the links to the neighbors and the cops. This did the trick. Not sure how but the word got around again and uninvited visits have stopped for now. Neighbors and cops should be ok right? Go figure. Let's see how this continues.
- Anyway.. Trespassers will be sniffed, recorded, honeypotted and so on..