O'Reilly logo

Hacking and Securing iOS Applications by Jonathan Zdziarski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Abusing the Runtime with Cycript

A great asset to someone attacking an iOS-based application is Cycript. According to the website, http://www.cycript.org, Cycript is “a programming language designed to blend the barrier between Objective-C and JavaScript.” Cycript was written by Jay Freeman, the author of many other third-party tools for iOS, including the Cydia software installer, Cydgets, Cycorder, and a Java port to iOS. The Cycript tool is fully JavaScript compatible, allowing you to write programs using the full JavaScript syntax, but also lets you directly blend in components of the Objective-C language. Cycript is, in short, a hacker’s implementation of all the runtime manipulation techniques covered so far.

Installing Cycript

To install Cycript, first install the mobilesubstrate and adv-cmds packages using Cydia. You’ll be prompted to reboot. Once the device has come back up, log into it using SSH. Download the latest Cycript package from http://www.cycript.org/debs/. Copy the package to your device and install it using dpkg:

$ dpkg -i cycript_0.9.450-1_iphoneos-arm.deb

Once the package is installed, you should now have cycript available in your path. For the examples in this chapter, run with root privileges.

# cycript
cy#

To exit the interpreter, press Control-D.

Using Cycript

Cycript allows JavaScript-esque variable definitions that connect with Cocoa classes. The following example creates an NSString object using Objective-C and assigns it to a variable using JavaScript:

cy# ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required