httptoolkit / httptoolkit-server

The backend of HTTP Toolkit
https://httptoolkit.com
GNU Affero General Public License v3.0
447 stars 101 forks source link

Fix incorrect command in ADB cert injection script #122

Closed julio-b closed 3 months ago

julio-b commented 3 months ago

Fixes: 59f013f5

CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.

julio-b commented 3 months ago

Injection script was failing with this error:

Android command [ 'su', 'root', 'sh', '/data/local/tmp/htk-inject-system-cert.sh' ] returned `
---
Injecting certificate:
chown: user '700': No such file or directory`
Error: System certificate injection failed
    at e.injectSystemCertificate (/opt/HTTP Toolkit/resources/httptoolkit-server/bundle/index.js:953:29569)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async e.AndroidAdbInterceptor.injectSystemCertIfPossible (/opt/HTTP Toolkit/resources/httptoolkit-server/bundle/index.js:953:34251)
    at async e.AndroidAdbInterceptor.activate (/opt/HTTP Toolkit/resources/httptoolkit-server/bundle/index.js:953:31986)
    at async e.ApiModel.activateInterceptor (/opt/HTTP Toolkit/resources/httptoolkit-server/bundle/index.js:899:756023)
    at async /opt/HTTP Toolkit/resources/httptoolkit-server/bundle/index.js:953:3549
    at async /opt/HTTP Toolkit/resources/httptoolkit-server/bundle/index.js:953:2121
pimterry commented 3 months ago

Obviously this is a bug (good find, thanks!) but interestingly this does work on my Android test device, and even on my local linux machine - it just changes the folder to be owned by uid 700, even if an actual user with that id doesn't exist. Curious!

Out of interest, what device are you using where this fails?

Anyway, thanks for fixing this, I'll put out a release to resolve that for everybody shortly.

Just in case you're not aware, HTTP Toolkit Pro is totally free for contributors. I've just enabled that for the email from your git commit - just click 'Get Pro' then 'Log into existing account' and enter your j.b gmail address to get started.

julio-b commented 3 months ago

Obviously this is a bug (good find, thanks!) but interestingly this does work on my Android test device, and even on my local linux machine - it just changes the folder to be owned by uid 700, even if an actual user with that id doesn't exist. Curious!

Out of interest, what device are you using where this fails?

I was not able to reproduce on my physical devices either, only on emulator. I am using a pretty old image Android 7.1.1 (Nougat), Android TV Intel x86 Atom System Image, API Level 25, Revision 16 which ships with:

$ toybox --version
0.7.0-ee023b2c4ae9-android

My guess is that this chown 700 command triggered an extremely rare bug in toybox that was fixed by this commit https://android.googlesource.com/platform/external/toybox/+/3d64b0cc95c5957e53474c3e50f143c61a057104%5E%21/

Anyway, thanks for fixing this, I'll put out a release to resolve that for everybody shortly.

Just in case you're not aware, HTTP Toolkit Pro is totally free for contributors. I've just enabled that for the email from your git commit - just click 'Get Pro' then 'Log into existing account' and enter your j.b gmail address to get started.

I was not aware of this, thank you very much! HTTPToolkit is one of my favorite debugging tools.