逆向android应用添加代码和资源

目标实现:反编译一个apk,在指定界面添加一个@+/id是tv_test的TextView,MainActivity的onCreate中通过设置文本"我是逆向添加的"

看下效果图:


逆向前效果图


逆向后效果图

开始工作:

对apk文件拆包:

apktool d test.apk

解压包之后cd到目录里面


先对res文件找到对应activity_main.xml文件添加布局代码,加入代码

    android:id="@+id/tv_test"

    android:background="@android:color/darker_gray"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:textSize="22dp" />

下一步,在res/values/public.xml添加id


tv_test是我们添加的id

记住id=0x7f070094 接下来要在R$id.smali文件添加改id,R$id.smali一般在包路径下面可以找到。添加完成之后如下图:


添加完成后的R$id.smali文件

接下来添加res/values/ids.xml文件


添加ids.xml文件


下一步修改activity文件,添加smali代码实现

TextView tvTest=findViewById(R.id.tv_test);

tvTest.setText("我是逆向添加的文本");

首先找到MainActivity.smali文件在onCreate方法中加入smali代码


MainActivity.smali onCreate方法添加代码

最后一步:

apktool b . 打包当前目录在dist文件夹下面生成apk文件,签名并运行。

打个广告:reversToy一键合并apk和aar神器https://github.com/dyglcc/reverseToy,有需要的朋友可以下载使用。

你可能感兴趣的:(逆向android应用添加代码和资源)