• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 15 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Inject code into a running process
=========
 Injcode
=========
:Author: Thomas Habets
:Contact: [email protected]
: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>`_

More Repositories

1

arping

ARP Ping
C
398
star
2

simple-tpm-pk11

Simple PKCS11 provider for TPM chips
C++
251
star
3

cmdg

Command line Gmail client
Go
195
star
4

ssh-scripts

Some SSH-related scripts
Python
105
star
5

monotonic_clock

Portable C library for getting monotonic time
C
70
star
6

xor-analyze

Program for cryptanalyzing xor "encryption" with variable key length
C
42
star
7

ax25ms

This project is a set of AX.25 microservices, to be pluggable for any implementation.
C++
30
star
8

tlssh

TLS Shell
C++
25
star
9

bthelper

Bluetooth helper tools for setting up serial ports for e.g. SSH
C++
25
star
10

eggpd

Erlang BGP daemon
Erlang
25
star
11

sshproxy

SSH Proxy / Load balancer
Go
22
star
12

radiostuff

My collection of gnuradio stuff
Python
21
star
13

openssl-tpm-engine

TPM engine module for OpenSSL (this is not upstream)
Shell
20
star
14

rslurp

slurp down a whole HTTP directory, with parallel goodness
Go
19
star
15

gtping

GTP Ping
C
16
star
16

sim

Multi Party Authorization version of sudo/doas
C++
15
star
17

ind

Indent output from subprocess
C
12
star
18

weberl

Like web.py, but for Erlang
Erlang
11
star
19

clipsniff

Sniff the clipboard of a Unix X server.
C++
10
star
20

goircd

Minimalistic simple Internet Relay Chat (IRC) server
Go
10
star
21

pipebench

Measures the speed of stdin/stdout communication. I would actually recommend 'pv' over this program. I put it on github in order to collect everything in one place.
C
9
star
22

hamtransfer

Tool for transferring files over amateur radio using modern techniques
Rust
8
star
23

dejitun

De-jitter tunnel
C++
8
star
24

yhsmpam

YubiHSM PAM module backend
Python
8
star
25

goodpipe

Rust
7
star
26

qpov

Tool for converting Quake demo files to POV-Ray
Go
6
star
27

dotfiles

My dotfiles
C++
6
star
28

tlscheck

Quickly check TLS certificates of frontends and backends
Go
6
star
29

libopenpty

openpty() for platforms that don't have it
C
6
star
30

rustradio

Like GNURadio, but in Rust
Rust
6
star
31

diamond_linking_example

Example of a diamond linking thingy with version problems. See http://blog.habets.pp.se/2012/05/Shared-libraries-diamond-problem
C
6
star
32

multitraceroute

Fast traceroute that does TCP, UDP and ICMP traceroute in parallel and shows the results in one big table.
Python
5
star
33

tcpstats

Collect stats on TCP connections on close()
Python
5
star
34

wifispace

GNURadio program for measuring how busy wifi channels are
C++
5
star
35

lightwave

Like google wave, but much dumber and written in erlang
Erlang
5
star
36

zipbrute

Old project for brute forcing zip file passwords I found in an old backup from 2001.
C
4
star
37

tarweb

Serve a static website from a tar file
C++
4
star
38

hamwebby

Web interface for remote rig control of ham radios
JavaScript
4
star
39

opwgen

Generate passwords like OPIE generates OTPs: readably
C
4
star
40

fluxbox

Fluxbox window manager
4
star
41

netmap

Make and organize network maps from data directly out of your routers
Go
4
star
42

gopload

Self-contained simple HTTP upload handler using websockets to show progress
Go
4
star
43

openvpn

OpenVPN, with SSL Engine (TPM) support
C
3
star
44

cert-sig-pin

Extract a certificate signature suitable for Chrome public key pinning.
Go
3
star
45

pam_externalpass

Spawn external program from PAM to do authentication
Shell
3
star
46

yurate

Curate Youtube videos so that you don't miss any subscribed content.
JavaScript
3
star
47

temp-to-cloud

Upload temperature measurements to Stackdriver
Go
3
star
48

go-uuid

Local mirror of deleted codesite project
Python
2
star
49

firewalls-at-the-source

Go
2
star
50

x11type

Simulate keypresses in X
Shell
2
star
51

travelling-amateur

Tool for finding rules for operating amateur radio while visiting another country.
JavaScript
2
star
52

autoscan

Web and LCD/button UI for scanning from a USB scanner directly into Google Drive
Go
2
star
53

udportknock

UDP portknock script
Shell
2
star
54

pgsql

Postgresql useful commands, to be run with psql [databasename] -f <filename>
2
star
55

brain

My brain
POV-Ray SDL
2
star
56

ychares

Yubikey challenge-response script
Python
2
star
57

netcat

netcat-openbsd with fixed TCP_MD5SIG for Linux
C
2
star
58

yoracle

Yubikey oracle
Python
2
star
59

3ggraph

Graph live information from a 3G dongle
Python
2
star
60

irssi

irssi with TPM support
C
2
star
61

kybertest

CLI to encrypt files using quantum-resistant cryptography
C++
2
star
62

livecount

A widget for a web page (e.g. a blog post) that shows how many people (browsers) currently have the page open
Rust
2
star
63

airthingy

Tools for airthings API and bluetooth
Go
2
star
64

roodit

My reddit scripts
Python
2
star
65

sparslog

My implementation of an IKEA sparsnรคs SDR receiver
Rust
2
star
66

drive-du

Cmdline and cloud tool for listing folder sizes in Google Drive
Go
2
star
67

tlshake

Rust
2
star
68

mdsort

Maildir sorter
Python
1
star
69

smoog

My smugmug scripts
Python
1
star
70

openvpn-debian

OpenVPN, with SSL Engine (TPM) support
C
1
star
71

ndping

Like ARPing, but for IPv6
1
star
72

closite

Redirect user to the closest site using javascript
JavaScript
1
star
73

libdropprivs

Example code (will be library) for dropping privileges
C
1
star
74

profy

Always-on VPN client scripts intended for Raspberry Pi or other small computers
Shell
1
star
75

gr-habets38

My gnuradio components for gnuradio 3.8+
C++
1
star
76

doublecross-cpp

Experiments in making C++11 versions of things that exist in other languages. Such as the Maybe Monad from Haskell.
C++
1
star
77

tleservice

TLEService is a microservice for calculating satellite orbits.
Go
1
star
78

flight-radiation

Radiation data from a recent flight between LHR and SFO
Shell
1
star
79

keffos

Silly OS I wrote as a teenager
C
1
star