V4L2Loopback

V4L2Loopback is a kernel module which allows for the creation of virtual video devices. Applications that support v4l2 (like VLC, Cheese, etc) can read such devices as a real video device. Moreover, the data fed to such applications can be generated by other applications (GStreamer, FFmpeg, etc).

Installation

git clone https://github.com/umlaeute/v4l2loopback.git
cd v4l2loopback-master
make && sudo make install

Running

sudo modprobe v4l2loopback

This will create a /dev/videoX device. More options to create devices on demand or to change their names can be found at v4l2loopback git repo. To feed data to our new device, we have chosen the ffmpeg video pipeline.

Using V4L2Loopback with Skype

In this project we are using Skype as the vehicle of our covert channel. We use a FFmpeg video pipeline to feed data into the v4l2 device.

Installing Skype

sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update && sudo apt-get install skype

Using Skype with FFmpeg pipeline

Skype was able to read the contents fed with the FFmpeg pipeline without hassle. However, Skype seems to check the video devices as soon as it is launched. If a proper video pipeline is not feeding data to the v4l2 device upon launch, Skype will trigger a pix_format error and unable to process further video input. An easy workaround is to set up a dummy video pipeline while Skype starts.

#feed device with a short, dummy stream so Skype can adjust
ffmpeg -nostats -re -i sync.mp4 -r 30 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 & 
#Launch Skype
skype

When a call is under way, Skype fixes the video stream parameters as those of the video stream it reads first. Changes in the pipeline video must respect the pixel format as well as the video scale (i.e. we can restart the pipeline with another video but it must respect colorspace/scale from the previous video).

Using Skype with GStreamer pipeline

Before using the FFmpeg pipeline, we tried the GStreamer pipeline. Skype requires the loading of one of the following Video4Linux v2 compatibility library so that it can sucessfully read the data that is fed to the device.

LD_PRELOAD=/usr/lib/i386-linux-gnu/libv4l/v4l1compat.so skype
LD_PRELOAD=/usr/lib/i386-linux-gnu/libv4l/v4l2convert.so skype

The location of libv4l may vary on your system.

Although we got Skype to read the data from a GStreamer pipeline, the image froze whenever Skype tried to access the device. Therefore, we moved to the FFmpeg pipeline.