One of the courses I took recently focused on programming a microcontroller. I was told to do a project that somehow involved a sensor, a microcontroller and software for user interaction. I'd previously come across an article about "hacking" Siri, making it possible to interact with various hardware using a Raspberry Pi and thought use that in the project.

In this post, I'll focus on telling you how to setup the Siri proxy server (SiriProxy by Plamoni). My plan is to do a few other separate posts with things I've learned during the project.

I've found a couple of guides on how to install the SiriProxy gem on a Raspberry Pi, but I thought that some of them were missing a few steps, and others had gotten the sequence mixed up.

I decided to write my own walkthough of the intallation process, trying to add the few things I thought was missing while still keeping it simple.

Prerequisites

  • You should already be familiar with your Raspberry Pi, and know how to connect to it through SSH.
  • Some of the build processes take a while to finish so you'll need some patience too.
  • For this example installation, I've set the static ip of my Raspberry Pi to 192.168.0.4

The process

  1. Install necessary dependencies
  2. Install rvm to manage ruby
  3. Build and install ruby
  4. Build and install the siriproxy gem
  5. Install and setup DNS server on the Raspberry Pi to redirect Siri-traffic to SiriProxy
  6. Generate siriproxy certificates and tranfer them to your iOS device
  7. Run the siriproxy server

Install dependencies

$ apt-get update
$ apt-get dist-upgrade
$ apt-get autoremove
# siriproxy dependencies
$ apt-get install libxslt1.1 libxslt-dev xvfb build-essential git-core curl libyaml-dev libssl-dev
# rvm dependencies
$ apt-get --no-install-recommends install bash curl git patch bzip2
# ruby dependencies
$ apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev

Install rvm

$ curl -L https://get.rvm.io | bash -s stable --ruby
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.zshrc
$ source ~/.zshrc # reload the file

Note: If you're using bash, replace .zshrc with .bashrc

Install Ruby 1.9.3 through RVM.

$ rvm install 1.9.3
$ rvm use 1.9.3 --default

This will take a while. The Raspberry Pi has limited processing power, and when you install the ruby version, it has to download and compile it. Don't be surprised if it takes about an hour to finish the rvm install command

Install SiriProxy

Download latest repo from GitHub

$ git clone git://github.com/plamoni/SiriProxy.git ~/SiriProxy

Build the gem

$ cd ~/SiriProxy
# enter 'y' when prompted by rvm
$ mkdir ~/.siriproxy
$ cp config.example.yml ~/.siriproxy/config.yml
$ rake install
# siriproxy 0.4.0 built to pkg/siriproxy-0.4.0.gem
# siriproxy (0.4.0) installed

Run bundler to install siriproxy gem dependencies

$ siriproxy bundle
# Fetching gem metadata
# ...
# Bundle is complete!

Generate certificates and copy them to your iOS device

$ siriproxy gencerts
# Creating CA directory
# ...
# Done!

This will create a file called ca.pem, which you need to copy to your device.

There are various ways to do this. I used scp to copy the file to my desktop machine.

From my desktop machine's terminal

$ cd ~/Downloads
$ scp [email protected]:/root/.siriproxy/ca.pem .

From there I e-mailed it to myself and I was able to open the attachment on my iPhone. You could also use Dropbox for this.

When you open the file on your iOS device, you're asked if you want to trust the certificate - go ahead and accept it.

Install and setup DNS server

An easy way to setup DNS on the Raspberry Pi is by installing dnsmasq

$ apt-get install dnsmasq

After installation, setup the DNS server to redirect traffic for guzzoni.apple.com to the IP of your Raspberry Pi.

This is done in the dnsmasq configuration file:

$ sudo vi /etc/dnsmasq.conf

Add the following line after line 62:

address=/guzzoni.apple.com/192.168.0.4

in this case, the IP of my Raspberry Pi is 192.168.0.4

That's it for the DNS server.

Setup your iOS device to use the DNS server

  • On your iOS device, go to the Wi-Fi settings
  • Click the blue arrow next to your current connection
  • For the "DNS" setting, change the current IP to the IP of your Raspberry Pi (in my case 192.168.0.4)

Now all traffic from your iPhone should go through the Raspberry Pi, and the traffic from Siri will be intercepted by siriproxy

Run the siriproxy server

$ cd ~/SiriProxy
$ siriproxy server
# [Info - Server] Starting SiriProxy on 0.0.0.0:443...
# [Info - Server] SiriProxy up and running.

And test the server by using activating Siri and saying "Test siri proxy".

Siri should answer "Siri Proxy is up and running!"