Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

进到adb shell后要输账号密码,怎么实现 #40

Open
xyd113 opened this issue Apr 22, 2021 · 4 comments
Open

进到adb shell后要输账号密码,怎么实现 #40

xyd113 opened this issue Apr 22, 2021 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@xyd113
Copy link

xyd113 commented Apr 22, 2021

No description provided.

@wjt9
Copy link

wjt9 commented Jun 11, 2021

怎么没人回答这个问题,我也遇到同样的问题,不知道怎么解

@xyd113
Copy link
Author

xyd113 commented Jul 7, 2021

怎么没人回答这个问题,我也遇到同样的问题,不知道怎么解

我用pexpect实现了adb shell里面输账号密码
(以下代码我有加工过,你需要再调一下)
shell = pexpect.spawn(f"adb shell")
shell.expect('login:', 5)
shell.sendline("your username")
shell.expect('Password:', 5)
shell.sendline("your password")

@Yann-Song
Copy link

Yann-Song commented Jul 22, 2021

修改__init.py__
在 class _AdbStreamConnection(object): 中增加一个发数据方法,如下:
def send_onlydata(self, data: str):
self.conn.send("{}".format(data).encode("utf-8"))
在class AdbClient(object): 中增加一个登录方法,

   def login_adb(self,serial : str,username : str,password : str):
            msg = ''
            c = self._connect()
            c.send_command("host:transport:" + serial)
            c.check_okay()
            c.send_command("shell:")
            c.check_okay()
            while True:
                ch = c.read_string(1)
                msg = msg + ch
                if msg.find('ogin:') > 0:
                    c.send_onlydata(username)
                    msg = ''
                    continue
                elif msg.find('assword:') > 0:
                    c.send_onlydata(password)
                    msg = ''
                    continue
                elif msg.find('ncorrect') > 0:
                    print("error password / user account ")
                    self.__login = False
                    break
                elif msg.find('#') > 0:
                    self.__login = True
                    break
            return c

我的实现如上,python 不是熟悉,能看懂就行了

@codeskyblue
Copy link
Member

什么手机啊,怎么还有用户名密码啊

@codeskyblue codeskyblue added enhancement New feature or request good first issue Good for newcomers labels May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants