In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the way to bypass the non-public API restrictions above Android P". In daily operation, I believe many people have doubts about what is the way to bypass the non-public API restrictions above Android P, and the editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what is the way to bypass the non-public API restrictions above Android P"! Next, please follow the editor to study!
First, we get the getDeclaredMethod method by reflecting API. GetDeclaredMethod is public, so there is no problem; the method we get through reflection is called the meta-reflection method.
Then, we just got the meta-reflection method through the reflection to reflect the call to getDeclardMethod. Here we achieve the purpose of reflection as a system-reflection-related API is a system class, so our meta-reflection method is also a method loaded by the system class; so the getDeclardMethod of our meta-reflection method call will be considered to be system-called and can reflect any method.
The pseudo code is as follows:
Method metaGetDeclaredMethod = Class.class.getDeclaredMethod ("getDeclardMethod"); / / Public API, no problem Method hiddenMethod = metaGetDeclaredMethod.invoke (hiddenClass, "hiddenMethod", "hiddenMethod parameter list"); / / system class uses hidden API through reflection, and the check passes directly. HiddenMethod.invoke / / find the Method direct reflection call correctly
At this point, we have been able to use "meta-reflection" to get hidden methods or hide Field at will. However, if all the hiding methods we use are to do this, it will be a bit of a hassle. In the above, we later found that there is an "exemption" condition for hiding API calls, as follows:
If (shouldWarn | | action = = kDeny) {if (member_signature.IsExempted (runtime- > GetHiddenApiExemptions () {action = kAllow; / / Avoid re-examining the exemption list next time. / / Note this results in no warning for the member, which seems like what one would expect. / / Exemptions effectively adds new members to the whitelist. MaybeWhitelistMember (runtime, member); return kAllow;} / / slightly}
As long as the IsExempted method returns true, even if the method is blacklisted, it will still be released and allowed to be called. Let's take another look at the IsExempted method:
Bool MemberSignature::IsExempted (const std::vector& exemptions) {for (const std::string& exemption: exemptions) {if (DoesPrefixMatch (exemption)) {return true;}} return false;}
Continue to track the passed parameter runtime- > GetHiddenApiExemptions () and find that this thing is also a parameter in runtime. In this case, we can go on and on, and we can also bypass it by directly modifying hidden_api_exemptions_ in the way we modify runtime flag. But if we keep tracking, we will find that this API is actually exposed to the Java layer, and there is a corresponding VMRuntime.setHiddenApiExemptions Java method; that is, as long as we set the exemption condition through VMRuntime.setHiddenApiExemptions, we can happily use reflection.
Combined with the above method, we only need to use "meta-reflection" to reflect the call to VMRuntime.setHiddenApiExemptions to exempt all the hidden API we want to use. Furthermore, if we take a look at the DoesPrefixMatch called in the IsExempted method above, we can see that it is prefixing the method signature. Children's shoes, the signatures of all our Java method classes start with L. If we send it directly to L, all hidden API will be pardoned!
At this point, the study on "what is the way to bypass the private API restrictions above Android P" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.