All Projects → dsnet → termijack

dsnet / termijack

Licence: other
TermiJack surreptitiously hijacks standard streams (stdin, stdout, and/or stderr) from an already running process.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to termijack

ntee
Portable Unix shell command 'tee', with some extras - read from standard input and write to standard output and files
Stars: ✭ 22 (-86.75%)
Mutual labels:  stdout, stdin
anewer
anewer appends lines from stdin to a file if they don't already exist in the file. This is a rust version of https://github.com/tomnomnom/anew
Stars: ✭ 46 (-72.29%)
Mutual labels:  stdout, stdin
smag
Show Me A Graph - Command Line Graphing
Stars: ✭ 78 (-53.01%)
Mutual labels:  stdout
mini-kali
Docker image for hacking
Stars: ✭ 15 (-90.96%)
Mutual labels:  gdb
V8Power
Putting the power of an 8-cylinder engine under the hood of DOS batch files.
Stars: ✭ 30 (-81.93%)
Mutual labels:  stdout
gdb graphs
To visualize function call flow for a C/C++ program using gdb and python
Stars: ✭ 61 (-63.25%)
Mutual labels:  gdb
metal.test
Deprecated, superseded by https://github.com/metal-ci/test
Stars: ✭ 41 (-75.3%)
Mutual labels:  gdb
exploiting
Exploiting challenges in Linux and Windows
Stars: ✭ 122 (-26.51%)
Mutual labels:  gdb
vscode-db-explorer-firebird
Explore and run queries against your Firebird® databases without leaving VS Code.
Stars: ✭ 16 (-90.36%)
Mutual labels:  gdb
lldbg
A lightweight native GUI for LLDB.
Stars: ✭ 83 (-50%)
Mutual labels:  gdb
evry
Split STDIN stream and execute specified command every N lines/seconds.
Stars: ✭ 61 (-63.25%)
Mutual labels:  stdin
vdb
A set of python visual enhancements for gdb.
Stars: ✭ 23 (-86.14%)
Mutual labels:  gdb
kakoune-gdb
gdb integration plugin
Stars: ✭ 44 (-73.49%)
Mutual labels:  gdb
gdb-ruby
It's time for Ruby lovers to use Ruby in gdb, and gdb in Ruby!
Stars: ✭ 55 (-66.87%)
Mutual labels:  gdb
envsensor-observer-py
Python Bluetooth low energy observer example for OMRON Environment Sensor (2JCIE-BL01)
Stars: ✭ 31 (-81.33%)
Mutual labels:  stdout
xboxpy
Python module to interface with original Xbox hard- and software
Stars: ✭ 23 (-86.14%)
Mutual labels:  gdb
minimal gdb
🐛 Lightweight vim -> gdb broker which uses .gdbinit gdb config file to export breakpoints
Stars: ✭ 16 (-90.36%)
Mutual labels:  gdb
gdb 2 root
This python script adds some usefull command to stripped vmlinux image
Stars: ✭ 20 (-87.95%)
Mutual labels:  gdb
CTF
My CTF tools & some other stuff
Stars: ✭ 17 (-89.76%)
Mutual labels:  gdb
lwprintf
Lightweight printf library optimized for embedded systems
Stars: ✭ 98 (-40.96%)
Mutual labels:  stdout

Terminal Hijacker

Introduction

terminal

TermiJack hijacks the standard streams (stdout, stdin, and/or stderr) from an already running process and silently returns them back after finishing. While this script is running and attached to another process, the user may interact with the running process as if they were interacting with the original terminal.

This script also provides the ability to mirror hijacked streams. In the case of standard input, this means that inputs from both this terminal and the remote terminal will be forwarded to the target process. Similarly, standard output and error coming from the target process will be forwarded to both this terminal and the remote terminal.

While gdb is being used to hijack standard streams, there may be a small latency during the transition where the target process is paused. Do not use this script on time-critical processes. Also, this script may need to be run as root in order for gdb to do its business.

Lastly, this script performs poorly with programs using either the ncurses or readline GNU libraries due to the special way they interact with input/output streams. Support for them may be added in the future.

Requires the GNU Debugger (gdb) in order to run.

Theory

Typically, the standard streams (stdin, stdout, stderr) are connected to a virtual terminal like /dev/pts/23 as show below:

before_hijack

Using gdb to intercept the target process, we can use syscalls (open, fcntl) to create a set of named pipes that will act as the intermediate socket between the target process and the hijacker script. Other syscalls (dup, dup2) are used to clone the original standard streams to temporary place-holders and to swap the file descriptors of the named pipes and standard streams.

In the situation where we only hijack the standard streams and don't reflect the to/from the original streams, this setup looks something like the following:

after_hijack

The termijack script also allows the ability to mirror the standard streams to/from the hijacked process. This means that the hijacked stdin and hijacker's stdin will be multiplexed to the target process. Additionally, and stdout or stderr coming from the hijacked process will be sent to both the hijacked virtual terminal and to the hijacker's virtual terminal. This setup looks something like the following:

after_hijack_reflect

Of course, at the very end, when the termijack script detaches from the target process, it will undo all of the shenanigans and close file descriptors that it opened. Ideally, it's operation should be very surreptitious.

Usage

Hijack stdin, stdout, and stderr:

  • ./termijack.py -ioe $TARGET_PID

Hijack stdin, stdout, and stderr. Also, reflect them back to the target process:

  • ./termijack.py -IOE $TARGET_PID
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].