Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How to compile:
- // gcc -shared -fPIC -ldl -o lowermss.so lowermss.c
- // How to use:
- // LD_PRELOAD=./lowermss.so <command>
- #define _GNU_SOURCE
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
- #include <dlfcn.h>
- static void __attribute__((constructor)) lowermss_init();
- static int (*real_socket)(int, int, int);
- static int new_mss = 1460;
- void lowermss_init() {
- real_socket = dlsym(RTLD_NEXT, "socket");
- }
- int socket(int domain, int type, int protocol) {
- int s = real_socket(domain, type, protocol);
- if(type == SOCK_STREAM) {
- setsockopt(s, IPPROTO_TCP, TCP_MAXSEG, &new_mss, sizeof(&new_mss));
- }
- return s;
- }
Add Comment
Please, Sign In to add comment