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

Fixes #110, #24, #101: Use httptoolkit/frida-android-unpinning #111

Merged
merged 2 commits into from
Jul 6, 2023

Conversation

baltpeter
Copy link
Member

No description provided.

Copy link
Contributor

@zner0L zner0L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty happy with this and it does work if I run it in the development directory, but if I build it and run the example with the built library, I get the following error:

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: Script(line 698): SyntaxError: unsupported keyword: export]

Node.js v18.14.2

I am guessing this relates to the new module syntax you introduced in the tsconfig.json. I verified my setup works with the current main branch.

src/android.ts Outdated Show resolved Hide resolved
@baltpeter
Copy link
Member Author

The problem is that Parcel builds the unpinning script instead of treating it as a text file. It adds:

export {$ee1b1628d2dcda72$exports as default};

The JS engine Frida uses doesn't understand that, thus the error.

@baltpeter
Copy link
Member Author

Parcel does support inlining files without transforming them. However, for that to work, you need to use readFileSync and __dirname exactly like this:

const unpinningScript = readFileSync(join(__dirname, 'external', 'frida-android-unpinning.js'), 'utf-8');

Using readFile from fs/promises or import.meta instead of __dirname does not work.

However, if we do use __dirname, we can't run the example scripts through tsx anymore. That uses esbuild under the hood which doesn't have support for Parcel's __dirname hack:

/home/benni/coding/JS/tweasel/appstraction/src/android.ts:627
            const unpinningScript = readFileSync(join(__dirname, 'external', 'frida-android-unpinning.js'), 'utf-8');
                                                      ^


ReferenceError: __dirname is not defined
    at Object.startApp (/home/benni/coding/JS/tweasel/appstraction/src/android.ts:627:55)
    at <anonymous> (/home/benni/coding/JS/tweasel/appstraction/examples/android-device.ts:47:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

@baltpeter
Copy link
Member Author

So, we need our own hack. If I rename the file to frida-android-unpinning.js.txt, doesn't recognize it as JavaScript anymore and leaves it alone. shrug

@baltpeter baltpeter requested a review from zner0L July 6, 2023 12:22
Copy link
Contributor

@zner0L zner0L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, now it works!

@zner0L zner0L merged commit e1e0aa5 into main Jul 6, 2023
@zner0L zner0L deleted the b_ht-unpinning-scriüt branch July 6, 2023 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants