GithubHelp home page GithubHelp logo

Comments (3)

caikelun avatar caikelun commented on May 22, 2024 2

看了下 android 9 OPPO A8 的 ARM64 libziparchive.so:

$ llvm-readelf -sW ./libziparchive.so
......
85: 000000000000a274     8 FUNC    GLOBAL DEFAULT    12 _Z12EndIterationPv
98: 000000000000a278     4 FUNC    GLOBAL DEFAULT    12 _Z9FindEntryPvRK9ZipStringP8ZipEntry
......

可以看到这两个函数是紧挨着的,结合 _Z12EndIterationPv 的汇编分析,它的体积应该是 4 字节才对,现在错误的记录为了 8 字节,导致和 _Z9FindEntryPvRK9ZipStringP8ZipEntry 的地址范围重叠了

bh_hook_manager_verify_got_value 调用 dladdr 获取地址对应的符号名,最终 dladdr 会走到如下函数:

static bool symbol_matches_soaddr(const ElfW(Sym)* sym, ElfW(Addr) soaddr) {
  return sym->st_shndx != SHN_UNDEF &&
      soaddr >= sym->st_value &&
      soaddr < sym->st_value + sym->st_size;
}

在这个函数中,会发现 _Z12EndIterationPv 的地址范围已经 match,于是就直接返回了,dladdr 只会返回第一个 match 的函数信息。

这问题的根本原因是设备上的 libziparchive.so 的符号表中信息有错误。

可以先注释掉对 bh_hook_manager_verify_got_value 的调用,一般来说没什么问题。这个检测的目的是:如果在 bytehook hook 某个函数之前,已经有其他 hook 逻辑替换了当前 GOT 中的函数地址值(已经被hook了),那么 bytehook 再替换的话,就影响了之前的hook效果,bytehook的初衷是为了在 app 中统一集中管理所有的 PLT hook,因此遇到这种情况的话,就返回失败了,后续再通过 errno 来手动解决冲突问题。

from bhook.

Gangbadei avatar Gangbadei commented on May 22, 2024

bh_hook_manager_verify_got_value失败的日志打印:
image

dladdr 之后的dl_info 打印:
image

from bhook.

Gangbadei avatar Gangbadei commented on May 22, 2024

收到 多谢解答。

from bhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.