tweaselORG / appstraction

An abstraction layer for common instrumentation functions (e.g. installing and starting apps, setting preferences, etc.) on Android and iOS.
MIT License
4 stars 1 forks source link

Failed to disable WireGuard tunnel on Android #103

Open baltpeter opened 1 year ago

baltpeter commented 1 year ago

Another bug that came up during the https://github.com/tweaselORG/meta/issues/16 run:

Failed to analyze app /media/benni/storage2/tmp/tweasel/cert-pinning-experiment/de.zollsoft.arzt_direkt_app-96.apk: Error: Failed to disable WireGuard tunnel.
    at Object.setProxy (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/node_modules/appstraction/dist/index.js:1002:47)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at <anonymous> (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/node_modules/cyanoacrylate/dist/index.js:256:17)
    at async Promise.all (index 0)
    at stopTrafficCollection (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/node_modules/cyanoacrylate/dist/index.js:246:23)
    at Object.stopTrafficCollection (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/node_modules/cyanoacrylate/dist/index.js:382:33)
    at <anonymous> (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/run.ts:82:17)

From then on, every other app unsurprisingly failed with:

Failed to analyze app /media/benni/storage2/tmp/tweasel/cert-pinning-experiment/de.zooplus-161421209.apk: Error: Cannot start new traffic collection. A previous one is still running.
    at startTrafficCollection (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/node_modules/cyanoacrylate/dist/index.js:186:48)
    at Object.startTrafficCollection (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/node_modules/cyanoacrylate/dist/index.js:372:28)
    at <anonymous> (/home/benni/coding/JS/tweasel/experiments/cert-pinning-bypass/run.ts:58:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
baltpeter commented 1 year ago

On the device, the tunnel is in fact still enabled.

Running adb shell am broadcast -a com.wireguard.android.action.SET_TUNNEL_DOWN -n 'com.wireguard.android/.model.TunnelManager$IntentReceiver' -e tunnel appstraction manually doesn't help.

Even starting the WireGuard app and running the command didn't help.

And neither did force-stopping the app.

baltpeter commented 1 year ago

After manually disabling the tunnel in the app and re-enabling it, I still cannot control it via intents.

baltpeter commented 1 year ago

Curiously, just rerunning the analysis script did work. I don't think ensureDevice() should have changed anything, so maybe the solution was to re-enable the tunnel via an intent, even though it was already enabled?