Sun, 16 Mar 2008

Trainblogging, Part 2

In a previous post, I mentioned how I was able to blog from an Amtrak train by using my jailbroken iPhone to connect to the Internet.

I didn't provide a lot of detail, and finding myself on another Amtrak train with several hours to pass the time, I thought I'd share exactly how it's done.

You will need:
  • A jailbroken iPhone
  • A Mac laptop with wifi
  • The open source SOCKS proxy "srelay" for the iPhone


The basic idea is simple-- first we're going to create an ad-hoc wifi network with the laptop. (The difference between an "ad-hoc" network and an "infrastructure" network is how the network is created. In "infrastructure mode" the wifi network is typically created by a dedicated wireless access point, or WAP. We won't need an access point, so we'll take advantage of "ad hoc" mode where the laptop will create and use its own network). We'll connect to this network, and put the routing in place to allow the laptop to access web pages via SOCKS. (Note: Since the SOCKS proxy is configured via System Preferences, only applications that are aware of this Network Preference can use the SOCKS proxy. For applications like Firefox or other network clients that don't use the Network Preferences setting, you'll have to manually configure them the same way.)

Let's get started.

  1. Create an ad-hoc network on your Macbook. The easiest way to get it set up is to choose no security*. From the wifi menu bar, select "Create Network", and give it a name.
  2. From your iPhone, browse the wireless networks, and join the wifi network you just created.
  3. On your iPhone, specify the IP address it should have statically (there's no DHCP server). I chose 192.168.1.100
  4. On your Mac, open Network Preferences, and create a location. I called mine iPhone, and gave my laptop the IP address 192.168.1.101
  5. Now that both computers are on the same network, you can verify that the two can talk to each other by opening up Terminal.app and typing "ping 192.168.1.100". You should see successful pings. (You can also ping from the other direction from the iPhone to the Mac)
  6. Next, in Network preferences, open the "Advanced" menu and select the "Proxies" tab.
  7. Check the "SOCKS proxy" box, and provide the IP address of the SOCKS proxy: 192.168.1.100. Don't forget port 1080.
  8. Click OK, and launch Safari. Assuming your iPhone has access to the EDGE network, you should be able to download web pages at a blazing 128Kbps.

Security Note: Putting BSDKit on an iPhone and creating an unsecured 802.11 network could expose your iPhone to risk. For example, the default root password on an iPhone is "dottie". Arguably, hackers could connect to your unsecured wifi network, discover the IP addresses you're using, connect to 192.168.1.100 via ssh, and run "rm -rf /" to delete everything off your iPhone. Needless to say, you should change the default root password on your iPhone, you should only connect to networks you can trust, and use https to create end-to-end encryption to prevent snooping of sensitive HTTP connections.

* Once you get the basic authentication set up, go back and lock down your network using WPA or WEP. You'll have to configure the network properly first on the Mac, then use the same auth credentials to connect with the iPhone.




Khan Klatt

Khan Klatt's photo