mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 22:45:48 +01:00
Update android.yml
This commit is contained in:
parent
10b27b2085
commit
7b02b08e87
124
.github/workflows/android.yml
vendored
124
.github/workflows/android.yml
vendored
@ -1,91 +1,49 @@
|
||||
#define _GNU_SOURCE // 必须放在第一行,确保 dlfcn.h 包含 RTLD_DEFAULT
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/user.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/uio.h>
|
||||
#include <elf.h> // 提供 ELF 相关定义
|
||||
#include <linux/elf.h> // 必须包含这个,提供 NT_PRSTATUS
|
||||
name: Android NDK Build
|
||||
|
||||
// 目标包名 (王者荣耀)
|
||||
const char* TARGET_PKG = "com.tencent.tmgp.sgame";
|
||||
const char* LIB_PATH = "/data/local/tmp/libJKMenu.so";
|
||||
on:
|
||||
push:
|
||||
branches: [ "master", "main" ]
|
||||
workflow_dispatch:
|
||||
|
||||
// 兼容性修正:如果环境依然找不到 NT_PRSTATUS,手动定义它
|
||||
#ifndef NT_PRSTATUS
|
||||
#define NT_PRSTATUS 1
|
||||
#endif
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
pid_t find_pid_by_name(const char* package_name) {
|
||||
DIR* dir = opendir("/proc");
|
||||
if (!dir) return -1;
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir))) {
|
||||
pid_t pid = atoi(entry->d_name);
|
||||
if (pid <= 0) continue;
|
||||
char path[256], cmd[256];
|
||||
snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
|
||||
FILE* f = fopen(path, "r");
|
||||
if (f) {
|
||||
if (fgets(cmd, sizeof(cmd), f) && strstr(cmd, package_name)) {
|
||||
fclose(f); closedir(dir); return pid;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
closedir(dir); return -1;
|
||||
}
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
int main() {
|
||||
pid_t pid = find_pid_by_name(TARGET_PKG);
|
||||
if (pid == -1) {
|
||||
printf("[-] Target process %s not found!\n", TARGET_PKG);
|
||||
return 1;
|
||||
}
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
||||
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
|
||||
perror("[-] Attach failed");
|
||||
return 1;
|
||||
}
|
||||
waitpid(pid, NULL, WUNTRACED);
|
||||
- name: Install Ninja
|
||||
run: sudo apt-get install ninja-build
|
||||
|
||||
struct user_pt_regs regs;
|
||||
struct iovec iov;
|
||||
iov.iov_base = ®s;
|
||||
iov.iov_len = sizeof(regs);
|
||||
|
||||
// 使用 NT_PRSTATUS 获取寄存器
|
||||
if (ptrace(PTRACE_GETREGSET, pid, (void*)NT_PRSTATUS, &iov) < 0) {
|
||||
perror("[-] PTRACE_GETREGSET failed");
|
||||
ptrace(PTRACE_DETACH, pid, NULL, NULL);
|
||||
return 1;
|
||||
}
|
||||
- name: Setup Android NDK
|
||||
uses: nttld/setup-ndk@v1
|
||||
id: setup-ndk
|
||||
with:
|
||||
ndk-version: r26b
|
||||
|
||||
// 远程定位 dlopen
|
||||
// 如果 RTLD_DEFAULT 依然报错,可以直接用 NULL
|
||||
uintptr_t remote_dlopen = (uintptr_t)dlsym(RTLD_DEFAULT, "__loader_dlopen");
|
||||
- name: Build with CMake
|
||||
run: |
|
||||
mkdir -p build && cd build
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
|
||||
-DANDROID_ABI=arm64-v8a \
|
||||
-DANDROID_PLATFORM=android-26 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DANDROID_STL=c++_static
|
||||
ninja
|
||||
|
||||
// 远程写入 SO 路径并调用
|
||||
uintptr_t sp = (regs.sp - 256) & ~0xF;
|
||||
size_t len = strlen(LIB_PATH) + 1;
|
||||
for (size_t i = 0; i < len; i += 8) {
|
||||
long data = 0;
|
||||
memcpy(&data, LIB_PATH + i, (len - i) < 8 ? (len - i) : 8);
|
||||
ptrace(PTRACE_POKETEXT, pid, sp + i, (void*)data);
|
||||
}
|
||||
|
||||
regs.regs[0] = sp; // x0: path
|
||||
regs.regs[1] = 2; // x1: RTLD_NOW
|
||||
regs.pc = remote_dlopen;
|
||||
|
||||
ptrace(PTRACE_SETREGSET, pid, (void*)NT_PRSTATUS, &iov);
|
||||
ptrace(PTRACE_DETACH, pid, NULL, NULL);
|
||||
|
||||
printf("[+] Injection request sent to PID %d\n", pid);
|
||||
return 0;
|
||||
}
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: JKMenu-Package
|
||||
path: |
|
||||
build/libJKMenu.so
|
||||
build/jk_injector
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user