Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Windows #61

Merged
merged 7 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Additionally, you will need to [prepare the target device/emulator](#device-prep

### Host dependencies for Android

For Android, you need the [Android command line tools](https://developer.android.com/studio/command-line/) (can also be installed through [Android Studio](https://developer.android.com/studio)). Note that these need to be included in your `PATH`, e.g. by including something like this in your `.zshrc`/`.bashrc`:
For Android, you need the [Android SDK platform tools](https://developer.android.com/tools/releases/platform-tools) and [Android build tools](https://developer.android.com/tools/releases/build-tools) (can also be installed through [Android Studio](https://developer.android.com/studio)). Note that these need to be included in your `PATH`, e.g. by including something like this in your `.zshrc`/`.bashrc`:

```sh
# Android SDK
Expand All @@ -56,12 +56,10 @@ For the `certificate-pinning-bypass` capability, you need to install [`objection

### Host dependencies for iOS

For iOS, you need [`libimobiledevice`](https://libimobiledevice.org/) and `ideviceinstaller`. The distribution packages are fine, if available.
For iOS, you need [`libimobiledevice`](https://libimobiledevice.org/) and `ideviceinstaller`. The distribution packages are fine, if available. On Windows, you will additionally need the Apple Device Driver and the Apple Application Support service. You can get those by installing iTunes.

For the `frida` capability, you need to install [`frida-tools`](https://frida.re/docs/installation/).

For the `ssh` capability, you need to install [`sshpass`](https://sourceforge.net/projects/sshpass).

## Supported targets

Appstraction supports the following targets. Note that it will likely also work on other versions of the targets, but these are the ones we have tested.
Expand Down
30 changes: 15 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ An ID of a known permission on Android.

#### Defined in

[android.ts:769](https://github.com/tweaselORG/appstraction/blob/main/src/android.ts#L769)
[android.ts:768](https://github.com/tweaselORG/appstraction/blob/main/src/android.ts#L768)

___

Expand All @@ -58,7 +58,7 @@ A supported attribute for the `getDeviceAttribute()` function, depending on the

#### Defined in

[index.ts:329](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L329)
[index.ts:332](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L332)

___

Expand All @@ -77,7 +77,7 @@ The options for each attribute available through the `getDeviceAttribute()` func

#### Defined in

[index.ts:335](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L335)
[index.ts:338](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L338)

___

Expand All @@ -89,7 +89,7 @@ An ID of a known permission on iOS.

#### Defined in

[ios.ts:398](https://github.com/tweaselORG/appstraction/blob/main/src/ios.ts#L398)
[ios.ts:382](https://github.com/tweaselORG/appstraction/blob/main/src/ios.ts#L382)

___

Expand Down Expand Up @@ -133,7 +133,7 @@ Functions that are available for the platforms.

#### Defined in

[index.ts:18](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L18)
[index.ts:19](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L19)

___

Expand All @@ -153,7 +153,7 @@ The options for the `platformApi()` function.

#### Defined in

[index.ts:267](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L267)
[index.ts:270](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L270)

___

Expand All @@ -172,7 +172,7 @@ Connection details for a proxy.

#### Defined in

[index.ts:343](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L343)
[index.ts:346](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L346)

___

Expand Down Expand Up @@ -202,7 +202,7 @@ The options for a specific platform/run target combination.

#### Defined in

[index.ts:294](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L294)
[index.ts:297](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L297)

___

Expand All @@ -220,7 +220,7 @@ A capability for the `platformApi()` function.

#### Defined in

[index.ts:322](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L322)
[index.ts:325](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L325)

___

Expand All @@ -232,7 +232,7 @@ A platform that is supported by this library.

#### Defined in

[index.ts:9](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L9)
[index.ts:10](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L10)

___

Expand All @@ -250,7 +250,7 @@ A run target that is supported by this library for the given platform.

#### Defined in

[index.ts:11](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L11)
[index.ts:12](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L12)

___

Expand All @@ -262,7 +262,7 @@ Configuration string for WireGuard.

#### Defined in

[index.ts:350](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L350)
[index.ts:353](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L353)

## Variables

Expand All @@ -274,7 +274,7 @@ The IDs of known permissions on Android.

#### Defined in

[android.ts:638](https://github.com/tweaselORG/appstraction/blob/main/src/android.ts#L638)
[android.ts:637](https://github.com/tweaselORG/appstraction/blob/main/src/android.ts#L637)

___

Expand All @@ -286,7 +286,7 @@ The IDs of known permissions on iOS.

#### Defined in

[ios.ts:381](https://github.com/tweaselORG/appstraction/blob/main/src/ios.ts#L381)
[ios.ts:365](https://github.com/tweaselORG/appstraction/blob/main/src/ios.ts#L365)

## Functions

Expand Down Expand Up @@ -373,4 +373,4 @@ The API object for the given platform and run target.

#### Defined in

[index.ts:359](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L359)
[index.ts:362](https://github.com/tweaselORG/appstraction/blob/main/src/index.ts#L362)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"frida": "^16.0.8",
"fs-extra": "^11.1.0",
"ipa-extract-info": "^1.2.6",
"node-ssh": "^13.1.0",
"p-retry": "^5.1.2",
"pkijs": "^3.0.14",
"semver": "^7.3.8",
Expand Down
17 changes: 8 additions & 9 deletions src/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,16 @@ export const androidApi = <RunTarget extends SupportedRunTarget<'android'>>(
}

// Start `frida-server` if it's not already running.
const fridaCheck = await execa(`frida-ps -U | grep frida-server`, {
shell: true,
reject: false,
});
if (fridaCheck.exitCode === 0) return;
const { stdout: fridaCheck } = await execa('frida-ps', ['-U'], { reject: false });
if (fridaCheck.includes('frida-server')) return;

await this.requireRoot('Frida');

await execa('adb', ['shell', 'chmod', '755', '/data/local/tmp/frida-server']);
await execa('adb', ['shell', '-x', '/data/local/tmp/frida-server', '--daemonize']);

const fridaIsStarted = await retryCondition(
async () =>
(await execa(`frida-ps -U | grep frida-server`, { shell: true, reject: false })).exitCode === 0,
async () => (await execa('frida-ps', ['-U'], { reject: false })).stdout.includes('frida-server'),
100
);
if (!fridaIsStarted) throw new Error('Failed to start Frida.');
Expand All @@ -168,7 +164,9 @@ export const androidApi = <RunTarget extends SupportedRunTarget<'android'>>(

getCertificateSubjectHashOld: (path: string) =>
execa('openssl', ['x509', '-inform', 'PEM', '-subject_hash_old', '-in', path]).then(
({ stdout }) => stdout.split('\n')[0]
// The `trim()` is necessary for Windows:
// https://github.com/tweaselORG/meta/issues/25#issuecomment-1507665763
({ stdout }) => stdout.split('\n')[0]?.trim()
),
hasCertificateAuthority: (filename) =>
execa('adb', ['shell', 'ls', `/system/etc/security/cacerts/${filename}`], { reject: false }).then(
Expand Down Expand Up @@ -392,7 +390,8 @@ export const androidApi = <RunTarget extends SupportedRunTarget<'android'>>(
if (
err.exitCode === 255 &&
(err.stderr.includes('not a changeable permission type') ||
err.stderr.includes('has not requested permission'))
err.stderr.includes('has not requested permission') ||
err.stderr.includes('Unknown permission'))
)
return;

Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ExecaChildProcess } from 'execa';
import type { NodeSSH } from 'node-ssh';
import type { LiteralUnion } from 'type-fest';
import type { AndroidPermission } from './android';
import { androidApi } from './android';
Expand Down Expand Up @@ -259,7 +260,9 @@ export type PlatformApi<
objectionProcesses: ExecaChildProcess[];
}
: Platform extends 'ios'
? undefined
? {
ssh: NodeSSH['execCommand'];
}
: never;
};

Expand Down
Loading