• Stars
    star
    113
  • Rank 303,052 (Top 7 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created about 15 years ago
  • Updated over 2 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
394
star
2

simple-tpm-pk11

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

cmdg

Command line Gmail client
Go
184
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++
31
star
8

tlssh

TLS Shell
C++
25
star
9

eggpd

Erlang BGP daemon
Erlang
25
star
10

sshproxy

SSH Proxy / Load balancer
Go
22
star
11

bthelper

Bluetooth helper tools for setting up serial ports for e.g. SSH
C++
22
star
12

openssl-tpm-engine

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

radiostuff

My collection of gnuradio stuff
Python
20
star
14

rslurp

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

sim

Multi Party Authorization version of sudo/doas
C++
16
star
16

gtping

GTP Ping
C
16
star
17

weberl

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

ind

Indent output from subprocess
C
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

dejitun

De-jitter tunnel
C++
8
star
23

yhsmpam

YubiHSM PAM module backend
Python
8
star
24

hamtransfer

Tool for transferring files over amateur radio using modern techniques
Rust
7
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

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
31

multitraceroute

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

tcpstats

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

wifispace

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

lightwave

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

zipbrute

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

tarweb

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

hamwebby

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

opwgen

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

fluxbox

Fluxbox window manager
4
star
40

netmap

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

gopload

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

openvpn

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

cert-sig-pin

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

pam_externalpass

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

yurate

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

temp-to-cloud

Upload temperature measurements to Stackdriver
Go
3
star
47

go-uuid

Local mirror of deleted codesite project
Python
2
star
48

firewalls-at-the-source

Go
2
star
49

x11type

Simulate keypresses in X
Shell
2
star
50

travelling-amateur

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

autoscan

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

udportknock

UDP portknock script
Shell
2
star
53

pgsql

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

brain

My brain
POV-Ray SDL
2
star
55

ychares

Yubikey challenge-response script
Python
2
star
56

netcat

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

yoracle

Yubikey oracle
Python
2
star
58

3ggraph

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

rustradio

Like GNURadio, but in Rust
Rust
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

python-pyhsm

Python code for YubiHSM
Python
2
star
66

drive-du

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

mdsort

Maildir sorter
Python
1
star
68

closite

Redirect user to the closest site using javascript
JavaScript
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

profy

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

libdropprivs

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

gr-habets38

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

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
76

tleservice

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

flight-radiation

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

sparslog

My implementation of an IKEA sparsnΓ€s SDR receiver
Rust
1
star
79

keffos

Silly OS I wrote as a teenager
C
1
star