Giter Site home page Giter Site logo

Comments (5)

TheZ3ro avatar TheZ3ro commented on August 22, 2024

can you send a screenshot or describe better how do you connect with a user and password? this is not a common type of authentication in adb.
also if you could intercept USB or TCP communication with Wireshark would greatly help.

from adb_shell.

cmbs2019 avatar cmbs2019 commented on August 22, 2024

Thanks for your reply. This device can connect with password like this.
image
Using user as 'root', and password as 'oelinux123'.

from adb_shell.

TheZ3ro avatar TheZ3ro commented on August 22, 2024

what if you use adb_shell like this?

from adb_shell.adb_device import AdbDeviceUsb
from adb_shell.auth.sign_pythonrsa import PythonRSASigner

# Load the public and private keys
adbkey = 'path/to/adbkey'
with open(adbkey) as f:
    priv = f.read()
with open(adbkey + '.pub') as f:
     pub = f.read()
signer = PythonRSASigner(pub, priv)

# Connect via USB (package must be installed via `pip install adb-shell[usb])`
device = AdbDeviceUsb()
device.connect(rsa_keys=[signer], auth_timeout_s=0.1)

# Send a shell command
login = 'root\noelinux123\n'
response = device.shell(login + 'whoami')

from adb_shell.

cmbs2019 avatar cmbs2019 commented on August 22, 2024

Thank you . I try it, but doesn't work.
Since I don't have adbkey, I use the function below
device = AdbDeviceTcp('127.0.0.1', 5037, default_transport_timeout_s=9.) device.connect(auth_timeout_s=0.1) login = 'root\noelinux123\n' response = device.shell(login + 'whoami')
But cannot connect.
Traceback (most recent call last): File "E:\Project\PyOneDark\main.py", line 5974, in adb_connect device.connect(auth_timeout_s=0.1) File "E:\Project\PyOneDark\venv\lib\site-packages\adb_shell\adb_device.py", line 675, in connect self._available, self._maxdata = self._io_manager.connect(self._banner, rsa_keys, auth_timeout_s, auth_callback, adb_info) File "E:\Project\PyOneDark\venv\lib\site-packages\adb_shell\adb_device.py", line 228, in connect cmd, arg0, maxdata, banner2 = self._read_expected_packet_from_device([constants.AUTH, constants.CNXN], adb_info) File "E:\Project\PyOneDark\venv\lib\site-packages\adb_shell\adb_device.py", line 408, in _read_expected_packet_from_device cmd, arg0, arg1, data = self._read_packet_from_device(adb_info) File "E:\Project\PyOneDark\venv\lib\site-packages\adb_shell\adb_device.py", line 486, in _read_packet_from_device msg = self._read_bytes_from_device(constants.MESSAGE_SIZE, adb_info) File "E:\Project\PyOneDark\venv\lib\site-packages\adb_shell\adb_device.py", line 455, in _read_bytes_from_device raise exceptions.AdbTimeoutError("Timeout: read {} of {} bytes (transport_timeout_s = {}, read_timeout_s = {})".format(len(data), len(data) + length, adb_info.transport_timeout_s, adb_info.read_timeout_s)) adb_shell.exceptions.AdbTimeoutError: Timeout: read 0 of 24 bytes (transport_timeout_s = 9.0, read_timeout_s = 10.0)

from adb_shell.

cmbs2019 avatar cmbs2019 commented on August 22, 2024

I use this method and it works, but some command like 'ls' or 'sqlite3' doesn't support.
` def adb_connect(self):
# 连接设备
self.child = pexpect.popen_spawn.PopenSpawn('adb shell')

    # 匹配提示符,输入用户名和密码
    self.child.expect(['#', ' $', 'mdm9607 login:'], timeout=3)
    self.adb_out.insertPlainText('检测到登录请求...\n')
    self.child.sendline('root')
    self.adb_out.insertPlainText('发送root用户名...\n')
    time.sleep(1)
    self.child.expect(['#', ' $', 'Password:'], timeout=4)
    self.adb_out.insertPlainText('检测到密码请求...\n')
    self.child.send('oelinux123\n')
    self.adb_out.insertPlainText('输入密码...\n')
    self.child.expect(['#', '~'], timeout=3)
    self.adb_out.insertPlainText('登录成功\n')`

from adb_shell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.