Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frida_injector_inject_library_file_sync failed on Kubernetes POD PID #533

Open
janetat opened this issue Jun 7, 2024 · 0 comments
Open

Comments

@janetat
Copy link

janetat commented Jun 7, 2024

1. Question

1.1 frida_injector_inject_library_file_sync failed when injecting Kubernetes POD PID

frida-core-inject-example <POD PID on Host>:
Failed to inject: libelf.so.1: cannot open shared object file: No such file or directory

Why it relates to libelf.so.1?

1.2 Why frida -p <POD PID on Host> -l frida_inject.js loaded successfully?

2. frida-core-inject-example.c

/*
 * Compile with:
 *
 * gcc -g -ffunction-sections -fdata-sections frida-core-inject-example.c -o frida-core-inject-example -L. -lfrida-core -ldl -lrt -lm -lresolv -pthread -Wl,--export-dynamic -lgio-2.0 -lgobject-2.0 -lglib-2.0
 *
 * Visit https://frida.re to learn more about Frida.
 */

#include "frida-core.h"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

// Function to print usage
void print_usage(const char *program_name) {
    fprintf(stderr, "Usage: %s <pid>\n", program_name);
}

int main(int argc, char *argv[]) {
    if (argc < 2) {
        print_usage(argv[0]);
        return 1;
    }

    int pid = atoi(argv[1]);
    const char *inject_path = "/root/.bpftime/libbpftime-agent.so";
    const char *agent_main = "bpftime_agent_main";
    const char *arg = "";

    frida_init();
    FridaInjector *injector = frida_injector_new();
    GError *err = NULL;

    guint id = frida_injector_inject_library_file_sync(injector, pid, inject_path, agent_main, arg, NULL, &err);
    if (err) {
        fprintf(stderr, "Failed to inject: %s\n", err->message);
        g_error_free(err);
        frida_unref(injector);
        frida_deinit();
        return 1;
    }

    printf("Successfully injected. ID: %u\n", id);
    frida_injector_close_sync(injector, NULL, NULL);
    frida_unref(injector);
    frida_deinit();

    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant