Skip to content

Commit 7d75d71

Browse files
committed
Set up SRI for Frida binary downloads
1 parent 6c72f31 commit 7d75d71

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/interceptors/frida/frida-android-integration.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
FRIDA_ALTERNATE_PORT,
1515
FRIDA_BINARY_NAME,
1616
FRIDA_DEFAULT_PORT,
17+
FRIDA_SRIS,
1718
FRIDA_VERSION,
1819
FridaHost,
1920
killProcess,
@@ -114,7 +115,8 @@ export async function setupAndroidHost(adbClient: AdbClient, hostId: string) {
114115
const serverStream = await FridaJs.downloadFridaServer({
115116
version: FRIDA_VERSION,
116117
platform: 'android',
117-
arch: deviceArch
118+
arch: deviceArch,
119+
sri: FRIDA_SRIS.android[deviceArch]
118120
});
119121

120122
await deviceClient.push(serverStream, ANDROID_FRIDA_BINARY_PATH, 0o555);

src/interceptors/frida/frida-integration.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ export const FRIDA_VERSION = '16.1.7';
3333
export const FRIDA_DEFAULT_PORT = 27042;
3434
export const FRIDA_ALTERNATE_PORT = 24072; // Reversed to mildly inconvenience detection
3535

36-
export const FRIDA_BINARY_NAME = `adirf-server`; // Reversed to mildly inconvenience detection
36+
export const FRIDA_BINARY_NAME = 'adirf-server'; // Reversed to mildly inconvenience detection
37+
38+
export const FRIDA_SRIS = {
39+
'android': {
40+
'arm': 'sha512-6i85XO372G2p18yttN9jTQEZUeZiY72pPuZPoxiDx+732ROLmDQZ7sIkmbrE8c0nrPc6LQ36OgSBAqVmzlMlsg==',
41+
'arm64': 'sha512-YGPOSYVl+icmn6jB0ZmdCyHk4hIUg+MShr+OLXhb31c2Cifz2nD4ddrp6yQLMoSSpnWsnecUadEj2rR2IGBohQ==',
42+
'x86': 'sha512-OB8bo6RnyBiVPDvheDrBy+CwRblXd/zQT8qGIEEoQlJxSrpRF/hAIZzzYkgTwtCil7lJgWTVFJRegpmntEqpdg==',
43+
'x86_64': 'sha512-Fy4jHMagt2sxAF5FY/ogCAy+s96VDTMwL1UtEazoVyvmohgkr/8tTHx4mQoV5mLInGbxRtpb3F0mPYVzMHtPrg=='
44+
}
45+
} as const;
3746

3847
class FridaScriptError extends CustomError {
3948
constructor(
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { expect } from 'chai';
2+
import * as FridaJs from 'frida-js';
3+
4+
import { FRIDA_SRIS, FRIDA_VERSION } from '../../src/interceptors/frida/frida-integration';
5+
6+
describe("Frida download SRIs", function () {
7+
this.timeout(30000); // Can be slow, since we're doing MB downloads & disk IO
8+
9+
Object.entries(FRIDA_SRIS).forEach(([target, sriMap]) => {
10+
Object.entries(sriMap).forEach(([arch, expectedHash]) => {
11+
it(`should have the correct SRI for ${target}-${arch}`, async () => {
12+
const correctSriHash = await FridaJs.calculateFridaSRI({
13+
ghToken: process.env.GITHUB_TOKEN,
14+
arch: arch as any,
15+
platform: target as any,
16+
version: FRIDA_VERSION
17+
});
18+
19+
expect(expectedHash).to.equal(correctSriHash[0]);
20+
});
21+
});
22+
});
23+
});

0 commit comments

Comments
 (0)