您的位置:首页 > 编程语言 > Python开发

Python+adb之使用电脑解开手机密码锁

2018-01-12 15:24 916 查看
上波图,手机休眠状态是这样的



打破休眠状态时的状态是这样的:



输入密码的界面是这样的:



基本上这就是我们平时解开手机密码锁的过程了(感谢我哥们凯子的手机赞助!)

下面我们运用Python语言加上adb驱动,用程序控制手机自己解锁,废话不多说上代码:

#   _*_ coding:utf-8 _*_

import os
from PIL import Image
import subprocess
import time

__author__ = 'admin'

def mobile_in(code):
#   开启电源键
os.popen('adb shell input keyevent 26')
time.sleep(1)
#   滑动屏幕进入输入密码界面
os.popen('adb shell input swipe 539 1868 539 1600')
time.sleep(1)
for i in range(len(code)):
if code[i] == '0':
#   密码盘上的“0”
os.popen('adb shell input swipe 480 1440 600 1550')
time.sleep(1)
elif code[i] == '1':
#   密码盘上的“1”
os.popen('adb shell input swipe 200 740 320 860')
time.sleep(1)
elif code[i] == '2':
#   密码盘上的“2”
os.popen('adb shell input swipe 480 740 600 860')
elif code[i] == '3':
#   密码盘上的“3”
os.popen('adb shell input swipe 760 740 880 860')
elif code[i] == '4':
#   密码盘上的“4”
os.popen('adb shell input swipe 200 990 320 1110')
elif code[i] == '5':
#   密码盘上的“5”
os.popen('adb shell input swipe 480 990 600 1110')
elif code[i] == '6':
#   密码盘上的“6”
os.popen('adb shell input swipe 760 990 880 1110')
elif code[i] == '7':
#   密码盘上的“7”
os.popen('adb shell input swipe 200 1240 320 1360')
elif code[i] == '8':
#   密码盘上的“8”
os.popen('adb shell input swipe 480 1240 600 1360')
elif code[i] == '9':
#   密码盘上的“9”
os.popen('adb shell input swipe 760 1240 880 1360')
time.sleep(1)

code = list('1357')
mobile_in(code)

运行后,手机会自己打破休眠,进入密码输入界面,并输入你指定的密码
(期间我想过可不可以用这种方式暴力破解手机锁密码呢?然而不行,输错3次后,手机就不允许再输入密码了!!)

os.popen('adb shell input swipe 60 1630 60 163 1000')

此代码可以实现长按手机屏幕上的某个按钮(不是点击的意思!),因为后面多了一个参数是点击时长。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python adb