Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the definition of Hook?

2025-01-18 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 definition of Hook". In daily operation, I believe many people have doubts about the definition of Hook. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is the definition of Hook?" Next, please follow the editor to study!

Hook technology, also known as hook function, is simply to pull the program out of the system into our own execution code snippet. Today, the editor will briefly introduce Hook in three minutes to let you know about Hook technology.

1. The definition of Hook

Hook, hook. Hook the program logic of the system. In the process of executing a certain section of SDK source code logic, intercept the execution of the logic by code means and add your own code logic.

Hook is simply similar to man-in-the-middle interception in network transmission. I intercept the original method in APP, define a method by myself, replace the original thing, and achieve a purpose that I cannot describe. This is true in vernacular, but the actual process and application are still relatively complex.

For common usage scenarios, take a few chestnuts:

App login hijacking, the general user manually click the "login" button will send the user name and password information to the server to verify whether the account and password are correct. This is very simple, people with ulterior motives only need to find a way for developers to authenticate the network after using the getText method of the EditText control, Hook this method, can hijack the user's account and password.

App injection advertising, when app starts to load HomeActivity must execute the onCreate method, hijack the home page of the onCreate method, inject pop-up ads inside to get advertising revenue. App data tampering, such as playing a game App, changing the number of gold coins in denomination, you can decompile App, find specific classes and methods, and insert your own methods. It sounds great, but to achieve it, you need to master a lot of reverse technology and other required technologies, but it is very difficult.

2. Practical value

Hook is the only way from intermediate development to advanced development. If Google is compared to the creator of Android, then the Android SDK source code contains the origin of everything. Intermediate developers only use everything to float on the surface, while senior developers can change everything from its origin and go deep into the core.

The most useful practical value: hook is the foundation of Android AOP programming, which allows us to insert extra logic without changing the original business. In this way, it not only protects the integrity of the original business, but also makes the additional code logic not coupled with the original business.

3. Pre-skills

Java reflection

Proficient in the use of class Class, method Method, member Field internal, many classes and methods are @ hide, external can not be accessed directly, so only through reflection, to create classes, methods, or members in the source code.

The ability to read Android source code

Hook entry points are all inside the source code, can not read the source code, can not sort out the source code logic, not to mention hook. In fact, there is a hole in using AndroidStudio to read the source code, and sometimes you will see "floating red" in the source code, which seems to be something that has not been quoted, but in fact, it is because some of the source code is not open to developers, which is very troublesome to solve. Therefore, it is recommended to download the whole source code from the Android official website, and then use SourceInsight to view the source code. If you don't need to jump around, just use the Android source site in one step.

4. General ideas of hook

No matter how complex the source code is, we want to interfere with some of the execution process, and there is only one way to kill it in the end: "changing beams for pillars". The idea of "changing beams for pillars" is usually a routine: determine the object to hook according to the demand to find the holder of the object to Hook, and get the object to hook (hold: class B has an object of class An in the member variable of class B, then B is the holder of A) define the proxy class of "object to Hook", and the object created in the previous step replaces the object to be Hook.

At this point, the study of "what is the definition of Hook" 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report