008、adb命令 (service call iphonesubinfo 15),获取手机号码

发布时间 2023-07-31 19:28:25作者: 空-山-新-雨

获取手机号码命令,  adb shell service call iphonesubinfo 15  如下:

不同android版本 15的数字不一样,可是是 13 或 17 等
C:\Users\SZ-M1-BD-0080>adb shell service call iphonesubinfo 15
Result: Parcel(
  0x00000000: 00000000 0000000e 0038002b 00310036 '........+.8.6.1.'
  0x00000010: 00320033 00390034 00330038 00380039 '3.2.4.9.8.3.9.8.'
  0x00000020: 00350036 00000000                   '6.5.....        ')

C:\Users\SZ-M1-BD-0080>

 

用python提取号码,如下:

import uiautomator2 as ui2

phone_device = ui2.connect('1579745798000GS')

# 获取手机号码
service_call_iphonesubinfo_15_txt = phone_device.shell('service call iphonesubinfo 15').output      # 不同android版本 15的数字不一样。
tem = service_call_iphonesubinfo_15_txt.split('\n')

phone_num_2 = tem[2].split(' ')[-1]
phone_num_3 = tem[3].split("'")[1]

phone_num_str_temp = '1' + phone_num_2.replace("'", '') + phone_num_3
phone_num_str_ = phone_num_str_temp.replace('.', '')

print(phone_num_str_)