Nothing to see here. The not-so-charger

El Kentaro
7 min readAug 22, 2018

So the whole mess with DEF CON this year where the hotel side conducted involuntary searches of hotel rooms and confiscated items from the room raised some questions about privacy
and hotel rooms. Now I understand given the circumstances with the mass shooting at the Mandalay Bay that the hotels are trying to minimize the possibility of another incident, however unannounced searches and threatening customers are questionable tactics. Obviously the hacker community has raised its voice, @DeviantOllam has announced a funding of smartphone app that would help in recording these searches. I agree that the smartphone is probably the best form factor for leaving in the room without raising any suspicions. However also because of the potential abuse I also understand that both iOS and Android are not allowing recording using the camera/microphone while the phone is locked. So I looked around for a different solution and I decided a fake phone charger form factor would work.

I’m sure many of us already have one of these multi-port usb chargers to charge all our gadgets. So my idea was to create a casing for an RPi that looked like one of those chargers.

Hardware parts.

1.Raspberry Pi 3B +
For the motion sensing to work , you want the maximum performance. You could go with an odroid or any of the more powerful ones but for “ease of procuring” and cost the RPi 3B+ is hard to beat. If you do not need all the performance you could probably use an Rpi0 too, but i found it that the 0 is just too weak for a stable operations, especially when you try to do motion detection and triggering events.

2.Raspberry Pi Camera (Pi NoIR)
Technically you could use any of the different camera options available but I just happen to have a infrared capable camera and it would help in low light situations , given that there is some IR light.

3.Raspberry Pi AC adaptor.

5. Android Phone

6.Optional : USB microphone
Recording audio gets tricky from a legal perspective but if you do decide you need audio recording you can use one of those usb mini-usb-microphones.

Software:

1.OS:
Raspian Stretch lite.

Since this is pretty much a headless configuration , don’t need all the desktop gui stuff.

I like to keep my files in one place so I created a directory named “dumps” in the home directory. This is where all the recordings are kept for a local copy.

2.Motion

This is the backend package that will do the recording of videos. You can use the one that comes with Raspian
but i suggest you build it from source. See MotionEye.

3.MotionEye https://github.com/ccrisan/motioneye/wiki/Install-On-Raspbian

MotionEye is a web front for the motion software. It allows all types of customization.
Follow the instructions on how to install motion from source and motioneye.

Also if you plan to use DropBox , setup the directory etc.

4. Easytether

Easytether allows you to easily tether your Rpi over either usb or bluetooth to an Android phone.

a). Download the easytether dep package to your Rpi: http://www.mobile-stream.com/beta/raspbian/9/easytether_0.8.9_armhf.deb
then install it by:

sudo dpkg -i easytether_0.8.9_armf.deb

b). Download the apk via their site or Google play.
http://www.mobile-stream.com/easytether/android.html

c). You need to enable the “developer mode” on your Android phone.
Usually you can do this by going to Settings > About phone > Build number , tap Build number multiple times and it should enable Developer options.

d). For easytether to work you need to enable the “USB debug” Option under Settings.

5. Optional; Recording sounds.
We will just use the default arecord command to record the sound.

Setup procedure.

  1. Install Raspian Stretch Lite
    2. Runs raspi-config and setup the usual things.
    3. Install Motion and Motioneye
    4. Setup Motioneye
    5. Install Easytether on the Rpi
    6. Configure Easytether on the phone
    7. Install Rpi into the case.

Setting up Motioneye

Motioneye is great frontend for the motion software by Calin Crisan. It has a ton of options but I will just go through some of my settings.

Motioneye: https://github.com/ccrisan/motioneye/wiki

  1. Change admin password …well ya.
  2. Add a camera by “add a camera…”
  3. Rotate the camera to fit the view. Once you rotate you can set the resolution to regain the view where width is larger than height. (i.e.: rotate camera 270 degrees, change resolution to Width:800 Height:1024)
  4. So we want a script to run once the a recording/image has been created. So use the “Run a command” in the “File Storage” section. This command runs once a media file has been created, we will use this to upload the sound recording to the same directory on Dropbox as where all of our other images and videos are being recorded.
  5. Setup “Run a Command” under Motion Notifications.
    We want to record the sound of the room once the motion detection has been triggered. Motion by itself does not have audio recording capabilities so we will use a script to record the sound.

The Uplink to the Netz

Because we use easytether to provide the uplink to the Rpi , there really isn’t much we need to do. The usb cable connecting the phone will provide the linkage between the Rpi and the phone and phone will use whatever uplink it has and share it back to the usb cable. (take that , “hotel captive portals”)

Individual scripts:

So I use 2 scripts , 1. to record the sound. 2. to upload the sound recording to dropbox.

Motion can upload the images/videos it takes to a directory in Dropbox, however since motion does not have sound recording capabilities we will use the unix command arecord to record the sound using the usb microphone and once its done upload it to dropbox.

recording the sounds:

In some states/region recording audio without consent is considered illegal so be careful if you decide to record the sound.

So I use a usb microphone so I need to blacklist the onboard sound chip so the usb microphone is the default. Technically this is not required but it does make life a bit easier.
Just create a file /etc/modprobe.d/alsa-blacklist.conf that has this one line:

blacklist snd_bcm2835

once you have done this , you might want to reboot the Rpi.
After the reboot you might want to test your microphone , usually the recording volume is low , but you can change this by using alsamixer command.

setting up the sound recording script:

soundrec.sh script:

#!/bin/bash
timestamp=`date '+%Y_%m_%d__%H_%M_%S'`;
tfolder=`date '+%Y-%m-%d'`;
if pgrep -x 'arecord' > /dev/null
then
sudo pkill arecord
sudo arecord -D plughw:0,0 --max-file-time=300 /home/pi/dumps/$tfolder/$timestamp.wav
else
sudo arecord -D plughw:0,0 --max-file-time=300 /home/pi/dumps/$tfolder/$timestamp.wav
fi

pretty simple, once its called it creates a timestamp filename and record the audio.

Once motion detection is done and the files have been created motioneye will upload the images/videos to Dropbox. However we still have to manually upload our sound files into the respective directory. For this you gonna need a Dropbox API key. So head over to the Dropbox API “My apps” : https://www.dropbox.com/developers/apps , and click on “Create APP” , select the Dropbox API. Select the “Full Dropbox” option, if you don’t you can only upload to a folder called “Apps” in your dropbox. (this might work, but you gonna need to setup MotionEye and the other scripts to hit the same directory)

Get the token and plug it into the following script:

#!/bin/bash
if pgrep -x 'arecord' > /dev/null
then
sudo pkill arecord;
fi
sleep 5;
timestamp=`date '+%Y-%m-%d'`;filename=$(ls -t /home/pi/dumps/$timestamp/*.wav | head -1 | awk -F '/' {'print $6'});
tfile=$(ls -t /home/pi/dumps/$timestamp/*.wav | head -1);
filepath="/roadpi/$timestamp/$filename";curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer [ACCESS_KEY]” \
--header "Dropbox-API-Arg: {\"path\": \"$filepath\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @$tfile

Once you have all the software configured then you gonna need to put the Rpi into the case, one catch here , in order to make the case small etc etc.The current design of the case requires that you either desolder the headers or you can just clip them like I did . (I was too lazy to actually desolder the headers)

The case doesn’t have the holes for the RPi , so you need to drill the holes in. The reason for this is due to the fidelity of my printer its just easier to manually drill the holes. You want to use 5mm spacers between the Rpi and the case to raise the Rpi a bit to give it some airflow.

To line up the camera lens with the hole in , just look under a bright light and check so you can line up the camera lens with the case hole. Once you have the lens lined up , just use some hot glue and glue the camera on to the case.

That’s it everything should run automatically once the RPi is powered on.

After you are done building it and you realize you need to adjust some of the settings, you can just use a usb-ethernet dongle to connect to the Rpi.

Although not the ideal form factor, I think its closer than anything else. Like I said, this is my contribution to an issue. I hope it inspires you to go make your own solution.

Case files on Thingiverse.

https://www.thingiverse.com/thing:3061919

--

--