Skip to content
parasite? live on another process.
C Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


# Parasite - live along side a process. Die when it dies.

## Example: Serving a HTTP from /bin/sleep.

    % PARASITE_RUBY=./sinatra-example.rb LD_PRELOAD=./ sleep 360
    Parasite initialized by hooking 'malloc'
    == Sinatra/1.1.0 has taken the stage on 4567 for development with backup from Thin
    >> Thin web server (v1.2.7 codename No Hup)
    >> Maximum connections set to 1024
    >> Listening on, CTRL+C to stop - - [01/Feb/2011 19:10:25] "GET / HTTP/1.1" 200 12 0.0019 - - [01/Feb/2011 19:10:25] "GET /favicon.ico HTTP/1.1" 404 420 0.0008

    % curl localhost:4567; echo
    User time: 0.78<br>
    System time: 0.16

## Possible use cases:

* Expose internal-process data from any process over HTTP, etc, without needing
  to modify said program - and without requiring root access necessarily to access it.
* Allow coordinated handoff of server sockets without modifying the main
  program (this will be tricky, but should work nicely)
* Embed a script runtime (ruby, python, perl, nodejs, etc) into any running program.

## Example: Inspect netcat's socket.

% PARASITE_RUBY=irb-example.rb LD_PRELOAD=./ nc -l 8888
Parasite initialized by hooking 'malloc'
>> require "socket"
=> true
>> sock = Socket.for_fd(3)
=> #<Socket:0x7f8a795833c8>
>> port, address = Socket.unpack_sockaddr_in(sock.getsockname)
=> [8888, ""]

Something went wrong with that request. Please try again.