想过重新编译环境变量,对于某些Android4.0版本并不适用,运行不起来,利用adb修改 build.prop文件达到修改机型的目的效果也不错。
-
Root
首先需要手机root,群控的手机貌似都root,没root的自行root。 -
修改build.prop
Python脚本
# -*- coding: utf-8 -*-
import os
import sys
import json
import random
import subprocess
reload(sys)
sys.setdefaultencoding("utf-8")
def genDescription(line,release,name):
value = line.split("=")[1]
list_value = value.split(" ")
list_value[0] = name.replace(' ','') + "-user"
list_value[1] = release
description = ' '.join(list_value)
return description
def genFingerprint(line,release,model,brand,name):
value = line.split("=")[1]
list_value = value.split("/")
list_value[0] = brand
list_value[1] = name.replace(' ','')
list_value[2] = name.replace(' ','') + ":" + release
fingerprint = '/'.join(list_value)
return fingerprint
def modify(release,model,brand,name,manufacturer):
for line in open("./o/build.prop"):
rline = line
if "ro.build.version.release=" in line:
rline = "ro.build.version.release=" + str(release) + "\n"
elif "ro.product.model=" in line:
rline = "ro.product.model=" + str(model) + "\n"
elif "ro.product.brand=" in line:
rline = "ro.product.brand=" + str(brand) + "\n"
elif "ro.product.name=" in line:
rline = "ro.product.name=" + str(name) + "\n"
elif "ro.product.manufacturer=" in line:
rline = "ro.product.manufacturer=" + str(manufacturer) + "\n"
elif "ro.build.description=" in line:
rline = "ro.build.description=" + str(genDescription(line,release,name)) + "\n"
elif "ro.build.fingerprint=" in line:
rline = "ro.build.fingerprint=" + str(genFingerprint(line,release,model,brand,name)) + "\n"
with open("./n/build.prop", "a") as f:
f.write(rline)
def main_modify():
json_data = json.load(open("phone.json"))
array_phone = json_data['phone']
pid = random.randint(0,len(array_phone))
item_phone = array_phone[pid]
name = item_phone['name']
manufacturer = item_phone['manufacturer']
model = item_phone['model']
array_release = json_data['release']
rid = random.randint(0,len(array_release))
release = array_release[rid]
brand = manufacturer
if os.path.exists("./n/build.prop"):
os.remove("./n/build.prop")
modify(release,model,brand,name,manufacturer)
if __name__ == "__main__":
if len(sys.argv)==1:
print u"请输入参数"
phone = sys.argv[1]
print "开始连接设备"
os.system("adb connect {}".format(phone))
print "开始导出build.prop"
os.system("adb -s {} pull system/build.prop ./o".format(phone))
print "开始root"
os.system("adb root")
print "开始remote"
os.system("adb remount")
main_modify()
os.system("adb -s {} push ./n/build.prop system".format(phone))
cmds = [
"chmod 0644 system/build.prop",
"exit"
]
pipe = subprocess.Popen("adb -s {} shell".format(phone), shell= True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
code = pipe.communicate(("\n".join(cmds) + "\n").encode('utf-8'));
for item in code:
if item:
print(item.decode('gbk'))
在终端中执行 python
androidbuild.py
[参数:设备id,或者adb airless ip:5555]
一些机型配置文件
phone.json
{
"release": [
"7.0",
"7.0.1",
"7.1",
"8.0",
"5.1",
"4.4.4",
"6.0.1",
"5.1.1",
"6.0",
"4.4.2",
"5.0.2",
"4.3",
"5.0",
"4.2.2",
"4.4",
"4.1.2",
"5.0.1",
"4.2.1",
"4.1.1",
"4.4.3",
"4.0.4",
"4.0.3",
"4.2",
"4.1",
"5.1.0",
"4.4.5",
"4.0",
"4.3.1",
"4.4.0",
"5.0.5",
"5.3 ",
"6.0.2",
"6.1",
"4.3.0",
"4.2.3",
"4.2.9",
"4.4.1"
],
"phone": [
{
"name": "荣耀7i",
"manufacturer": "HUAWEI",
"model": "ATH-AL00"
},
{
"name": "荣耀6至尊版",
"manufacturer": "HUAWEI",
"model": "H60-L21"
},
{
"name": "荣耀6 Plus",
"manufacturer": "HUAWEI",
"model": "PE-TL10"
},
{
"name": "P10",
"manufacturer": "HUAWEI",
"model": "VTR-AL00"
},
{
"name": "P10 Plus",
"manufacturer": "HUAWEI",
"model": "VKY-AL00"
},
{
"name": "联想K3",
"manufacturer": "Lenovo",
"model": "Lenovo K30-T"
},
{
"name": "乐视2",
"manufacturer": "LeMobile",
"model": "Le X620"
},
{
"name": "乐视2 Pro",
"manufacturer": "LeMobile",
"model": "Le X525"
},
{
"name": "乐视1",
"manufacturer": "Letv",
"model": "X600"
},
{
"name": "乐视1 Pro",
"manufacturer": "Letv",
"model": "X800+"
},
{
"name": "乐视1 S",
"manufacturer": "Letv",
"model": "Letv X500"
},
{
"name": "乐视1 S 太子妃版",
"manufacturer": "Letv",
"model": "Letv X501"
},
{
"name": "HTC One M9",
"manufacturer": "HTC",
"model": "HTC M9e"
},
{
"name": "HTC One A9",
"manufacturer": "HTC",
"model": "HTC One A9"
},
{
"name": "HTC One M9",
"manufacturer": "HTC",
"model": "HTC M9e"
},
{
"name": "HTC One A9",
"manufacturer": "HTC",
"model": "HTC One A9"
},
{
"name": "OPPO R9",
"manufacturer": "OPPO",
"model": "OPPO R9m"
},
{
"name": "OPPO Find7",
"manufacturer": "OPPO",
"model": "x9007"
},
{
"name": "OPPO Find5",
"manufacturer": "OPPO",
"model": "x909t"
},
{
"name": "OPPO R7",
"manufacturer": "OPPO",
"model": "OPPO R7"
},
{
"name": "OPPO R7S",
"manufacturer": "OPPO",
"model": "OPPO R7S"
},
{
"name": "锤子 T1",
"manufacturer": "Smartisan",
"model": "SM705"
},
{
"name": "锤子 T2",
"manufacturer": "Smartisan",
"model": "SM801"
},
{
"name": "坚果",
"manufacturer": "Smartisan",
"model": "YQ601"
},
{
"name": "锤子 T3",
"manufacturer": "Smartisan",
"model": "SM901"
},
{
"name": "小米2S",
"manufacturer": "Xiaomi",
"model": "MI 2S"
},
{
"name": "小米3",
"manufacturer": "Xiaomi",
"model": "MI 3"
},
{
"name": "小米4",
"manufacturer": "Xiaomi",
"model": "MI 4LTE"
},
{
"name": "小米4C",
"manufacturer": "Xiaomi",
"model": "MI-4C"
},
{
"name": "小米4S",
"manufacturer": "Xiaomi",
"model": "MI 4S"
},
{
"name": "小米5",
"manufacturer": "Xiaomi",
"model": "MI 5"
},
{
"name": "小米NOTE",
"manufacturer": "Xiaomi",
"model": "MI NOTE LTE"
},
{
"name": "小米MAX",
"manufacturer": "Xiaomi",
"model": "MI MAX"
},
{
"name": "小米NOTE 2",
"manufacturer": "Xiaomi",
"model": "MI NOTE 2"
},
{
"name": "小米NOTE 顶配版",
"manufacturer": "Xiaomi",
"model": "MI NOTE PRO"
},
{
"name": "红米Note3",
"manufacturer": "Xiaomi",
"model": "Redmi Note 3"
},
{
"name": "小米平板2",
"manufacturer": "Xiaomi",
"model": "MI Pad 2"
},
{
"name": "小米5S",
"manufacturer": "Xiaomi",
"model": "2016080 "
},
{
"name": "小米 Note 4",
"manufacturer": "Xiaomi",
"model": "2016060"
},
{
"name": "小米MIX",
"manufacturer": "Xiaomi",
"model": "MIX"
},
{
"name": "一加手机1",
"manufacturer": "OnePlus",
"model": "A1001"
},
{
"name": "一加手机2",
"manufacturer": "OnePlus",
"model": "ONE A2001"
},
{
"name": "一加手机3",
"manufacturer": "OnePlus",
"model": "OnePlus A3000"
},
{
"name": "中兴 AXON 天机 MAX",
"manufacturer": "ZTE",
"model": "ZTE C2016"
},
{
"name": "中兴 AXON 天机 MINI",
"manufacturer": "ZTE",
"model": "ZTE B2015"
},
{
"name": "中兴 AXON 天机",
"manufacturer": "ZTE",
"model": "ZTE A2015"
},
{
"name": "中兴 星星2号",
"manufacturer": "ZTE",
"model": "ZTE G720C"
},
{
"name": "努比亚Z11 mini全网通",
"manufacturer": "ZTE",
"model": "NX529J"
},
{
"name": "努比亚大牛 Z9 Max",
"manufacturer": "ZTE",
"model": "NX512J"
},
{
"name": "努比亚小牛4 Z9 Mini",
"manufacturer": "ZTE",
"model": "NX511J"
},
{
"name": "ZTE国民指纹机BladeA1",
"manufacturer": "ZTE",
"model": "ZTE C880U"
},
{
"name": "格力手机1",
"manufacturer": "GREE",
"model": "G0111"
},
{
"name": "格力手机1s",
"manufacturer": "GREE",
"model": "G0121"
},
{
"name": "格力手机2",
"manufacturer": "GREE",
"model": "G0128"
},
{
"name": "MX2",
"manufacturer": "Meizu",
"model": "MX2"
},
{
"name": "MX3",
"manufacturer": "Meizu",
"model": "M355"
},
{
"name": "MX4",
"manufacturer": "Meizu",
"model": "MX4"
},
{
"name": "MX4 Pro",
"manufacturer": "Meizu",
"model": "MX4 Pro"
},
{
"name": "MX5",
"manufacturer": "Meizu",
"model": "M575M"
},
{
"name": "PRO 6",
"manufacturer": "Meizu",
"model": "PRO 6"
},
{
"name": "魅蓝3",
"manufacturer": "Meizu",
"model": "魅蓝3"
},
{
"name": "魅蓝 note",
"manufacturer": "Meizu",
"model": "m1 note"
},
{
"name": "魅蓝3 note",
"manufacturer": "Meizu",
"model": "m3 note"
},
{
"name": "魅蓝metal",
"manufacturer": "Meizu",
"model": "m1 metal"
},
{
"name": "Galaxy S6 Edge+",
"manufacturer": "samsung",
"model": "SM-G9280"
},
{
"name": "Galaxy Note7",
"manufacturer": "samsung",
"model": "SM-N9300"
},
{
"name": "Galaxy S7 edge",
"manufacturer": "samsung",
"model": "SM-G9350"
},
{
"name": "Galaxy S7",
"manufacturer": "samsung",
"model": "SM-G9300"
},
{
"name": "Galaxy S8",
"manufacturer": "samsung",
"model": "SM-G9500"
},
{
"name": "Galaxy S8+",
"manufacturer": "samsung",
"model": "SM-G9550"
},
{
"name": "Galaxy C7",
"manufacturer": "samsung",
"model": "SM-W2017 "
},
{
"name": "Galaxy ON5",
"manufacturer": "samsung",
"model": "SM-G5520"
},
{
"name": "Galaxy ON5",
"manufacturer": "samsung",
"model": "SM-G5520"
},
{
"name": "Galaxy C9 Pro",
"manufacturer": "samsung",
"model": "SM-C9000"
},
{
"name": "Xperia Z3",
"manufacturer": "Sony",
"model": "L55t"
},
{
"name": "Xperia Z5 Premium",
"manufacturer": "Sony",
"model": "E6883"
},
{
"name": "Xperia Z5",
"manufacturer": "Sony",
"model": "E6683"
},
{
"name": "Xperia Z3+",
"manufacturer": "Sony",
"model": "E6533"
}
]
}
项目源码传送门
python adb修改android机型
版权声明:本文为xbw12138原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。