1

I'm interested on injecting my own shared object to any future to run instance of a specific executable. This executable gives me hard time since it is executed a lot and quite frequently which makes me reluctant to inject my code actively (using ptrace()).

The best option I thought of is to use some kind of ELF patcher (maybe https://github.com/NixOS/patchelf ?) in order to make the executable depends on my code. This option discourages me since I'm afraid any bug in the code will lead to an executable corruption.

Any other suggestion?

Rules:

  • Root permissions are granted
  • I can't load a kernel module
  • The injection must be inline - meaning, before the executable entry point was called (main())
Eytan Naim
  • 159
  • 14
  • 1
    Does this https://stackoverflow.com/questions/25812181/is-it-possible-to-override-main-method-using-ld-preload help you? –  Jun 30 '20 at 01:14
  • I'm not the user that runs the executable which makes LD_PRELOAD problamtic. – Eytan Naim Jun 30 '20 at 05:20
  • 1
    for testing, you could always try copying the executable and modify the copy; one idea is creating a _constructor_ routine within your `customlib.so` and adding that lib to the copied executable with a tool like `patchelf`; is the result stable? – Milag Jun 30 '20 at 14:47
  • I'm aiming for a product :) – Eytan Naim Jun 30 '20 at 20:35

0 Answers0