安卓改机技术揭秘(一) 工具篇

来源:互联网 发布:页面加载时执行js 编辑:程序博客网 时间:2024/06/15 02:53
目前 市面上你能买到的一些安卓刷量变机工具例如 008K、变机宝等等 使用的都是XPOSED框架来修改手机的机型。这种修改方式目前是一种主流技术,主流技术的优点就是兼容性好、开发(包括文档支持、社区支持、第三方模块)成本低、稳定性高等特点。但对于当前项目来说,主流技术并不是一个好的解决办法,因为主流技术不光你了解,APP的厂商的技术人员也很了解,而且一般规律来看,厂商的技术实力、人力、财力以及这三方面的积累,不是一个小团队的作者可以对抗的。

目前改机软件所实现的修改机型项目汇总起来分为以下几类
1:手机唯一身份标志
这个很好理解,主要包括 IMEI IMSI ICCID 等等这些全球唯一的身份标志,来表示这台手机的独立性,另外要实现一些编号的校验位运算,一般情况下,这些标志身份的序号都有校验位和一些固定的格式和算法,这里有很多渠道和积分墙是对这些序号的合法性有检测的。
2 : 唯一标志衍生信息
这个衍生信息就有很多项了,例如一些改机软件 随便的把某个厂商的型号和一个合法的IMEI结合在一起,殊不知IMEI的前6位为TAC,是每个机型独有的身份标志,随便搭配后,一定会被检测出来的。再例如联通的IMSI是46001开头,移动和电信的就不一样,IMSI,ICCID,NUMBER,运营商,网络制式,mnc,mcc这些信息最起码是要匹配的。
3:环境信息
环境信息分为两部分 ①:手机内部环境 包括你的系统特定信息,用户特定信息。②:手机外部环境:基站信息、GPS信息、WIFI信息等等。

本文中所有的操作都基于Android Studio环境。下面进入实战操作环节!

1 首先创建一个APP,并配置XPOSED的开发环境,配置过程可以参考以下两篇文章,此处不再重复。
http://www.cnblogs.com/csonezp/p/5177928.html
http://www.open-open.com/lib/view/open1451364108964.html

2 配置好XPOSED环境后,在该APP中创建HOOK类 本文为MainHook,该类必须继承IXposedHookLoadPackage

1
2
3
4
5
6
7
8
public class MainHook implements IXposedHookLoadPackage
{
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable
    {
        //xposed程序入口 do something...
    }
}



3 实际修改项

目前市面上的很多改机软件都没有修改第二处的IMEI
另外一个位置是在com.android.internal.telephony.PhoneSubInfo类中,
导致有些反作弊系统读取这个位置的IMEI值后不会下分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getDeviceId", GetCatValue("imei"));
HTool.XHookMethod("com.android.internal.telephony.PhoneSubInfo",mLpp.classLoader, "getDeviceId", GetCatValue("imei"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getSubscriberId", GetCatValue("imsi"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getLine1Number", GetCatValue("number"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getSimSerialNumber", GetCatValue("simserial"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getSimCountryIso", GetCatValue("simcountryiso"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getSimOperator", GetCatValue("simoperator"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getSimOperatorName", GetCatValue("simoperatorname"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getNetworkCountryIso", GetCatValue("networkcountryiso"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getNetworkOperator", GetCatValue("networkoperator"));
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getNetworkOperatorName", GetCatValue("networkoperatorname"));
 
//WIFI信息
HTool.XHookMethod(android.net.wifi.WifiInfo.class.getName(),mLpp.classLoader, "getMacAddress", GetCatValue("wifimac"));
HTool.XHookMethod(android.net.wifi.WifiInfo.class.getName(),mLpp.classLoader, "getBSSID", GetCatValue("bssid"));
HTool.XHookMethod(android.net.wifi.WifiInfo.class.getName(),mLpp.classLoader, "getSSID""\""+GetCatValue("ssid")+"\"");
XposedHelpers.findAndHookMethod(java.net.NetworkInterface.class.getName(),mLpp.classLoader, "getHardwareAddress", new Object[] {
        new XC_MethodHook()
        {
            protected void afterHookedMethod(MethodHookParam param) throws Throwable
            {
                //每个安卓系统中 至少存在5个以上的MAC地址 
                //但大多数软件只修改了MAC和BSSID 
                //真正的MAC修改是在此处理函数中监听每次访问.
            }
        }});
         
//蓝牙信息
HTool.XHookMethod(BluetoothAdapter.class.getName(),mLpp.classLoader,"getAddress", GetCatValue("bluemac"));
HTool.XHookMethod(BluetoothAdapter.class.getName(),mLpp.classLoader, "getName", GetCatValue("bluename"));
 
//设置手机信息 无论手机是否插入了sim卡 都会模拟出SIM卡的信息 APP获得SIM卡消息时返回该手机已有SIM卡
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getPhoneType", TelephonyManager.PHONE_TYPE_GSM);
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getNetworkType", TelephonyManager.NETWORK_TYPE_HSPAP);
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "getSimState", TelephonyManager.SIM_STATE_READY);
HTool.XHookMethod(android.telephony.TelephonyManager.class.getName(),mLpp.classLoader, "hasIccCard"true);
 
     
//修改手机系统信息 此处是手机的基本信息 包括厂商 信号 ROM版本 安卓版本 主板 设备名 指纹名称等信息
XposedHelpers.setStaticObjectField(android.os.Build.class, "MODEL", GetCatValue("model"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "MANUFACTURER", GetCatValue("manufacturer"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "BRAND", GetCatValue("brand"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "HARDWARE", GetCatValue("hardware"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "BOARD", GetCatValue("board"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "SERIAL", GetCatValue("serial"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "DEVICE", GetCatValue("device"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "ID", GetCatValue("id"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "PRODUCT", GetCatValue("product"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "DISPLAY", GetCatValue("display"));
XposedHelpers.setStaticObjectField(android.os.Build.class, "FINGERPRINT", GetCatValue("fingerprint"));
 
XposedHelpers.findAndHookMethod("android.os.SystemProperties",mLpp.classLoader, "native_get", new Object[] {String.class,String.class,
        new XC_MethodHook()
        {
            //为了防止某些APP跳过Build类 而直接使用SystemProperties.native_get获得参数
        }});
//修改系统版本 我看到世面上的软件基本上都是不能修改系统版本的 从而造成了刷量后 很多渠道最终会显示你的APP用户全部使用的某一系统版本
//这样的话数据就太假了.
XposedHelpers.setStaticObjectField(android.os.Build.VERSION.class, "RELEASE", GetCatValue("version"));
XposedHelpers.setStaticObjectField(android.os.Build.VERSION.class, "SDK", GetCatValue("apilevel"));
 
HTool.XHookMethod(android.os.Build.class.getName(),mLpp.classLoader, "getRadioVersion", GetCatValue("radioversion"));
 
//修改为指定的运营商mnc mcc信息
XposedHelpers.findAndHookMethod(android.content.res.Resources.class.getName(),mLpp.classLoader, "getConfiguration", new Object[] {
        new XC_MethodHook()
        {
            ...........................
            //此处的mnc和mcc必须和系统中其他关于运营商的数据对应!
        }});
 
//修改ANDROID_ID
XposedHelpers.findAndHookMethod(android.provider.Settings.Secure.class.getName(),mLpp.classLoader, "getString",
new Object[] {ContentResolver.class,String.class,
        new XC_MethodHook()
        {
            ...............................
            //此处会根据传入的String参数 判断返回值 其中包括比较关键的数据就是android_id
        }});
 
//防止APP使用Runtime.exec方式获取一些特定的系统属性
XposedHelpers.findAndHookMethod(Runtime.class.getName(),mLpp.classLoader, "exec",new Object[] {String.class,String[].class, File.class,
        new XC_MethodHook()
        {
            //一些APP从JAVA层获得到了数据 还会从shell(native)层获得一些更底层的数据 来判断用户的合法性
            //经常用到的有 cat、getprop、ifconfig等等命令,当exec执行这些命令后 往往会返回一些手机的真实信息
            //因为框架和处理方式不同,...部分此处根据自己需求,编写重定向返回值的过程...
        }});
 
//修改位置信息
XposedHelpers.findAndHookMethod(LocationManager.class.getName(),mLpp.classLoader, "getLastKnownLocation",
    new Object[] {String.class,
            new XC_MethodHook()
            {
                ..........................
                //返回预先设置好的经纬度信息以伪装地理位置
            }});
 
HTool.XHookMethod(Location.class.getName(),mLpp.classLoader, "getLatitude", latitude);
HTool.XHookMethod(Location.class.getName(),mLpp.classLoader, "getLongitude", longitude);
 
 
//修改GSM制式手机的基站信息
HTool.XHookMethod(android.telephony.gsm.GsmCellLocation.class.getName(),mLpp.classLoader, "getLac", GsmLac);
HTool.XHookMethod(android.telephony.gsm.GsmCellLocation.class.getName(),mLpp.classLoader, "getCid", GsmCid);
 
 
//修改CDMA制式手机的基站信息
HTool.XHookMethod(android.telephony.cdma.CdmaCellLocation.class.getName(),mLpp.classLoader, "getBaseStationLatitude", CdmaLatitude);
HTool.XHookMethod(android.telephony.cdma.CdmaCellLocation.class.getName(),mLpp.classLoader, "getBaseStationLongitude", CdmaLongitude);
HTool.XHookMethod(android.telephony.cdma.CdmaCellLocation.class.getName(),mLpp.classLoader, "getBaseStationId", CdmaBid);
HTool.XHookMethod(android.telephony.cdma.CdmaCellLocation.class.getName(),mLpp.classLoader, "getSystemId", CdmaSid);
HTool.XHookMethod(android.telephony.cdma.CdmaCellLocation.class.getName(),mLpp.classLoader, "getNetworkId", CdmaNid);
 
 
//模拟手机的APP列表
XposedHelpers.findAndHookMethod("android.app.ApplicationPackageManager",mLpp.classLoader, "getInstalledPackages",new Object[] {int.class,
        new XC_MethodHook()
        {
            //此处模拟正常用户的APP列表 其中随机的增加和删除一些常用APP 以达到每个手机的APP有很大的随意性和合理性
        }});
 
XposedHelpers.findAndHookMethod("android.app.ApplicationPackageManager",mLpp.classLoader, "getInstalledApplications",new Object[] {int.class,
        new XC_MethodHook()
        {
            //此处模拟正常用户的APP列表 其中随机的增加和删除一些常用APP 以达到每个手机的APP有很大的随意性和合理性
        }});
         
//防止APP的VPN SOCK5 HTTP代理检测
XposedHelpers.findAndHookMethod(java.net.NetworkInterface.class.getName(),mLpp.classLoader, "getNetworkInterfacesList",new Object[] {
        new XC_MethodHook()
        {
            ........................................
            //此处对于一些连接信息 对JAVA做了隐藏处理 但对于系统和Native层依然是可见的 所以APP不会检测到代理 但代理却可以正常的运行...
        }});



       
以上这些做下来 从信息采集上基本可以过市面上70%的系统了 对于某些系统的高级检测,则需要我们采用更高级的处理方式才能攻破对方的防线,这些处理方式我们随后会讲到。
但目前推广市场上 不光是采用技术手段 还采取大数据分析等方式判断你的数据是否合格 所以想把这个作为一个项目来做 从技术方面解决工具问题只是刚刚开始。



原文地址: https://bbs.pediy.com/thread-213042.htm

原创粉丝点击