<commit_before># Function hooking via LD_PRELOAD
Description: This directory contains some sample code for hooking a function is libc
## Settings up the project
### Pre-reqs
1. Linux OS
2. gcc is installed
⋅⋅ using ubuntu you can install gcc using sudo apt-get install gcc or on fedora sudo yum install gcc
### Instructions
Once all the prereqs are aquired just run 
```bash
./build.sh
```
This script will build `hook.so` and the executable `sample`
It will then run the program as so: `LD_PRELOAD=./libhook.so ./sample`

You should see some output similar to the block below:

> paul@paul-UX32VD:~/Documents/school/fall2013/cse409/project$ ./build.sh 
> Calling from main...
> inside shared object..
> malloc(12) = 0x18b1010
> displaying memory leaks..
> returning from shared object..
> returning to main..
> freeing memory..

## Sources and References
1. [Let’s Hook a Library Function](http://www.linuxforu.com/2011/08/lets-hook-a-library-function/)
2. [Tutorial: Function Interposition in Linux](http://www.jayconrod.com/cgi/view_post.py?23)
3. [LD_PRELOAD for real world heap access tracking](http://blog.oakbits.com/index.php?post/2012/04/11/LD_PRELOAD-for-real-usage-on-memory-allocation)
4. [LD PRELOAD notes](http://www.noah.org/wiki/LD_PRELOAD_notes)
5. [dlsym(3)](http://linux.die.net/man/3/dlsym)
6. [What is the LD_PRELOAD trick?](http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick)

<commit_msg>Added a few more sources to README.md<commit_after># Function hooking via LD_PRELOAD
Description: This directory contains some sample code for hooking a function is libc
## Settings up the project
### Pre-reqs
1. Linux OS
2. gcc is installed
⋅⋅ using ubuntu you can install gcc using sudo apt-get install gcc or on fedora sudo yum install gcc
### Instructions
Once all the prereqs are aquired just run 
```bash
./build.sh
```
This script will build `hook.so` and the executable `sample`
It will then run the program as so: `LD_PRELOAD=./libhook.so ./sample`

You should see some output similar to the block below:

> paul@paul-UX32VD:~/Documents/school/fall2013/cse409/project$ ./build.sh 
> Calling from main...
> inside shared object..
> malloc(12) = 0x18b1010
> displaying memory leaks..
> returning from shared object..
> returning to main..
> freeing memory..

## Sources and References
1. [Let’s Hook a Library Function](http://www.linuxforu.com/2011/08/lets-hook-a-library-function/)
2. [Tutorial: Function Interposition in Linux](http://www.jayconrod.com/cgi/view_post.py?23)
3. [LD_PRELOAD for real world heap access tracking](http://blog.oakbits.com/index.php?post/2012/04/11/LD_PRELOAD-for-real-usage-on-memory-allocation)
4. [LD PRELOAD notes](http://www.noah.org/wiki/LD_PRELOAD_notes)
5. [dlsym(3)](http://linux.die.net/man/3/dlsym)
6. [What is the LD_PRELOAD trick?](http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick)
7. [3.2.2.10 Memory Allocation Hooks](http://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Hooks-for-Malloc.html)
8. [Overriding 'malloc' using the LD_PRELOAD mechanism](http://stackoverflow.com/questions/6083337/overriding-malloc-using-the-ld-preload-mechanism)


{'fraction_non_alphanumeric': 0.13037974683544304, 'fraction_numerical': 0.036075949367088606, 'mean_word_length': 4.421955403087479, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 7, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5749543', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1051, 'n_words': 310}