From Facebook's Hackathon, TCP re-implemented over chat in a post-SOPA world
To re-implement file transfer, we decided to hijack Facebook's speedy chat service to do our own packet transmission. This is the way it works:
-A python localhost server converts binary data into base64 ASCII and forms packets with uuid's, timestamps, seqnums, and the whole 9 yards.
-These packets get pumped over localhost to a user script (aka a Greasemonkey script) running on Facebook.com.
-This user script handles the scrubbing of incoming chat messages (packets) and populating the chatbox with outgoing packets.
-Facebook does _not_ make sending a chat message easy with custom JS, so in order to actually send a chat message, we signal the python localhost server to run a bash script that tells applescript to emulate a keydown event. Hacked up, I know, but it works! Also, this works for any application (desktop, flash embedded, etc) because it's as legit as a real keypress.
Just pumping the packets was the first challenge which we finished around 2am. The second obstacle was that facebook decides to drop about 50% of our packets after the first 15, so we then implemented a crude TCP style acknowledgement/handshake method that ensures each packet gets delivered. Implementing TCP inside of TCP... as meta as you get.
If you want to watch a video of a nyan cat GIF transmission, go here:
http://www.youtube.com/watch?feature=player_detailpage&v=tk5m0mqsrFs#t=74s
The main point is that despite even the most extreme legal restrictions on the internet, the next generation will always find a way :D
Github: https://github.com/pcottle/emotiface
Happy to answer any questions. Techcrunch also showed up and filmed / walked around the office (which was surprising considering the relationship between the two). I remember the techcrunch guy specifically saying "I feel like I'm at the Deathstar" when he walked through Facebook's double doors.
25 comments
[ 23.0 ms ] story [ 1312 ms ] threadhttps://github.com/pcottle/emotiface/blob/master/backend/key...
As you can see, it just keeps hitting return 20 times (for 20 packets). The JS does the majority of the heavy lifting. It continually checks the chat textarea and waits for it to empty (when a keydown happens). When that happens, it loads the next packet and waits again. Code snippet:
//check if it's nothing
Link:https://github.com/pcottle/emotiface/blob/master/backend/sta...
There are various interesting ways to tunnel TCP inside many other protocols like ICMP, DNS, etc. The underlying principle is that since many protocols run over IP, as long as you're able to route IP, you're pretty much done.
EDIT: I didn't mean to sound pessimistic. :)
Obviously not a scenario that we will see any time soon (hopefully), but it was certainly a fun challenge to work on. It was also extremely hilarious to see two computers, side-by-side, chat each other actual network packets inside a browser.
http://en.wikipedia.org/wiki/Steganography#Digital_steganogr...
If you couldn't inject your own code into the chat plugin (or had trouble faking the packets from your own), you could do the extremely low-tech solution of videochatting a screen of a slowly-changing QR code. It would make encoding super simple and still allow for a decent amount of bandwidth transmission :D
Damnit! That's a good idea. 3k bytes per QR code, a conservative estimate of 15 fps, and you are at decent 45k a second with no code injection!
Or, better yet, you could just send raw pixels as bits, white = 0, black = 1. With 1024x768 HD video, that's a possible 768K/Frame => 22.5M/s @ 30 FPS!
What do you think? A friend who's exceptional at maths (I'm not) told me it's not possible, however I don't like when naysayers come and tell it's impossible. Still it demotivated me. Do you think it's possible?
Explained in two words: "Optical Transmission"
But at the same time, you don't need to limit to black-and-white. Even just black/white/red/green/blue/purple/yellow/turquoise would be four times as much bandwidth, and I would be very surprised if even lossy video couldn't reliably distingish up to 64 colours.
I don't think many people currently have 22.5M/s download speeds anyway, so it's probably not a big deal.
I wonder how many people actually owned a TV modem. It had to be a tiny market.
By the way, I highly recommend watching the episode, they interview Aleph One and some other old-school hackers.
That "download blast" section looks like it has a significant amount of bandwidth though. It's cool to see the idea implemented though
Edit: I mean multiple source, of this is already "broadcasted", so no need to take care of multiple receivers.
The only challenge would be dividing up the packet requesting, but you could do this manually by pasting in two handshake packets, one with startat at 0 and the other with startat at 50:
{"handshake":true,"uuid":"somethingRandom",type:"whichToSend","startAt":0,"filename":"nyancat"}
{"handshake":true,"uuid":"somethingRandom",type:"whichToSend","startAt":50,"filename":"nyancat"}
And then boom! Receive as normal and enjoy your ultra-slow bittorrent-style bandwidth
Yes taking over the inter is a diaster, but even something like that isn't enoughvto close the gates completely.
And the truth is, they can't.