Hack to Spy: Building a Raspberry Spy Pi, Part 03

Tr0jan_Horse

Moderator
Staff member
MODERATOR
ULTIMATE
PREMIUM
MEMBER
Joined
Oct 23, 2024
Messages
304
Reaction score
8,795
Deposit
0$
In this article, I will show you how to capture full video from your Raspberry Spy Pi and then create a script that will capture video at discrete intervals to save storage on your tiny spying device.


6a4a49_27b76af4983f478c92caec205e1519f3mv2-1.webp



Step #1 Login to Your Spy Pi with SSH


The first step, of course, is to login to your Spy Pi remotely with SSH.


kali > ssh [email protected]


6a4a49_b752159631464329913eea6cc677dbfemv2-1.webp



Step #2 Capture Video


Now that we are logged in remotely to our Spy Pi, we can begin to capture video from it. Our Raspbian operating system has a utility named raspivid that is capable of capturing video from the attached raspberry pi camera. To do so, we simply type;


raspberrypi > raspivid -o spytest -t 1000


Where:


raspivid is the video capture command


-o designates the output


spytest is the name of the output file


1000 is the number of hundreds of seconds of video to capture (10s)


6a4a49_00959e7c8a0146b99dad5adb16945b50mv2.webp



As you can see above, we were able to capture 10s of video in a file named spytest. Also, note that the captured video is 1.2M


Step #3 Create a BASH script to Capture Video at Discrete Intervals


As we saw in the previous step, our Spy Pi can capture video using the raspivid command. The problem with this technique is the amount of space that the video consumes. You can see that the 10 seconds video consumed 1.2M. This isn’t a lot of space, but if we were trying to capture hours or days of video, we could easily fill terabytes of data space. Unless you attach an external hard drive to our Spy Pi, that will overwhelm our little Spying device.


Perhaps a better approach would be to capture chunks of video at discrete intervals. Maybe… only capture 10 seconds of video every minute. To do this we can write a simple BASH script.


Let’s open nano remotely on the Spy Pi or you can open a GUI based text editor directly on the Spy Pi. I will be using nano as my text editor and I suggest you do the same as we will need to access this Spy Pi remotely in the future and a little practice with nano now, will go a long way later. Open nano by typing;


raspberrypi > nano


When it has opened, we can now enter our script.


Our script will look like this;


#! /bin/bash do raspivid -o spycam .$i -t 1000 sleep 60s done


You can see it below in nano.


Note that I have used the for loop integer, i, as a variable in the name of the output file, spycam.$i. In this way, each video capture will be numbered consecutively so that we can go back and view any minute’s capture.


Now, hit CTL+X to exit, enter Y to save and give it a name of spyscript.


6a4a49_49e11abb27114826b44fc0a4cf1ff801mv2-1.webp



After we have saved the spyscript, we will need to give ourselves permission to execute it. We can use the chmod command to do so.


raspberrypi > chmod 755 spyscript


6a4a49_1eddbc5a3085432a8ab0b5017f225356mv2-1.webp



As we can see above, after we have changed the permissions and done a long listing, our spyscript now has execute permissions. We are ready to use our Spy Pi to capture hours of video!


6a4a49_8f346931d81a4a8eb24b5d0e500c3c89~mv2.jpg



Step #4 Run the Script


Now we are ready to run our script that will capture 10 seconds of video every minute. To do so, type;


raspberrypi> sudo ./spyscript


6a4a49_f25c3f8e858c4c599002b6fb41b83a7fmv2.webp



It will now begin to capture 10 seconds of video every minute and store it in files with consecutively numbered names such as spycam.1, spycam2, spycam3, etc. I interrupted mine after just 3 minutes to show you the output, but if you let it run, you will have files spycam.1 all the way to spycam.1000.


This will enable us to view any snippet of video in consecutive order. Obviously, if we wanted to see video from the second hour, we could simply view spycam.61, where 61 designates video from the 61st minute.


Step #5 Reduce Further your Storage Needs


Of course, even this much of video might overwhelm the storage in your tiny Spy Pi. If that is the case, you could increase the sleep time (say sleep 120s or 180s) or reduce the amount of video say to 500 (5s).


In future articles in this series, I will show how to view the video captures remotely as well as capture audio, so keep coming back to Hackers-Arise! and learn the most valuable skill set of the 21st century–hacking!
 
Top Bottom