V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
guanyin8cnq12
V2EX  ›  程序员

海思固件 V500R020,内核 4.4.197 ,加载 外部 自编译模块, 显示 PLT sections 问题

  •  
  •   guanyin8cnq12 · 2021-07-01 09:54:19 +08:00 · 1330 次点击
    这是一个创建于 1001 天前的主题,其中的信息可能已经有所发展或是发生改变。
    linux 官方内核 4.4.197 中 arch/arm/kernel/module.lds 的内容是
    SECTIONS {
    .core.plt : { BYTE(0) }
    .init.plt : { BYTE(0) }
    }

    编译成的 ko 模块,在海思中运行提示 错误。

    module PLT section(s) missing

    随便找一个海思固件中的 ko,拖到 ida 里查看,section 里 只能查到 .plt 和 .init.plt 。

    尝试修改 arch/arm/kernel/module.lds 中的 .core.plt 为 .plt
    能加载,但是,用 lsmod 查看,模块加载是失败的,显示 -1 。
    dmsg 查看日志,显示

    [ 5188.608302] ------------[ cut here ]------------
    [ 5188.608360] WARNING: CPU: 1 PID: 10602 at kernel/module.c:1105 module_put+0x78/0x13c()
    [ 5188.608373] Modules linked in: getshell(O) ...
    [ 5188.609581] CPU: 1 PID: 10602 Comm: insmod Tainted: P W O 4.4.197 #1
    [ 5188.609597] Hardware name: Hisilicon A9
    [ 5188.609649] [<c0012d3c>] (rtos_unwind_backtrace) from [<c000e518>] (show_stack+0x10/0x14)
    [ 5188.609686] [<c000e518>] (show_stack) from [<c023cd20>] (dump_stack+0x88/0xa8)


    查阅了相关 Tainted P W O 似乎与问题无关。

    我想可能还是修改的 sections 有问题。
    将 core.plt 修改成 plt 虽然没报 PLT section(s) missing,但是似乎内核找不到相关 section 定义的内容。
    问题非常奇怪,有米有知道的,望不吝赐教。

    相关研究在这里,我已经 push 到 github
    https://github.com/0neday/Exploit-HS8545M-ONT/tree/main/persist-root-shell/linux-4.4
    第 1 条附言  ·  2021-07-01 10:42:53 +08:00

    [root@haproxy linux-4.4]# objdump -t hi_epon.ko | grep plt 00000000 l d .plt 00000000 .plt 00000001 l d .init.plt 00000000 .init.plt

    [root@haproxy linux-4.4]# objdump -t getshell.ko | grep plt 00000000 l d .plt 00000000 .plt 00000200 l d .init.plt 00000000 .init.plt

    hi_epon.ko 提取于 海思固件

    第 2 条附言  ·  2021-07-01 10:43:32 +08:00
    [root@haproxy linux-4.4]# objdump -t hi_epon.ko | grep plt 00000000 l d .plt 00000000 .plt
    00000001 l d .init.plt 00000000 .init.plt

    [root@haproxy linux-4.4]# objdump -t getshell.ko | grep plt 00000000 l d .plt 00000000 .plt
    00000200 l d .init.plt 00000000 .init.plt
    第 3 条附言  ·  2021-07-01 12:26:34 +08:00
    在海思 v500r019 里,其内核是 3.10 ,可以成功加载自编译模块。
    r020 用的是 4.4 内核,添加了新功能 PLTS
    第 4 条附言  ·  2021-07-01 12:26:39 +08:00
    在海思 v500r019 里,其内核是 3.10 ,可以成功加载自编译模块。
    r020 用的是 4.4 内核,添加了新功能 PLTS
    3 条回复    2021-11-18 00:10:11 +08:00
    ihipop
        1
    ihipop  
       2021-07-01 11:54:22 +08:00 via Android
    你是用的海狮官方 kernel header 编译的吗?如果是用官方的 Linux 内核代码编译,你怎么绕过海狮 Linux 内核的 magic ver 检测的?
    guanyin8cnq12
        2
    guanyin8cnq12  
    OP
       2021-07-01 12:12:12 +08:00
    @ihipop 不需要绕,直接在 config 里配。 第一次编译,不知道 magic,没关系,用 dmsg 查看,会有提示,你照着提示修改 config 就行了。很简单。
    btworm
        3
    btworm  
       2021-11-18 00:10:11 +08:00
    @guanyin8cnq12
    config.gz 找到了,但您提到的用"dmesg 查看,...照着提示修改 config", 不大明白什么意思。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1001 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:12 · PVG 06:12 · LAX 15:12 · JFK 18:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.