Book Image

Mobile Device Exploitation Cookbook

By : Akshay Dixit
Book Image

Mobile Device Exploitation Cookbook

By: Akshay Dixit

Overview of this book

Mobile attacks are on the rise. We are adapting ourselves to new and improved smartphones, gadgets, and their accessories, and with this network of smart things, come bigger risks. Threat exposure increases and the possibility of data losses increase. Exploitations of mobile devices are significant sources of such attacks. Mobile devices come with different platforms, such as Android and iOS. Each platform has its own feature-set, programming language, and a different set of tools. This means that each platform has different exploitation tricks, different malware, and requires a unique approach in regards to forensics or penetration testing. Device exploitation is a broad subject which is widely discussed, equally explored by both Whitehats and Blackhats. This cookbook recipes take you through a wide variety of exploitation techniques across popular mobile platforms. The journey starts with an introduction to basic exploits on mobile platforms and reverse engineering for Android and iOS platforms. Setup and use Android and iOS SDKs and the Pentesting environment. Understand more about basic malware attacks and learn how the malware are coded. Further, perform security testing of Android and iOS applications and audit mobile applications via static and dynamic analysis. Moving further, you'll get introduced to mobile device forensics. Attack mobile application traffic and overcome SSL, before moving on to penetration testing and exploitation. The book concludes with the basics of platforms and exploit tricks on BlackBerry and Windows Phone. By the end of the book, you will be able to use variety of exploitation techniques across popular mobile platforms with stress on Android and iOS.
Table of Contents (11 chapters)
Mobile Device Exploitation Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface

Creating a simple iOS app and running it in the simulator


Having introduced you to Xcode and the simulator, now we will create our first iOS application.

Getting ready

To get ready to code the iOS application, you need Xcode and iOS Simulator in your MacBook and working. If you have followed the previous recipe, and know a little bit of Objective-C, you are all set to code your very first iOS application.

How to do it...

Now that we have a basic idea of Xcode, let's start by building the user interface:

  1. In the project navigator, select Main.storyboard. Xcode then brings up a visual editor for storyboards, called interface builder.

    A storyboard is used to lay out views and transition between different views. As we use a single-view application, the storyboard already includes a View Controller.

  2. Next, we will add a button to the view. The bottom part of the utility area shows the Object Library, as shown in the following screenshot:

  3. Drag the Button object from the Object Library to the view:

  4. Stop dragging and move the button to the area of your choice. Double-click on the button and rename it Click Me.

  5. Next we will add a few lines of code to display our message. In the project navigator, you should find the ViewController.swift file. We will be adding a method to the already present ViewController class. When this method is called, our code will tell iOS to display a certain message.

  6. Now let's code our method. This is what our method looks like:

    @IBAction func showMessage(){ 
    let alertController = UIAlertController(title: "My First App", message: "Hello World", preferredStyle: UIAlertControllerStyle.Alert) 
    alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:nil)) 
    self.presentViewController(alertController, animated: true, completion: nil) 
    } 
    
  7. This is what the finished work will look like:

  8. Now we need to connect our Click Me button in the storyboard to our showMessage method. This part is easy; we click on Main.storyboard, where we have displayed our screen.

  9. Press and hold the Ctrl key on your keyboard, click the Click Me button, and drag it to the View Controller icon.

  10. Release both buttons, and we see a pop-up message with the showMessage option. Select it to make a connection between the button and our function:

  11. That's it! If everything is correct, we can now run our app perfectly when we click on the run button:

How it works...

The @IBAction attribute, introduced in Swift, is used to connect storyboard actions to the code. Here, we wanted to connect the click of a button to a message being displayed. So, we defined the function showMessage as func.

Note

Starting from iOS 8, UIActionSheet and UIAlertView were replaced by the new UIAlertController.

In our function, we call UIAlertController and ask it to display an alert popup, with the title My First App and the message Hello World. We also add an action:

alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:nil)) 

This essentially means we add an option to close the popup when OK is clicked on.

When we dragged our button to the ViewController and selected our showMessage function, we essentially linked the clicking of the button to the calling of our function.

There's more...

You can experiment by trying different styles of button, or using table views, links, and so on. Add more functionality to experiment in ways of learning iOS app development.

A good starting place would be the documentation from the creators of iOS:

See also