add ios alert box example

This commit is contained in:
iddoeldor 2018-08-17 17:31:16 +03:00 committed by GitHub
parent 094f212b29
commit 0a335b23ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@
- [Await for specific module to load](#await-for-condition)
- [Android make Toast](#android-make-toast)
- [Hook java io InputStream](#hook-java-io-inputstream)
- [iOS alert box](#ios-alert-box)
- [TODO list](#todos)
#### Intercept and backtrace low level open
@ -455,7 +456,21 @@ function hookInputStream() {
Java.perform(hookInputStream);
```
#### iOS alert box
```
var UIAlertController = ObjC.classes.UIAlertController;
var UIAlertAction = ObjC.classes.UIAlertAction;
var UIApplication = ObjC.classes.UIApplication;
var handler = new ObjC.Block({ retType: 'void', argTypes: ['object'], implementation: function () {} });
ObjC.schedule(ObjC.mainQueue, function () {
var alert = UIAlertController.alertControllerWithTitle_message_preferredStyle_('Frida', 'Hello from Frida', 1);
var defaultAction = UIAlertAction.actionWithTitle_style_handler_('OK', 0, handler);
alert.addAction_(defaultAction);
// Instead of using `ObjC.choose()` and looking for UIViewController instances on the heap, we have direct access through UIApplication:
UIApplication.sharedApplication().keyWindow().rootViewController().presentViewController_animated_completion_(alert, true, NULL);
})
```