Saturday, 7 January 2012

So you want to get your ustream video off your iPhone? is great for streaming events to distant relatives and such. My wife and I used their iPhone app to great success for our wedding last year. Unfortunately, for videos that we were able to record but not stream due to limited WiFi access, we have had no luck getting the incredibly slow uploads to actually complete. After a year and numerous attempts, I thought I'd find my own way to get these video's off the device without resorting to jailbreaking, etc.

Ustream sends a HTTP request to ask for the location of an FTP server to upload your videos to. We will pretend to be that server.

1. On an ubuntu box (call it

  $ sudo apt-get install ftpd wireshark

2. Find or setup a linux router between you and the internet and run this on it:

  $ iptables -t nat -I PREROUTING -p tcp --dport 21 -j DNAT --to-destination
  $ iptables -t nat -I PREROUTING -p tcp -d -j REDIRECT --to-port 21

The first line sends all FTP traffic to your local FTP server instead of wherever it was originally headed.
The second line redirects all ports sent to the ustream FTP server IP subset (at the time of writing at least. ping to port 21.
Together they make sure all the traffic ustream tries to send to itself gets sent to your ubuntu box instead.

3. Now you either a. mess with your FTP server to allow all usernames / passwords to work (edit the source code, mess with authentication modules, etc.) or b. do as I did and run tcpdump on your linux router:

  $ sudo tcpdump -i eth0 "src iphone_ip or dst iphone_ip" -s 2000  -w iphone.pcap

3a. Go to your iphone and try to upload a video. It will get stuck at Uploading 0%. Cancel the upload. Ctrl-C tcpdump and open the file on your ubuntu workstation with wireshark.

  $ wireshark iphone.pcap

3b. The username and password ustream uses will be in a binary blob in the response to a request sent to that you should have in your iphone.pcap log file.

3c. Run off and create the users as required:

  $ sudo useradd -m 1_12345_12345
  $ sudo passwd 1_12345_12345
  New password: .....

  New password (again): .....

4. Go to your phone, hit "Upload".

5. Profit! (Or simply savour your new-found ability to watch your precious videos wherever you like!)