Skip to content

meng156sb/kpm-control-demos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KPM Control Demos

一个面向 APatch / KernelPatch 的公开示例仓库,演示 3 种常见的 KPM 用户态控制方案

  1. KPM_CTL0 + sc_kpm_control():官方推荐方案
  2. hook __NR_supercall:自定义 SuperCall 命令方案
  3. hook __NR_prctl:自定义 prctl 操作码方案

为什么做这个仓库

很多 KPM 示例只展示单一路径,实际做项目时常见的控制入口有多种:

  • 想走 APatch 官方控制通路
  • 想做 自定义 supercall 协议
  • 想做 兼容普通用户态调用的 prctl 通路

这个仓库把三套方案放在一起,方便直接比较它们的:

  • 接入复杂度
  • 安全边界
  • 用户态调用方式
  • 适合的业务场景

方案对比

方案 用户态入口 是否官方通路 适合场景 结论
KPM_CTL0 + sc_kpm_control() sc_kpm_control() 固定命令、模式化控制、正式项目 首选
hook __NR_supercall syscall(__NR_supercall, ...) 研究/实验/自定义协议 可用,但要自己处理认证与兼容
hook __NR_prctl prctl(custom_op, ...) 原型验证、任意参数传递、快速实验 简单直接,但不如 CTL0 原生

仓库结构

.
├─ demos/
│  ├─ ctl0_sc_kpm_control/
│  ├─ custom_supercall_hook/
│  └─ prctl_hook_control/
├─ docs/
│  └─ comparison.md
└─ build.ps1

快速开始

1. 构建全部 demo

powershell -ExecutionPolicy Bypass -File .\build.ps1 -Target all

2. 只构建某一套

powershell -ExecutionPolicy Bypass -File .\build.ps1 -Target ctl0
powershell -ExecutionPolicy Bypass -File .\build.ps1 -Target custom-supercall
powershell -ExecutionPolicy Bypass -File .\build.ps1 -Target prctl

3. 输出目录

所有产物统一输出到:

out/

推荐顺序

如果你只打算学一套,建议按这个顺序看:

  1. demos/ctl0_sc_kpm_control/
  2. demos/custom_supercall_hook/
  3. demos/prctl_hook_control/

说明

  • 仓库默认面向 Android + APatch + KernelPatch 场景
  • 示例都尽量保持最小可运行
  • custom supercall hookprctl hook 方案属于教学/研究演示,不建议直接替代官方 CTL0 通路做正式模块控制

About

APatch/KernelPatch KPM control demos: CTL0, custom supercall hook, and prctl hook

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors