Sending data via cellular voice connections with Linux


“A5/1 [the encryption scheme used in most cellular voice calls] has operated unchanged for the last 21 years but it has now reached its cryptographic end-of-life, engulfed by the march of Moore’s Law. However, the operational end-of-life of A5/1 may still be decades away as there are approximately 2 billion GSM subscribers, commanding about 80% of the global mobile market. This would be a tough product recall indeed. A5/1 is well-positioned to become the NT of the mobile crypto world, and I see the makings of a long tail of GSM vulnerability.” - Dr. Luke O’Connor at NoTricks: Another crack at open Rainbow Tables for A5/1

 

Introduction

The ability to intercept and decrypt GSM cell phone conversations is now well within the reach of hobbyists.12

My friend Scott and I were discussing this sobering fact one night and we began wondering if any systems exist which provide end-to-end encryption for this insecure link.

Sure, there are plenty of solutions for people with access to cellular dataconnections, but what can voice call participants use to foil eavesdroppers?

We didn’t find any low-cost systems so we decided to create our own. OKCrypto is the Linux-based encrypting software modem that we’ve made. It consists of two components: the modem component and crypto component.

The modem / Hardware components

We needed the ability to send data before we could try sending  encrypteddata, so the first step was to design a simple software modem.

Rather than executing the modem code on the cell phones themselves, I decided to host the modem code on a the sender and receiver’s Linux systems. This design provides two benefits:

  1. The modem code and crypto code has access to the rich Linux API.
  2. Sensitive code and data are isolated from the both the cell phone itself and from the cell infrastructure. We have clean separation between trusted (PC) and untrusted (cell) environments.

Thus, the “real work” in OKCrypto is done on the PC – the cell phones simply allow the PCs to talk to each other. See figure 1 for an overview of the hardware involved in the system.

Conceptually, the modem is similar to the analog Plain Old Telephone Service (POTS) modems from the Bad Old Days before broadband service became popular. Instead of an audio coupler, we’re using Bluetooth to connect our PC to our phone line. Instead of custom hardware, our modem is comprised of some glue scripts and the software packages they connect – all running on a Linux PC.

The modem doesn’t provide an asynchronous full-duplex communication link like traditional modems. This modem’s operation is simpler: The sender’s modem dials the number of, and subsequently transmits a pre-prepared chunk of data to, the recipient’s modem. It then hangs up.

The modem uses Dual-tone multi-frequency (DTMF) signaling to encode the data it transmits. I chose DTMF because I was familiar with it and because Debian provides a package for Multimon. OKCrypto uses two utilities that Multimon provides:

  1. gen – a DTMF generation utility (digits->wav file)
  2. multimon – a DTMF detection utility (wav file->digits)

Transmitting audio from a PC to a cell phone / Software components

I’d been working on a few Bluetooth security projects at the time, so the Hands-Free Profile (HFP)3 came immediately to mind as a convenient way to transfer audio (and any data we’ve encoded in the audio) between a PC and a cell phone during a call.

-flickr size=”small” float=”right”-4153181752-/flickr-In most cases HFP is used to connect a a Bluetooth phone to a Bluetooth headset so that the headset can be used to make calls via the phone. See figure 2.

-flickr size=”small” float=”right”-4153181518-/flickr-In the PC world, HFP is typically used to connect a desktop computer to a bluetooth headset. See figure 3. In that configuration, the PC fulfills the first of two roles mandated by the HFP specification: the Audio Gateway (AG) role. The headset fulfills the hands-free (HF) role.

For our purposes, we need the PC to appear to be a bluetooth headset to a cell phone – the PC must fulfill the HF role. See figure 4. This is similar to how call-handling in-vehicle GPS/stereo units work.

Support for the HF role in bluez, the Linux Bluetooth stack (pronounced “blue-zee”), is just now maturing4 so I went searching for a userspace implementation of the HFP protocol stack.

One of the best, chan_mobile, is distributed as an add-on to the popular open-source private branch exchange (PBX) Asterisk system. If you configure chan_mobile to use your cell phone, Asterisk can make both outbound calls and receive inbound calls with the phone.

Asterisk is the largest software component of the OKCrypto modem. It not only provides a reliable HFP HF role implementation which works with a wide array of modern phones (see above), but also many essential telephony operations:

  1. Recording audio during a call. OKCrypto uses Asterisk’s built-in voicemail capabilities.
  2. Transmitting audio during a call.
  3. Pausing for a given time period.
  4. Logging phone call details.

See figure 5 for an overview of the software components in the OKCrypto system. Note that the same software is used on both the sender and receiver’s PCs.

Demonstration / OKCrypto scripts

Let’s look at how we can use this modem to send a 16-byte binary file over a cellular voice connection.

First, the sender and recipient will need to perform some set-up steps:

  1. 1. Acquire a Linux-supported computer and Bluetooth adapter. I found that using a virtual machine introduces latency that bluez/btusb cannot tolerate.
  2. Acquire a HFP-capable cell phone.
  3. Install Linux, SoX, Python, multimon, Asterisk, the Asterisk “add-ons”, GPG, and the OKCrypto scripts.
  4. Pair cell phone with computer. Grant HFP access.
  5. Configure chan_mobile
  6. Start Asterisk Next, the sender can issue this command at a shell to send the file ‘/tmp/foo’ to the recipient at 585-555-3258.
    $ ./bin_to_int_seq.py /tmp/foo | ./ast_send.sh 5855553258 [...]
    $ cksum /tmp/foo 668417501 16 /tmp/foo

    She’ll notice her PC making a call with her phone, silently transmitting the data, and disconnecting. Behind the scenes, the OKCrypto scripts will…

  7. Convert the bytes in /tmp/foo to a series of decimal digits.
  8. Encode the digits as DTMF tones with gen from the multimon package. 1. Increase the pitch (time-independent) to prevent any intermediary systems (esp. Asterisk) from interpreting the tones.
  9. Queue the final audio file for transmission by Asterisk.

The recipient will hear his phone ring once before his PC answers the call, records the audio, and disconnects. When the call is complete, Asterisk will invoke one of the OKCrypto scripts to…

  1. Decrease the pitch to yield the original DTMF tones.
  2. Decode the DTMF tones to a series of decimal digits.
  3. Convert the digits to a series of bytes which is written to ‘/tmp/bar’.
    $ tr -d '\n' < /tmp/newest_vm.txt | ./int_seq_to_bin.py /tmp/bar [...]
    $ cksum /tmp/bar 668417501 16 /tmp/bar

Encryption

Now that we can reliably send data, let’s make sure that it’s encrypted first. This turns out to be one of the simplest components of the system – many good crypto APIs are available.

I use GnuPG:

$ gpg --symmetric --force-mdc --cipher-algo AES256 filetoencrypt 

The `–force-mdc` option provides integrity checking – useful for handling transmission errors. Consider these GPG options carefully and make sure they fit your requirements.

Further work

Here are a few ideas we’re pursuing for the future of this project:

  • Moving the modem code to the cell phone. This would simplify the setup but potentially risk security.
  • Improving modem error rate. Data is often erroneously duplicated during transmission.
  • Increasing the modem throughput. The current code averages a meager 10 bytes/second.
  • Hiding the data within a steganographic channel in a normal voice conversation.
  • Incorporating GPG into the OKCrypto scripts.
  • Packaging the system as a LiveCD/Live flash drive.
  • Implementing key exchange.
  • Building an embedded device dedicated to OKCrypto.

What I learned

I gained experience in the follow areas during the design, implementation. and testing:

  • GSM, CDMA crypto. I suspect the cellular phone industry would make a great case study in protocol security by obscurity.
  • Cellular voice codecs used by large carriers. Trivia: your calls only require ~10kbps.5
  • Bluetooth HFP specification and available implementations.
  • Debugging latency tolerances in virtual machine USB “passthrough” subsystems.
  • The Twilio telephony API. I used Twilio when I only had one cell phone to debug with.
  • Asterisk administration.

Conclusion / Download

I’ve described a method to securely transmit data over any of the widely-available cell voice networks. The implementation requires only commodity hardware, open-source software, and minimal setup.

Be aware that transmitting data by “automated means” may violate the terms of your cellular service contract. I disclaim all liability. This information is provided for educational purposes only.

You can download the OKCrypto system here: http://www.unsyncopated.com/corral/okcrypto_v0.1.tar.gz

It is licensed under the LGPL.

Further reading

Update 1/13/09 - Check out some technical notes on our recent progress with a faster and more reliable modem: OKCrypto/Progress Report for 01-09-2010

  1. Open-Source Effort to Hack GSM John Blau – IEEE Spectrum Magazine – December 2009 issue []
  2. Subverting the security base of GSM Karsten Nohl – Hacking at Random – 8/15/2009 []
  3. Bluetooth Hands-Free Profile (HFP) 1.5 – Bluetooth Special Interest Group – 11/25/2005 []
  4. Comment #1 on Maemo bug #2754 – Johan Hedberg – 1/25/2009 []
  5. Adaptive Multi-Rate audio codec – Wikipedia – 11/24/2009 []

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!