Feed Icon RSS 1.0 XML Feed available

FLATWORM: Low-Latency Rewriting Proxy

Tags: , , ,

Flatworm
Note This is me documenting an old investigation from 2008, in 2014 -- so I can clean the project off my hard drive!
Flatworm is a proxy (simpler than a "Squid" :-P) that allows for easy bookkeeping while rewriting traffic. The original goal was to inject frames into YouTube videos as they went by if one were serving as a proxy for a network connection to youtube.com. It evolved into an attempt to build a general purpose system for mutating http traffic while also mutating the headers to be consistent with the mutated data.

Overview Video

Backstory

There was a funny article I read about someone who had noticed his neighbors were using his WiFi. He could have just locked it up with a password, but decided to do something funnier. When an unrecognized machine connected to the network, he ran the data through a proxy to turn all the images upside-down:
As a thought-experiment, in 2008 I decided to look into what it would take to inject (and/or remove) frames in YouTube videos if you were proxying them. I wanted it to perform well for streaming...so that the latency would not be noticeable.
Seeking something that would perform well, I decided to look for the smallest proxy server written in C that I could find, that compiled and worked. At the time that led me to version 0.6 of something called 3Proxy, written by Vladimir Dubrovin (3APA3A):
The filtering design I made has some interesting nuances. I doubt there's anything out there that attacks exactly the same problem in the same way. But likely there's some combination of other methods in this space that are better for most purposes.
I'll mention that if this topic interests you, then you will almost certainly want to look at the "Man In The Middle Proxy":

Source Code

The code is available on GitHub:
Note The Flatworm sketch I found on Google Images but could not determine the artist. I hope they don't mind me borrowing it for something that is gratis software, non-commercial in nature, and an inactive project. If you drew it--or know who did--please let me know!
I started from 3Proxy as it "just worked", and was easy enough to get my head around. My knowledge of HTTP was not very detailed when I started. So I slowly evolved it from C into using C++-isms. Though I was not yet deeply knowledgable about C++ in 2008, and (for instance) was just starting to use auto_ptr, which is now deprecated. Other oddities in there (for instance, I hadn't heard of boost::optional, but invented something similar called "knowable").
If I were to tackle something like this again today, I would want to build it using Boost.ASIO or perhaps a different language paradigm altogether, like Red. So I don't really suggest anyone use it, except possibly for educational purposes. I'm just archiving it on GitHub to get it off my hard drive, and to accompany a video..
Business Card from SXSW
Copyright (c) 2007-2018 hostilefork.com

Project names and graphic designs are All Rights Reserved, unless otherwise noted. Software codebases are governed by licenses included in their distributions. Posts on blog.hostilefork.com are licensed under the Creative Commons BY-NC-SA 4.0 license, and may be excerpted or adapted under the terms of that license for noncommercial purposes.