First, preface
Recently, a classmate, sent me a device traffic access detection tool, but it is strange that he downloaded from the GP after the installation of no data, and directly installed on the GP can. There are also problems with packing two times. So here it can be judged that the app should have a signature check, and of course there are other check logic, we open this app interface as follows, no data:
Second, application analysis
Here is a simple analysis of the app, not much more directly using the JADX tool to open:
We will find that we need to authorize VPN permissions during our use, so we conclude that the app was developed using the Vpnservice function of the system, find the portal directly in the XML, and then go to the View configuration code:
Continue tracking to view internal logic:
In the worker class, see there are some core native methods, developed vpnservice know that interception of data and other operations are generally put to native to do, mainly because performance will be high. Not to mention directly using IDA to open the libwebd.so file, directly search the Nativeinit function, why search for this function? Because this is the initialization operation, and without the data, those checksum judgments will only be here, so look directly at this function implementation:
Keep looking down, what exactly did he do? Here are three main validations, specifically:
The first verification: Verify that the installation channel is GP, here using the system's Getinstallerpackagename method to make judgments, this method in the early version of Android has, but this method has a great use of the problem, will be introduced later. Because the GP installer package name is: com.android.vending, it is directly determined that if the installer is not GP, it does not carry out the blocking operation.
The second verification: the application of signature verification, this is the most common method of calibration, there is not much to explain, the direct use of kstools tool blasting can crack signature verification.
The third validation: This is the main validation xml android:debuggable= "True" This property value, we would like to debug this app before, the general will be manually anti-compilation to change this property is true. But we do not need to debug now, and there is no need to modify it. This verification has no effect on us.
See the above three verification, in fact, we now grasp the technology, is not difficult, especially the signature verification, can use kstools tools to do, a key operation, Students who do not know the Kstools tool can read this article: Automatic Burst Signature Verification tool Kstools in Android; This verification can be done by the students themselves using the tool. And the third validation can be said to have no effect, do not care about it. The first verification is the main point of view. Some students say the crack is also simple, directly modify the CBZ instructions can be. But this is missing a few tricks, we want not the result, but the process of learning. Now let's see how I cracked this check. We should introduce some more knowledge points again.
third, crack solution
To crack this installation channel there are roughly two scenarios, one is to use the Kstools tool source code modification, intercept the Getinstallerpackagename method, and then modify the return value, as follows:
The installer that returns the package name directly is GP, so it can be used by many people in the package. This is not much introduced, interested students to download the source of their own practice can be: https://github.com/fourbrother/kstools
There is also a super simple way to use the command PM install-i[to specify the installer package name] APK file, this command should be very few people know, but this simple command can be easily cracked here, you can specify an app installer.
After we install, we can see the installer name of the application in the/data/system/packages.xml of the system:
And here also said a knowledge, is the system of this packages.xml file, he is the device installation of the successful application of some details, including the use of permissions, signature information, installation channels, various signs and so on. Before someone asked how to get the device in the application installation channel source, in fact, can be obtained from this file. It is now true that the application is installed from the GP and that the PM command above is indeed valid.
Now let's see if the application interception works:
See, here began to intercept the device's packet, from here to see this app is really useful, for our development, is also a good tool, after the crack can be treasured use.
For the first way to crack is the best, because that can be used for many people, and for the second command to specify the installation method of the installer, the general small white users certainly do not know. For the first way to crack only need to modify the Kstools source code can.
Iv. Summary
All right, we've cracked it, we can use the app happily, but from the above we know that the new protection strategy is to determine whether the application comes from the specified application market. Some students may immediately think of, in order to prevent two of packaging, can be judged in the application from the mainstream application market channels, if not the right logic, this is also a protective strategy, but unfortunately the idea is not feasible, if feasible, there are many apps that have done so early. The reason is because this system method: Getinstallerpackagename, you can test this method, you will find: If an app is a system application, then this return value may be the device's own application market. If an app is a third-party app that is installed from the GP, this value must be com.android.vending, and if it's a different channel, such as a domestic app pack, Phone helper, pea pod, etc. It could be a null value, but a command such as PM, or a third-party application installed with the system's own installer could be a null value, that is to say: The application installer name returned by this system API is extremely unstable, completely an unreliable method, at least in the country can not be used. So you can almost ignore this method. But why does the app dare to do this? I'm curious, actually. However, it can be explained that the app developer has decided that the app is only available on GP, no other channels are released, so only the app downloaded by GP is considered legal. For example, a foreign user, using the Huawei mobile phone use of non-GP channels to download the app, it is a pity that this person can not be used. I'm also curious about why this app developer is doing this? Anyway, the domestic app should not do so. Because the return value of this method is extremely unstable.
But can not say that this method is not reliable, we in the back of the reverse is to ignore this protection, behind us in the crack app still follow the immutable law: Global Search Signature String to determine whether there is a signature check, Whether the global search Getinstallerpackagename method has secure channel validation. This is true whether you search in Ida or JADX.
Android Black Technology series--android new security protection strategy