Inject code into a running process
License
ThomasHabets/injcode
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more about the CLI.
- Open with GitHub Desktop
- Download ZIP
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
========= Injcode ========= :Author: Thomas Habets :Contact: thomas@habets.pp.se :Copyright: GPL Only supports x86 Linux, not 64bit. Install ======= Just type "make", and then put the binary (injcode) wherever you like. How it works ============ Injcode attaches to the target process using ptrace(). It then copies code and data into the memory space of the process and runs that. Then it cleans up as if it was never there. It places the code and data in the current code and data page, respectively. This ensures that no stack execution protection blocks it. The code injected can be anything, but currently these are implemented: - test Prints a message to stdout in the context of the target process. - close Close any file descriptor. (see /proc/<pid>/fd) - dup2 Overwrite any fd with a newly opened file. - retty Move a program from another tty to this one. Doing retty is quite involved. See: http://blog.habets.pp.se/2009/03/Moving-a-process-to-another-terminal for the full story. Running ======= Example 1: move irssi from one terminal to another -------------------------------------------------- Maybe move it into a screen. First start irssi in one terminal. Run injcode in another terminal: $ injcode -m retty <pid of irssi> Irssi should now be moved to the second terminal, including having a new controlling terminal. Example 2: redirect stdout of a running program into a file ----------------------------------------------------------- $ injcode -m dup2 \ -ofd=1 \ -oflags=O_CREAT,O_WRONLY,O_TRUNC \ -ofilename=logfile.txt <pid of program> Bugs ==== See bug list/wishist using BugsEverywhere. This file is written in `reStructuredText <http://docutils.sourceforge.net/docs/user/rst>`_
About
Inject code into a running process
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published