吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4905|回复: 41
收起左侧

[Android 原创] 分析xx输入法

[复制链接]
koifish 发表于 2022-2-24 23:18

分析xx输入法

解包与封包

  • 解包

    java -jar apktool_2.6.0.jar d xxx_lastold.apk -o bdold

    image-20220211212405835

  • 封包

    java -jar apktool_2.6.0.jar b bdold -o xxx.apk

    封包后发现执行会崩溃。
    >
    > 经过调试后发现存在反调试,删除掉反调试的代码。
    >

过签名检验

xx输入法v4.2.1.32

总体思想:
app本身没有做太多的防护,只有一个签名校验。
签名校验的位置在inputcore_20131125文件中的Java_com_baidu_input_PlumCore_PlInit函数中。

image-20220211213158042

image-20220211215054587

image-20220211215427962

PlInit为inputcore_20131125中的原生函数。

image-20220211215956165

注释掉checkState函数。

原来的汇编指令:
03 F0 DD F9  BL      _Z10checkStatei ; checkState(int)
将这句话注释掉,修改为:
00 00       MOVS    R0, R0
00 00       MOVS    R0, R0

xx输入法v5.0.1.6

和v4一致.

修改前

修改后

注释checkState函数。

原汇编:
03 F0 41 F9 BL      _Z10checkStatei ; checkState(int)

修改为:
00 00       MOVS    R0, R0
00 00       MOVS    R0, R0

最新版xx输入法v10.9.5.25

主要过程和v4差不多。在lib中分析libiptcore.so

搜索字符串signature很容易定位到下面的代码。

计算Hash

调用计算Hash

这里的代码逻辑非常的清晰,想要去除Hash校验的方法有很多,例如:

  • if条件取反。
  • if-else代码全部删除,在调用sub_38DB8,直接给定参数0

我这里简单一点,直接修改if跳转。

修改前

修改后

重新打包后,安装进手机发现能够正常运行了。

修改原包名

xx输入法v4.2.1.32

总体思想:

修改AndroidManifest.xml和smali汇编中有关包名这部分的内容。

注意:

  1. 修改完AndroidManifest.xml和smali汇编后封包的时候可能有些错误。这是由于资源中包名的部分没有修改,根据提示进行修改。
  2. 在so中可能存在反射调用的问题,需要在so中进行同步修改。

这里将原包名com.xxxx.input修改为com.xxxx.imput

AndroidManifest.xml

  • Line 1

    <?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.xx.imput">
  • Line 56

    <activity android:configChanges="keyboardHidden|orientation|screenSize" android:excludeFromRecents="true" android:name=".ImeCellManActivity" android:taskAffinity="com.xxx.imput.cell" android:theme="@android:style/Theme.NoTitleBar"/>
  • Line 57

    <activity android:configChanges="keyboardHidden|orientation|screenSize" android:excludeFromRecents="true" android:name=".ImeThemeActivity" android:taskAffinity="com.baidu.imput.theme" android:windowSoftInputMode="adjustPan"/>
  • Line 61

    <activity android:configChanges="keyboardHidden|orientation|screenSize" android:excludeFromRecents="true" android:name=".ImeListEditorActivity" android:noHistory="true" android:taskAffinity="com.baidu.imput.listeditor" android:theme="@android:style/Theme.Dialog"/>
  • Line 78

    <action android:name="com.xxx.imput.action.INSTALL"/>

res

重新封包时发现以下错误:

W: G:\nom\bd_bugai\res\layout\emoji_detail.xml:17: error: No resource identifier found for attribute 'textSize' in package 'com.baidu.input'
W:
W: G:\nom\bd_bugai\res\layout\emoji_item.xml:13: error: No resource identifier found for attribute 'textSize' in package 'com.baidu.input'
emoji_detail.xml
  • Line 4

    xmlns:xxx="http://schemas.android.com/apk/res/com.xxx.imput">
  • Line 15

    <com.xxx.imput.layout.widget.PageGalleryView android:id="@id/gallery" android:layout_width="0.0dip" android:layout_height="0.0dip" android:layout_marginLeft="32.0dip" android:layout_marginRight="32.0dip" />
  • Line 16

    <com.xxx.imput.layout.widget.HintSelectionView android:id="@id/hint" android:layout_width="fill_parent" android:layout_height="6.0dip" android:layout_marginLeft="82.0dip" android:layout_marginTop="12.0dip" android:layout_marginRight="82.0dip" android:layout_marginBottom="24.0dip" />
  • Line 17

    <com.xxx.imput.layout.widget.DownloadButton android:id="@id/button" android:background="@drawable/guide_btef" android:layout_width="fill_parent" android:layout_height="34.0dip" android:layout_marginLeft="36.0dip" android:layout_marginRight="36.0dip" baidu:textSize="14.0dip" />
emoji_item.xml
  • Line 4

    xmlns:xxx="http://schemas.android.com/apk/res/com.baidu.imput">
  • Line 13

    <com.xxx.imput.layout.widget.DownloadButton android:id="@id/button" android:background="@drawable/guide_btef" android:layout_width="fill_parent" android:layout_height="26.0dip" android:layout_marginTop="20.0dip" android:layout_below="@id/thumb" android:layout_alignLeft="@id/thumb" android:layout_alignRight="@id/thumb" baidu:textSize="12.0dip" />

smali汇编

  • 需要修改的smali文件的数量特别多,采用代码修改。

  • 在smali汇编中包名中的.被替换成/

    public class Main {
      public static void main(String[] args) {
          UpdateFile updateFile = new UpdateFile("G:\\nom\\bd_bugai\\smali\\com", "Lcom/xxx/input", "Lcom/xxx/imput");
          updateFile.updateFiles();
      }
    }
    import java.io.*;
    import java.util.List;
    
    public class UpdateFile {
      private String mCWD;
      private String mOldPkgName;
      private String mNewPkgName;
    
      UpdateFile(String cwd, String oldPkg, String newPkg) {
          mCWD = cwd;
          mOldPkgName = oldPkg;
          mNewPkgName = newPkg;
      }
    
      public void updateFiles() {
          updateFiles(mCWD);
      }
      private void updateFiles(String dir) {
          File file = new File(dir);
          File[] files = file.listFiles();
          for (File f : files) {
              if (f.isDirectory()) {
                  updateFiles(f.getAbsolutePath());
              } else {
                  System.out.println(f.getAbsolutePath());
                  update(f.getAbsolutePath());
              }
          }
      }
    
      private void update(String filePath) {
          BufferedReader br = null;
          String line = null;
          StringBuffer buf = new StringBuffer();
          try {
              // 根据文件路径创建缓冲输入流
              br = new BufferedReader(new FileReader(filePath));
              // 循环读取文件的每一行, 对需要修改的行进行修改, 放入缓冲对象中
              int lineNum = 1;
              while ((line = br.readLine()) != null) {
                  // 此处根据实际需要修改某些行的内容
                  if (line.contains(mOldPkgName)) {
                      String update = line.replaceAll(mOldPkgName, mNewPkgName);
                      buf.append(update);
                      System.out.println("    ["+lineNum+"]"+line);
                      System.out.println("    ["+lineNum+"]"+update);
                      System.out.println();
                  }
                  // 如果不用修改, 则按原来的内容回写
                  else {
                      buf.append(line);
                  }
                  buf.append("\n");
                  lineNum++;
              }
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              // 关闭流
              if (br != null) {
                  try {
                      br.close();
                  } catch (IOException e) {
                      br = null;
                  }
              }
          }
    
          BufferedWriter bw = null;
          try {
              // 根据文件路径创建缓冲输出流
              bw = new BufferedWriter(new FileWriter(filePath));
              // 将内容写入文件中
              bw.write(buf.toString());
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              // 关闭流
              if (bw != null) {
                  try {
                      bw.close();
                  } catch (IOException e) {
                      bw = null;
                  }
              }
          }
      }
    }

so文件修改

image-20220211221005093

搜索字符串,然后可以把这些字符串进行修改。然后封包发现终于可以正常运行了。

免费评分

参与人数 7威望 +2 吾爱币 +107 热心值 +7 收起 理由
lxx05 + 1 技多不压身
baikunlun + 1 + 1 学楼主的方法,打字乱码了,图在28楼
pdcba + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
fengbolee + 2 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
tony118 + 1 + 1 用心讨论,共获提升!
qtfreet00 + 2 + 100 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
你皮任你皮 + 2 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

hhuan 发表于 2022-2-26 12:08
小白问题:这是修改了什么呢?       

liu2514 发表于 2022-2-25 13:56
对于小白的我来说,看天书。。。感谢分享!!
top777 发表于 2022-2-25 14:25
hanlaoshi 发表于 2022-2-25 17:13
牛啊牛啊
dxjinf 发表于 2022-2-26 07:17
学习学习,关键是思路
smallmouse228 发表于 2022-2-26 12:41
小白啥也没看懂!!!
shuwangpeng 发表于 2022-2-26 14:53
学习了,感谢大牛
北辰POP 发表于 2022-2-26 17:42
思路非常好
 楼主| koifish 发表于 2022-2-26 18:19
hhuan 发表于 2022-2-26 12:08
小白问题:这是修改了什么呢?

修改了so过签名校验
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-26 09:34

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表