You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
Hi guys, I've been trying to figure out how to generate the ADB keys within this python module, so we can run a 100% Python implementation of ADB, without ever requiring to run the server to first generate the keys. There is an ongoing discussion here regarding this issue.
So I wrote a simple code with the supported RSA librairies:
from adb.usb_exceptions import DeviceAuthError
from adb import adb_commands
from adb.sign_pythonrsa import PythonRSASigner
from adb.adb_protocol import InvalidChecksumError
import os.path as op
from Crypto.PublicKey import RSA
from adb import sign_pycryptodome
Signer = PythonRSASigner.FromRSAKeyPath
uri='192.168.1.86:5555'
byte_uri = str.encode(uri)
adbkey=op.expanduser('~/.android/adbkey')
if op.isfile(adbkey):
print('Key found, trying with auth')
signer = Signer(adbkey)
adb = adb_commands.AdbCommands().ConnectDevice(serial=byte_uri, rsa_keys=[signer])
else:
print('Adbkey {} not found, trying without auth'.format(adbkey))
key = RSA.generate(2048)
private_key = key.export_key(pkcs=8)
public_key = key.publickey().export_key(format='DER')
with open(adbkey, 'wb') as priv:
priv.write(private_key)
with open(adbkey+'.pub', 'wb') as pub:
pub.write(public_key)
try:
adb = adb_commands.AdbCommands().ConnectDevice(serial=byte_uri)
except DeviceAuthError:
print('Auth key required for device {}'.format(uri))
But the problem is that the original code generates a custom public key, which is "naked" as in no formating is present and there is also the user and hostname of the device.
The code generating the keys is here, although I'm not familiar enough with C to understand and port the function.
To me it seems to be as simple as porting this function, any thoughts ? Could somebody do it ?
Thanks! 🙂
The text was updated successfully, but these errors were encountered:
Hi guys, I've been trying to figure out how to generate the ADB keys within this python module, so we can run a 100% Python implementation of ADB, without ever requiring to run the server to first generate the keys. There is an ongoing discussion here regarding this issue.
So I wrote a simple code with the supported RSA librairies:
But the problem is that the original code generates a custom public key, which is "naked" as in no formating is present and there is also the user and hostname of the device.
The code generating the keys is here, although I'm not familiar enough with C to understand and port the function.
To me it seems to be as simple as porting this function, any thoughts ? Could somebody do it ?
Thanks! 🙂
The text was updated successfully, but these errors were encountered: