36 lines
1.0 KiB
C
36 lines
1.0 KiB
C
// elon_all.c
|
|
// elonizes ur system
|
|
/* compile:
|
|
gcc -shared -fPIC -o elon_all.so elon_all.c -ldl
|
|
|
|
*/
|
|
#define _GNU_SOURCE
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <dlfcn.h>
|
|
#include <string.h>
|
|
int printf(const char *fmt, ...) {
|
|
(void)fmt;
|
|
return fprintf(stdout, "elon musk\n");
|
|
}
|
|
ssize_t write(int fd, const void *buf, size_t count) {
|
|
(void)buf; (void)count;
|
|
const char *msg = "elon musk\n";
|
|
size_t len = strlen(msg);
|
|
// Call the real write
|
|
static ssize_t (*real_write)(int,const void*,size_t) = NULL;
|
|
if (!real_write) real_write = dlsym(RTLD_NEXT, "write");
|
|
return real_write(fd, msg, len);
|
|
}
|
|
ssize_t send(int sockfd, const void *buf, size_t len, int flags) {
|
|
(void)buf; (void)len; (void)flags;
|
|
const char *msg = "elon musk\n";
|
|
size_t mlen = strlen(msg);
|
|
static ssize_t (*real_send)(int,const void*,size_t,int) = NULL;
|
|
if (!real_send) real_send = dlsym(RTLD_NEXT, "send");
|
|
return real_send(sockfd, msg, mlen, flags);
|
|
}
|