-
Notifications
You must be signed in to change notification settings - Fork 1
/
ios-device.ts
79 lines (63 loc) · 2.77 KB
/
ios-device.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
/* eslint-disable no-console */
import { parseAppMeta, pause, platformApi } from '../src/index';
// You can pass the following command line arguments:
// `npx tsx examples/ios-device.ts <app path> <CA cert path?> <proxy host?> <proxy port?>`
(async () => {
const ios = platformApi({
platform: 'ios',
runTarget: 'device',
capabilities: ['frida', 'ssh', 'certificate-pinning-bypass'],
});
const appPath = process.argv[2] || '/path/to/app-files';
const caCertPath = process.argv[3];
const proxyHost = process.argv[4];
const proxyPort = process.argv[5];
await ios.ensureDevice();
const osVersion = await ios.getDeviceAttribute('osVersion');
console.log('OS version:', osVersion);
const installedApps = await ios.listApps();
console.log('Installed apps:', installedApps);
if (caCertPath) {
await ios.installCertificateAuthority(caCertPath);
console.log(
'Installed CA. Note that it will currently not be automatically trusted unless you have manually trusted any user CA at least once before.'
);
}
if (proxyHost && proxyPort) await ios.setProxy({ host: proxyHost, port: +proxyPort });
await ios.setClipboard('I copied this.');
await ios.addCalendarEvent({
title: 'Secret meeting',
startDate: new Date('2024-01-01T12:00:00'),
endDate: new Date('2024-01-01T12:12:00'),
});
await ios.addContact({
lastName: 'Doe',
firstName: 'Kim',
email: '[email protected]',
phoneNumber: '0123456789',
});
await ios.setDeviceName('honeypotdontcopy');
const appMeta = await parseAppMeta(appPath as `${string}.ipa`);
if (!appMeta) throw new Error('Invalid app.');
const appId = appMeta.id;
console.log('App:', appId, '@', appMeta.version);
console.log('Installed already?', await ios.isAppInstalled(appId));
await ios.installApp(appPath as `${string}.ipa`);
// First, grant all permissions.
await ios.setAppPermissions(appId);
// Then, revoke the camera permission and unset the calendar permission.
await ios.setAppPermissions(appId, { kTCCServiceCamera: 'deny', kTCCServiceCalendar: 'unset' });
await ios.startApp(appId);
// Give the app some time to start.
await pause(5000);
const prefs = await ios.getPrefs(appId);
console.log(prefs);
const idfv = await ios.getDeviceAttribute('idfv', { appId });
console.log('IDFV:', idfv);
// `clearStuckModals()` is currently broken on iOS (see https://github.com/tweaselORG/appstraction/issues/12).
// await ios.clearStuckModals();
await ios.uninstallApp(appId);
if (proxyHost && proxyPort) await ios.setProxy(null);
if (caCertPath) await ios.removeCertificateAuthority(caCertPath);
})();
/* eslint-enable no-console */