Guest User

Untitled

a guest
Mar 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // How to compile:
  2. // gcc -shared -fPIC -ldl -o lowermss.so lowermss.c
  3. // How to use:
  4. // LD_PRELOAD=./lowermss.so <command>
  5. #define _GNU_SOURCE
  6. #include <stdlib.h>
  7. #include <sys/types.h>
  8. #include <sys/socket.h>
  9. #include <netinet/in.h>
  10. #include <netinet/tcp.h>
  11. #include <dlfcn.h>
  12.  
  13. static void __attribute__((constructor)) lowermss_init();
  14. static int (*real_socket)(int, int, int);
  15. static int new_mss = 1460;
  16.  
  17. void lowermss_init() {
  18. real_socket = dlsym(RTLD_NEXT, "socket");
  19. }
  20.  
  21.  
  22. int socket(int domain, int type, int protocol) {
  23. int s = real_socket(domain, type, protocol);
  24. if(type == SOCK_STREAM) {
  25. setsockopt(s, IPPROTO_TCP, TCP_MAXSEG, &new_mss, sizeof(&new_mss));
  26. }
  27. return s;
  28. }
Add Comment
Please, Sign In to add comment