That particular feature already exists in Kali Nethunter and what it actually does is through one Android device, to access another device.
We are given the opportunity to do so much bypass the lock screen, as well as taking full control of a device and for future use.
How to avoid such an attack
- We always charge it mobile us with our own charger
- We always use a complex screen lock code or a complex pattern
- We use programs protection on our device and more specifically programs that detect and prevent exploits.
PoC
What we need
- A rooted Android device with support for HID attacks in Kernel settings (eg NetHunter ROM)
- OTG cable
The script may not work every time. Therefore, we have to play with the keys we send to our target and change it exploit if it doesn't work the first time. A list of all possible keys can be found at the link below.
HID support in custom ROM
https://github.com/pelya/android-keyboard-gadget
Brute-force attack using our Android
https://github.com/urbanadventurer/Android-PIN-Bruteforce
List of all available keys
https://github.com/anbud/DroidDucky/blob/master/droidducky.sh