Change rand with LDPRELOAD

Create a .c file with the appropiate function signature:

int rand() {
    return 'B';
}

Compile according to your needs (to a .so and -shared):

gcc --shared -fPIC rand.c -o rand.so

Now run your program with LD_PRELOAD:

LD_PRELOAD=$PWD/random.so ./main

Note that this will not work for programs running in other privilege context.