Library for overriding system calls which fetch random values.
Go to file
Anton Livaja f3a453a88e
initial commit
2024-07-17 13:24:15 -04:00
src initial commit 2024-07-17 13:24:15 -04:00
.gitignore initial commit 2024-07-17 13:24:15 -04:00
Cargo.lock initial commit 2024-07-17 13:24:15 -04:00
Cargo.toml initial commit 2024-07-17 13:24:15 -04:00
LICENSE initial commit 2024-07-17 13:24:15 -04:00
Makefile initial commit 2024-07-17 13:24:15 -04:00
README.md initial commit 2024-07-17 13:24:15 -04:00

README.md

libfakerand

Introduction

libfakerand intercepts various system calls that programs use to retrieve entropy. It replaces the entropy which would otherwise be used with the one supplied by the user. This means you can force programs to use a fixed value instead of a random one.

libfakerand overrides the following functions:

  • rand()
  • read() function for /dev/urandom and /dev/random
  • getrandom()
  • RAND_bytes()

Usage

You may use env variables LD_PRELOAD and FAKERAND along with a command:

LD_PRELOAD=./target/release/libfakerand.so FAKERAND=0 openssl rand -hex 16

Alternatively, set environment variables so that all programs running in that shell are effected:

export LD_PRELOAD=/usr/lib/fakerand/fakerand.so
export FAKERAND=42

If you will be using it this way, it may make sense to place the .so file in /usr/lib/fakerand

Notes

Statically linked libraries can't be overriden by LD_PRELOAD. For this reason, libfakerand can't override cases such as:

FAKERAND=42 LD_PRELOAD=./target/release/libfakerand.so awk 'BEGIN{srand(); print rand()}' 2>/dev/null

This is because awk is statically linked.