Everest reverse-xposed-001-super detailed version

This article is combined with the xposed-001 video of Mount Everest for reference and learning.

This version is a super detailed version. According to this method, you can definitely get started with a fatal blow. You can rest assured.

1. What is xposed

The framework is an open source framework. Its function is a framework service that can affect the operation of the program (modify the system) without modifying the APK. Based on it, many powerful modules can be made, and they can operate at the same time without conflicting functions. . In fact, to put it simply, xposed is a process that can hijack the underlying application process. If you understand the aspect programming algorithm, its function is very much like the aop framework, providing the aspect, and the logic before and after modifying the point.

2. Prepare information

  1. xposed installer Baidu network disk address:
    android 5.1 Corresponding xposed address link: https://pan.baidu.com/s/1_9sCUlxqGjYuX1FgqpPFlQ Password: 8gmf
    android 4.4 Corresponding xposed address link: https://pan.baidu.com/s /1d-z6SQU2V-7--oH9rORZ9w Password: sgkh
  2. xposed-bridge54.jar Baidu network disk address: Link: https://pan.baidu.com/s/1H69Jh9xNnd4ODkwFbRgW2A Password: 3f9x
  3. Root real machine or night god simulator thunder and lightning simulator, etc. Everyone prepares your own
  4. The author of idea development tool thinks this is better than android studio Official website address: https://www.jetbrains.com/idea/

3. Start working

  1. Create a new Android project as shown in Figure
    Select Android project, select Empty Activity
    2. Click next and enter the project information
    1. Choose Android 5.1. You can choose according to your mobile phone or emulator system
    . 3. Click finish. You will see the project startup screen and go
    Click set sdk where sdk refers to java sdk, select jdk1.8
    After the project is completed, the project structure is shown in the figure
    to this place. Congratulations, you have completed the task of writing an android apk by yourself, but it is not an xposed module yet, it doesn’t matter. , Follow my train of thought.

  2. Open lightning simulator installed xposed installer.apk corresponding version, say xposed installer apk dragged lightning simulator, open as Insert picture description here
    click OK, this is an abnormal situation novice often encountered, Could not load available ZIP files. Pull down to try again. Do
    n’t panic when you encounter such a problem. Normally, it’s because of network problems. If you switch to wifi or connect to the hotspot of your mobile phone, this problem can be solved. If it still doesn’t work, try another simulator. In short, the root cause is It is the network reason.
    A problem often encountered by novices
    Under normal circumstances, there will be an install button, click install, and then wait for the download. This download will be a bit slow. After the click is successful, it will be automatically installed. At this time, click to allow root, and then restart the emulator. At this time, the xposed installer will be counted. The installation was successful, and the author changed the Xiaoyao emulator and it was fine, as shown in the figure
    Normal state after successful installation

  3. At this time, let's try the apk we just created. Click the button in idea. This
    Insert picture description here
    will happen. The purpose of
    We will find that there is no connected device at this time. If it is a mobile phone, open the developer simulation. After trusting the device, it will appear in this place. If the simulator is used, an adb command needs to be executed.
    executing the adb command is to connect the simulator as a device to the PC and be recognized by the PC. The specific commands are:
    adb connect 127.0.0.1:xxxxx where xxxx represents the port, you can refer to this article of mine: https://blog.csdn.net/neruda1991/article/details/106343759
    we execute the command
    adb connect 127.0.0.1:21503.
    As shown in the figure, it has been successfully connected
    These are all It is an error-prone place. If a novice has a problem, don't panic. Repeat the operation and it will definitely be solved. If you have any questions, please send a private message to the author and leave your QQ number and questions. Those who meet the conditions can join our Everest reverse communication group to communicate.
    We click the debug button again, as shown in the figure,
    Connected devices will appear at this time
    everyone will wonder why this mobile phone brand, mine is an emulator Ah, don’t panic, you can open the emulator’s settings, as shown in
    Insert picture description here
    the picture. This place is the mobile phone brand of the emulator. Select this phone, click ok and
    wait for a while, the first apk we wrote will be installed on the emulator. the
    The first apk is successfully installed
    Demo1
    problem occurs if you during installation, the high probability is gradle a problem, do not panic having problems, direct private letter of leaving qq and issues, in line with the conditions of pull you into our Everest reverse exchange group.

Finally the apk is installed successfully, and the content of xposed has just started, but as long as I follow my steps, there will be no problems.

First of all, the four elements are how to transform an ordinary apk into an xposed module
. Keep in mind the four points. I will list them first. If you come across your own apk that is not recognized as a module by xposed, then Just look at the four-point contrast.
1. Although the libs folder comes with the android project, but what we have to do is to create a new lib folder under the app, put in XposedBridgeApi-54.jar, then click on the jar, right click and select Add as library
2 . Create a new assets folder under the src/main folder, and then create a new xposed_init file in the folder. The file is written with the full class name of the hook main class.
3. Modify AndroidManifest.xml. Refer to the following template for the modified content
. 4. Remember Remember that it is the project dependency in the build.gradle file in the app

. Although these four points are a bit vague, they are checkpoints. Let’s talk about how to do it in detail.
First step screenshot:
Insert picture description here
Insert picture description here
Click ok to confirm as shown in the
ok the first step is completed
second step. Get the blank files out, as shown in the
Insert picture description here
third step

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.zhufeng.demo1">

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data
                android:name="xposedmodule"
                android:value="true"/>
        <meta-data
                android:name="xposeddescription"
                android:value="我的第一个xposed模块"/>
        <meta-data
                android:name="xposedminversion"
                android:value="54"/>
    </application>

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

</manifest>

A fourth step
as shown in
the compile Group: 'com.alibaba', name: 'FASTJSON', Version: '1.2.62'
compileOnly FileTree (Includes: [ '* .jar'], the dir: 'lib')
The reason for adding fatsjon of alibaba is to introduce a json component, which is convenient for later use, personal habit, you can also introduce other json components
now good four The steps are basically completed. We are the highlight of today, how to make xposed work. The code behind involves some things about Android development. Some novices may not know much about Android development, but that’s okay. Just paste and copy the code below. The effect we want to achieve is to let xposed modify the return value of a method.

  1. We modify the MainActivity code as follows:
package com.zhufeng.demo1;

import android.util.Log;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    
    

    private static final String TAG = "firstXposed";

    @Override
    protected void onCreate ( Bundle savedInstanceState ) {
    
    
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main );

        String sign = getSign();

        TextView textView = this.findViewById(R.id.hello);
        textView.setText( sign );

    }

    public String getSign(){
    
    
        return "这是我的第一个xposed";
    }
    
}

At the same time, we click on this place and jump to the Android page.

Then in the original code, just add one line to it.
android:id="@+id/hello"
Insert picture description here
Everyone should cheer, it’s not far from victory
. In this place, let’s take a look at the success of our efforts. At this time, we click the debug button again. This is the right place. After the
Insert picture description here
installation is successful, if the interface is the same as the picture above, and there is this stuff in the drop-down menu of Android , It means that we have turned this apk into an xposed plug-in

Insert picture description here
Okay, about the logic of the above code, that is, we get the value of sign through the getSign method, and then display it in this hello component. The original Hello world has been overwritten by us. So what do we need to do is to write an xposed hook class to witness our effect, not much nonsense, directly on the code above,
we create a new HookEntry class, and pay attention to the xposed_init file under assets , Fill in the full class name
of this HookEntry
Insert picture description here

package com.zhufeng.demo1;

import android.util.Log;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

/**
 * 这个类是否生效  别忘了  在 assets文件夹下 的xposed_init文件中写上全类名
 */
public class HookEntry implements IXposedHookLoadPackage {
    
    

    private static final String TAG = "firstXposed";

    @Override
    public void handleLoadPackage ( XC_LoadPackage.LoadPackageParam loadPackageParam ) throws Throwable {
    
    


        Log.i( TAG , "packageName is" + loadPackageParam.packageName );


        //这个名字从哪里来的,去AndroidManifest.xml上边找package
        //这个表示apk的包名
        if(loadPackageParam.packageName.equals("com.zhufeng.demo1")){
    
    
            String hookClassName = "com.zhufeng.demo1.MainActivity";//你想去hook的目标类的全雷鸣
            Class<?> hookClass = loadPackageParam.classLoader.loadClass( hookClassName );

            XposedHelpers.findAndHookMethod( hookClass , "getSign" , new XC_MethodHook() {
    
    
                @Override
                protected void beforeHookedMethod ( MethodHookParam param ) throws Throwable {
    
    
                    super.beforeHookedMethod( param );
                }

                @Override
                protected void afterHookedMethod ( MethodHookParam param ) throws Throwable {
    
    
                    super.afterHookedMethod( param );
                    
                    param.setResult( "哈哈 我终于成功了~~~" );
                }
            } );
            
        }

        


    }
}

Okay here, let’s reinstall the apk, the old rules, click the debug button, install, here I don’t need to take a screenshot,
let’s click to activate and restart
Activate and restart
this place. Some emulators are silly, so we need to open xposed by ourselves, and then Check the module we just wrote in the module, then go back to the main interface and choose either restart or soft restart.
Insert picture description here
Insert picture description here
However, I usually get stuck when I click this, so I just turn off the restart instead of simply
restarting. After success, open the Demo1 apk we wrote, and the comfortable stuff is finally here

Insert picture description here
There should be applause here. When the author wrote this article, it was almost done in one go, because I have been tinkering with it many times and all kinds of pits have been stepped on. I also know that on the reverse road, I will encounter various obstacles of their own, but it does not matter, go with each other, fight monsters together, if you have any questions, you can privately write QQ and questions to me.

The source code issues that everyone cares about, I will put it in our Everest reverse group, and qualified friends can privately trust me to join the group. But you can also do it yourself successfully according to my article. If you are also successful, be sure to come back and leave a comment or bookmark the article~ Thank you, everyone, this is our 001 course of the Everest reverse xposed and
our 002 course. I will teach you how to write an injection API framework for Android. If you understand this technology, we can actively call a method in the hooked app, and always achieve what we want~~ For the second Friends who are interested in the class can also send me
a private message. Okay, see you in the next class~

Guess you like

Origin blog.csdn.net/neruda1991/article/details/106351552