Repository navigation
Closed
Labels
Description
I ask Authoritzer to type ttt on USB keyboard gadget, and get these events instead:
evdev-dump events
/dev/input/event21 1659630959.601249 EV_MSC MSC_SCAN 0x000700E0
/dev/input/event21 1659630959.601249 EV_KEY KEY_LEFTCTRL 0x00000001
/dev/input/event21 1659630959.601249 EV_MSC MSC_SCAN 0x000700E1
/dev/input/event21 1659630959.601249 EV_KEY KEY_LEFTSHIFT 0x00000001
/dev/input/event21 1659630959.601249 EV_MSC MSC_SCAN 0x000700E2
/dev/input/event21 1659630959.601249 EV_KEY KEY_LEFTALT 0x00000001
/dev/input/event21 1659630959.601249 EV_MSC MSC_SCAN 0x000700E4
/dev/input/event21 1659630959.601249 EV_KEY KEY_RIGHTCTRL 0x00000001
/dev/input/event21 1659630959.601249 EV_SYN SYN_REPORT 0x00000001
/dev/input/event21 1659630959.602216 EV_MSC MSC_SCAN 0x000700E0
/dev/input/event21 1659630959.602216 EV_KEY KEY_LEFTCTRL 0x00000000
/dev/input/event21 1659630959.602216 EV_MSC MSC_SCAN 0x000700E1
/dev/input/event21 1659630959.602216 EV_KEY KEY_LEFTSHIFT 0x00000000
/dev/input/event21 1659630959.602216 EV_MSC MSC_SCAN 0x000700E2
/dev/input/event21 1659630959.602216 EV_KEY KEY_LEFTALT 0x00000000
/dev/input/event21 1659630959.602216 EV_MSC MSC_SCAN 0x000700E4
/dev/input/event21 1659630959.602216 EV_KEY KEY_RIGHTCTRL 0x00000000
/dev/input/event21 1659630959.602216 EV_SYN SYN_REPORT 0x00000001
/dev/input/event21 1659630959.617249 EV_MSC MSC_SCAN 0x000700E0
/dev/input/event21 1659630959.617249 EV_KEY KEY_LEFTCTRL 0x00000001
/dev/input/event21 1659630959.617249 EV_MSC MSC_SCAN 0x000700E1
/dev/input/event21 1659630959.617249 EV_KEY KEY_LEFTSHIFT 0x00000001
/dev/input/event21 1659630959.617249 EV_MSC MSC_SCAN 0x000700E2
/dev/input/event21 1659630959.617249 EV_KEY KEY_LEFTALT 0x00000001
/dev/input/event21 1659630959.617249 EV_MSC MSC_SCAN 0x000700E4
/dev/input/event21 1659630959.617249 EV_KEY KEY_RIGHTCTRL 0x00000001
/dev/input/event21 1659630959.617249 EV_SYN SYN_REPORT 0x00000001
/dev/input/event21 1659630959.618250 EV_MSC MSC_SCAN 0x000700E0
/dev/input/event21 1659630959.618250 EV_KEY KEY_LEFTCTRL 0x00000000
/dev/input/event21 1659630959.618250 EV_MSC MSC_SCAN 0x000700E1
/dev/input/event21 1659630959.618250 EV_KEY KEY_LEFTSHIFT 0x00000000
/dev/input/event21 1659630959.618250 EV_MSC MSC_SCAN 0x000700E2
/dev/input/event21 1659630959.618250 EV_KEY KEY_LEFTALT 0x00000000
/dev/input/event21 1659630959.618250 EV_MSC MSC_SCAN 0x000700E4
/dev/input/event21 1659630959.618250 EV_KEY KEY_RIGHTCTRL 0x00000000
/dev/input/event21 1659630959.618250 EV_SYN SYN_REPORT 0x00000001
/dev/input/event21 1659630959.633248 EV_MSC MSC_SCAN 0x000700E0
/dev/input/event21 1659630959.633248 EV_KEY KEY_LEFTCTRL 0x00000001
/dev/input/event21 1659630959.633248 EV_MSC MSC_SCAN 0x000700E1
/dev/input/event21 1659630959.633248 EV_KEY KEY_LEFTSHIFT 0x00000001
/dev/input/event21 1659630959.633248 EV_MSC MSC_SCAN 0x000700E2
/dev/input/event21 1659630959.633248 EV_KEY KEY_LEFTALT 0x00000001
/dev/input/event21 1659630959.633248 EV_MSC MSC_SCAN 0x000700E4
/dev/input/event21 1659630959.633248 EV_KEY KEY_RIGHTCTRL 0x00000001
/dev/input/event21 1659630959.633248 EV_SYN SYN_REPORT 0x00000001
/dev/input/event21 1659630959.634251 EV_MSC MSC_SCAN 0x000700E0
/dev/input/event21 1659630959.634251 EV_KEY KEY_LEFTCTRL 0x00000000
/dev/input/event21 1659630959.634251 EV_MSC MSC_SCAN 0x000700E1
/dev/input/event21 1659630959.634251 EV_KEY KEY_LEFTSHIFT 0x00000000
/dev/input/event21 1659630959.634251 EV_MSC MSC_SCAN 0x000700E2
/dev/input/event21 1659630959.634251 EV_KEY KEY_LEFTALT 0x00000000
/dev/input/event21 1659630959.634251 EV_MSC MSC_SCAN 0x000700E4
/dev/input/event21 1659630959.634251 EV_KEY KEY_RIGHTCTRL 0x00000000
/dev/input/event21 1659630959.634251 EV_SYN SYN_REPORT 0x00000001
hid_gadget_test, for example, does type keys correctly, so I assume the problem is with Authorizer itself.
The same version of Authorizer work before on the same device on Android 11, but with Android 12 it seems to be failing.
Activity
vi commentedon Aug 4, 2022
I see the following command line being executed by Authorizer:
Executing it manually also emits the same wrong keyboard events as from the Authorizer.
vi commentedon Aug 4, 2022
Looks like
printfwrites one byte at a time, which gadget drivers does not like.Workaround:
Use `dd` to write to the gadget device.
tejado commentedon Aug 5, 2022
Hi @vi
Thanks a lot for analysing this issue and providing a solution. There was at least one previous issue by users mentioning a similar problem.
I had never any issue with it. Do you know if this issue is part of every printf implementation? If not, I wonder why I did not hit it so far.
Can you provide information about your environment at Android 12, e.g. your shell and version of it? Thanks!
vi commentedon Aug 5, 2022
What do you mean by "shell version"?
/system/bin/shdoes not seem to provide version information.The system is
crosshatch-sp1a.210812.016.c2with Magisk25.1 (25100).tejado commentedon Aug 5, 2022
Great thanks. And on your Android 11, was this also toybox or busybox and which version?
vi commentedon Aug 5, 2022
On another (unrooted) device with Android 11 I see:
I do not see any relevant changes in
printfsubcommand between toybox 0.8.3 and 0.8.4.Note that
printfcan also be a build-in command in shell.Also note that different Linux kernels may react differently to short writes to character devices.
Alexander-Shukaev commentedon Aug 5, 2022
Happy to test as per #38.
vi commentedon Aug 5, 2022
@Alexander-Shukaev , Does it work better with #43?
Does
echo g g | hid_gadget_test /dev/hidg0 keyboardwork reliably for you?Alexander-Shukaev commentedon Aug 5, 2022
I don't know how to test this without release really.
tejado commentedon Aug 5, 2022
I will provide tomorrow a test apk, so we can verify if this is working on several devices.
vi commentedon Aug 7, 2022
Here is the apk I use for myself.
authorizer-debug.zip
Alexander-Shukaev commentedon Aug 7, 2022
How to install it on Android?
vi commentedon Aug 7, 2022
Rename it to
authorizer-debug.apk, thenadb install authorizer-debug.apk(if USB debugging is in use).Or copy it to the device, then open it with a file manager (you may need to accept that file manager as application installation source).
Note that installing apks in this way (including ones downloaded from Github) is a security risk. If you want both root access and security, you should be prepared to configure Android development environment to build things from source code (and review that source at least superficially).
Alexander-Shukaev commentedon Aug 7, 2022
Installing directly on the device, it says "App not installed", so the installation basically fails... Any ideas?
1 remaining item
Alexander-Shukaev commentedon Aug 7, 2022
@vi and @tejado, thanks for the tips and working on this. I can confirm through several test cases, which failed before, that the debug version that @vi provided now types passwords as expected! Incredible 🥂 💯
tejado commentedon Aug 7, 2022
Great, thanks for the feedback @Alexander-Shukaev. It could be, that this issue hit me the first time today as well. So my priority on this increased and will check the fix as well asap.
vi commentedon Aug 23, 2022
Shall I expect an F-Droid build with my patch (or some another fix) someday?
tejado commentedon Aug 25, 2022
Hi vi,
unfortunately, my issue had nothing to do with your fix. I need still some time to prepare my environment, as I preparing the builds on a new (Pixel) device with a different custom rom.
I hope I'm finishing this in the next days. If everything works fine, I will merge it and trigger an f-droid build.
Alexander-Shukaev commentedon Sep 8, 2022
Hi, it's been a while now since I tested the patch. @tejado, do you have some rough ETA for F-Droid please? Thanks!
vi commentedon Sep 8, 2022
Maybe it also worth to change it to avoid creating regular file
/dev/hidg0when character device does not exist along the way?tejado commentedon Sep 12, 2022
Give me a few more days. Latest end of next week. Having a summer break right now but I try my best to merge and schedule f-droid build asap.
Sure - there are even more things to fix/implement. At first I need to update my own devices as mentioned above, as these are currently based on the Kernel patch which has not such issues. When I'm done with that, I will implement more fixes, e.g. adding gadgets at boot time, ...
Use `dd` to write to the gadget device. (#43)
tejado commentedon Sep 18, 2022
Change was merged and additionally bugs were resolved to create a new release with minimum efforts. F-Droid build process should pick it up in their next update phase (few days).
@vi
I will now start the work on v0.5.0 which will be using latest SDKs, e.g. to get it ready for Play Store. This will then also include better compatibility with android-usb-gadget, e.g. fixing #36.
vi commentedon Sep 18, 2022
Offtopic here, but does it make sense to bundle some of USB Gadget Tool functions (i.e. adding keyboard gadget if it does not exist) into Authorizer itself?
tejado commentedon Sep 18, 2022
Maybe at a later point. Currently, the USB Gadget Tool is very unstable on some devices. E.g. it is required to add a new gadget instead of just adding the HID function to the existing gadget. Doing this automatically, can cause other USB functions to fail so that a reboot will be required (e.g. to get adb working again). But I will have to check how the overall experience with Authorizer and USB Gadget Tool can look like as soon as I use it together on a daily basis.
tejado commentedon Sep 25, 2022
The new version is now available in the F-Droid store: https://f-droid.org/en/packages/net.tjado.passwdsafe/