elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
27 Mayo 2012, 20:30  


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)

+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Hacking Avanzado
| | |-+  Hacking Linux/Unix (Moderadores: kamsky, TRICKY, berz3k)
| | | |-+  yaws ( yet another wingate scanner)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: yaws ( yet another wingate scanner)  (Leído 2,459 veces)
romanflyx

Desconectado Desconectado

Mensajes: 17


Ver Perfil
yaws ( yet another wingate scanner)
« en: 20 Mayo 2007, 00:01 »

yaws ( yet another wingate scanner)

les dejo el codigo fuente y que alguien me conteste donde se guarda el archivo de logs cuando hago el escaneo:

/* Yet Another Wingate Scanner (YAWS) Version 0.1
   (C) 1999 by tempus fugit, tempusf@gmx.net
   URL: tf.darpa.org
   You can freely distribute this stuff, but
   please let the copyright information intact
   and don't alter the code.

   Feel free to send my any comments or suggestions

   Features:
   - can read the hosts to check from a file
   - can scan subnets (class b and c)
   - has an extra flag to prevent intrusion detection systems from being activated
   - logs the results
   - logs successes in an extra file
   - you can enter the number of subprocesses
   - you can specify a timeout

   compile with gcc yaws.c -o yaws

*/

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <netdb.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <getopt.h>
#include <fcntl.h>

#define wgateport 23

void CheckForWingate (char *,int);
void init_rand ();
void DoLog (char *);
void LogSuccess (char *);
void usage ();
int sock, timeout=5;
char *logfile="yaws.log", *suclogfile="yaws.suc", *progname;

int main (int argc, char **argv) {
   static int forked=0;
   int forks=1, i, pid, dummy, scanned=0, toscan=0, j, k, extra=0, rnumber;
   char c, network[64]="none", class[]="z", inputfile[64]="", host[100];
   FILE *input;
   typedef char target[100];
   target *mytarget;
   progname=argv[0];
   while ((c = getopt (argc, argv, "vef:l:n:c:i:t:s:")) != -1) {
      switch (c) {
         case 'f': forks = atoi (optarg);
              break;
         case 'e': extra = 1;
              break;
         case 'l': logfile = optarg;
              break;
         case 'n': strncpy (network, optarg, 64);
              break;
         case 'c': strncpy (class, optarg, 1);
              break;   
         case 'i': strncpy (inputfile, optarg, 64);
              break;
         case 't': timeout = atoi (optarg);
              break;
         case 's': suclogfile = optarg;
              break;
         case 'v': usage ();
         case '?': usage ();
      }
   }
   
   if (argc < 2) {
      fprintf (stderr, "To few argumtens.\n");
      usage ();
   }
   
   if (forks < 1) {
      fprintf (stderr, "To little number of forks.\n");
      usage ();
   }
   
   DoLog ("YAWS 1999 by tempus fugit\n\n");
   
   if ((strcmp (network, "none")) && (strcmp (class, "z"))) {
      if ((!strcmp (class, "b")) && (extra == 0)) {   
         for (j=1; j<255; j++) {
            for (k=1; k<255; k++) {
               snprintf (host, 100, "%s.%d.%d", network, j, k);
               if ((pid = fork ()) == 0) {
                  CheckForWingate (host, wgateport);
                  kill(getpid(),9);
               }
               if (pid != 0) {
                  forked++;
                  if (forked >= forks) {
                     wait (&dummy);
                     forked--;
                  }
               }
            }
         }
      }
      else if ((!strcmp(class, "c")) && (extra == 0)) {
         for (j=1; j<255; j++) {
            snprintf (host, 100, "%s.%d", network, j);
            if ((pid = fork ()) == 0) {
               CheckForWingate (host, wgateport);
               kill(getpid(),9);
            }
            if (pid != 0) {
               forked++;
               if (forked >= forks) {
                  wait (&dummy);
                  forked--;
               }
            }
                  
         }
      }
      else if ((!strcmp(class, "b")) && (extra == 1)) {
         init_rand();
         mytarget = malloc ((254*254) * (sizeof (target)));
         if (mytarget == NULL) {
            fprintf (stderr, "Cannot allocate memory.\n");
            exit (1);
         }
         fprintf (stdout, "I am computing the random IPs, this may take a while.\n");         
         for (j=1; j<255; j++) {
            for (k=1; k<255; k++) {
                    marke:               
               rnumber = (int) ((254.0*254.0)*rand()/(RAND_MAX+1.0));
               if (strlen ((mytarget+rnumber)) > 1) goto marke;            
               snprintf ((mytarget+rnumber), 100, "%s.%d.%d", network, j, k);
               
            }
         }
         for (j=0; j<=(254*254); j++) {
            if ((pid = fork ()) == 0) {
               CheckForWingate ((mytarget+j), wgateport);
               kill(getpid(),9);
            }
            if (pid != 0) {
               forked++;
               if (forked >= forks) {
                  wait (&dummy);
                  forked--;
               }
            }
                  
         }
      }
      
      else if ((!strcmp(class, "c")) && (extra == 1)) {
         init_rand();
         mytarget = malloc ((255) * (sizeof (target)));
         if (mytarget == NULL) {
            fprintf (stderr, "Cannot allocate memory.\n");
            exit (1);
         }
         for (j=1; j<255; j++) {
                    marke2:               
               rnumber = 1+(int) ((254.0)*rand()/(RAND_MAX+1.0));
               if (strlen ((mytarget+rnumber)) > 1) goto marke2;            
               snprintf ((mytarget+rnumber), 100, "%s.%d", network, j);                                                                   
            
         }
         for (j=1; j<255; j++) {
            if ((pid = fork ()) == 0) {
               CheckForWingate ((mytarget+j), wgateport);
               kill(getpid(),9);
            }
            if (pid != 0) {
               forked++;
               if (forked >= forks) {
                  wait (&dummy);
                  forked--;
               }
            }         
         }
      }
         
      else
      {
         if ((class != "b") && (class != "c")) {
            printf ("You entered an unknown class or no network.\n");
            return 1;
         }
      }
   for (i=1; i <= forked; i++) wait (&dummy);
   return 0;
   }
      
   input = fopen (inputfile, "r");
   if (input == NULL) {
      fprintf (stderr, "Cannot open input file.\n");
      return 1;
   }
      
   while ((fscanf (input, "%s\n", host)) != EOF) {
      if ((pid = fork ()) == 0) {
         CheckForWingate (host, wgateport);
         kill(getpid(),9);
      }
      if (pid != 0) {
         forked++;
         if (forked >= forks) {
            wait (&dummy);
            forked--;
         }
      }
         
   }
   fclose (input);
   for (i=1; i <= forked; i++) wait (&dummy);

}

void alarm_handler (int sig) {
   close (sock);
   return;
}

void CheckForWingate (char *host, int port)
{
   int ret, conn, sel;
   char buffer[128], logmsg[1024];
   struct sockaddr_in sin;
   fd_set fd;
   struct timeval tv;
   struct hostent *he;
   
   if ((strlen (host)) == 0) exit (1);
   
   if (!(sock = socket (AF_INET, SOCK_STREAM, 0))) {
      fprintf (stderr, "Cannot create a socket.\n");
      exit (1);
   }
   
   if (inet_addr (host) == -1) {
      if ((he=gethostbyname (host)) == NULL) {
         snprintf (logmsg, 1024, "The host %s cannot be resolved.\n", host);
         DoLog (logmsg);
         return;
      }       
      memcpy (&sin.sin_addr, he->h_addr,he->h_length);
   }
   else if ((sin.sin_addr.s_addr = inet_addr (host)) == -1) {
      snprintf (logmsg, 1024, "IP %s cannot be identified.\n", host);
      DoLog (logmsg);
      return;
   }
   sin.sin_family = AF_INET;
   sin.sin_port = htons (port);
   signal (SIGALRM, alarm_handler);
   alarm (timeout);
   conn = connect (sock, (struct sockaddr*)&sin, sizeof (sin));
   if (conn < 0) {
      snprintf (logmsg, 1024, "Cannot connect to host %s on port %d.\n", host, port);
      DoLog (logmsg);
      close (sock);
      return;
   }
   FD_ZERO (&fd);
   FD_SET (sock, &fd);
   tv.tv_sec = timeout;
   tv.tv_usec = 0;
   sel = select (sock+1, &fd, NULL, NULL, &tv);
   if (sel > 0) {
      if ((ret = recv (sock, buffer, 128, 0)) > 0) {
         if (!strcmp (buffer, "WinGate>")) {
            snprintf (logmsg, 1024, "Host %s is a wingate.\n", host);
            DoLog (logmsg);
            LogSuccess (logmsg);
         }
         else {
            snprintf (logmsg, 1024, "Host %s is no wingate.\n", host);
            DoLog (logmsg);
         }
      }
      
   }
   if (!sel) {
      snprintf (logmsg, 1024, "Host %s time out by search.\n", host);
      DoLog (logmsg);
   }
   if (sel == -1) {
      fprintf (stderr, "Select Error.\n");
      exit (1);
   }
   close (sock);
   return;
}

void init_rand() {
        int fd;
        unsigned n;
        fd = open("/dev/random", O_RDONLY);
        read(fd, &n, sizeof(n));
        close(fd);
        srand(n);
}

void DoLog (char *message) {
   FILE *file;
   file = fopen (logfile, "a");
   if (file == NULL) {
      fprintf (stderr, "File Error.\n");
      exit (1);
   }
   fprintf (file,"%s", message);
   fclose (file);
}

void LogSuccess (char *message) {
   FILE *file;
   file = fopen (suclogfile, "a");
   if (file == NULL) {
      fprintf (stderr, "File Error.\n");
      exit (1);
   }
   fprintf (file, "** SUCCESS: **  ");
   fprintf (file, "%s", message);
   fclose (file);
}

void usage () {
   printf ("[YAWS] Yet Another Wingate Scanner Version 0.1 1999 by tempus fugit\n");
   printf ("mail: tempusf@gmx.net\n");
   printf ("URL: http://tf.darpa.org\n\n");
   printf ("Usage: %s -v -l <logfile> -f <forks> -t <timeout> -n <network> -c <network-class> -i <input file> -s <success-logfile>\n", progname);
   printf ("\tlogfile: the name of the file where the scanning results are stored.\n");
   printf ("\tforks  : the number of forks the program is allowed to create.\n");
   printf ("\ttimeout: timeout of search-process in seconds.\n");
   printf ("\tnetwork: you can enter network that will be checked for wingates.\n");
   printf ("\tnetwork: can be <X.X> or <X.X.X> if class is\n");
   printf ("\t                  b   or    c\n");
   printf ("\tinput-file: you can specify an input-file from which the hosts to checked are extraced.\n");
   printf ("\tsuccess-logfile: success messages are written in this file.\n");
   printf ("\tif you choose an input-file, the network and class options are ignored.\n");
   printf ("Example: %s -l mylogs -n 200.10 -c b -s wow\n", progname);
   exit (0);
}
      
      
   
      
   
   
      

      
      
   
      
   
      
   
   
      


« Última modificación: 20 Mayo 2007, 03:47 por romanflyx » En línea
romanflyx

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: yaws ( yet another wingate scanner)
« Respuesta #1 en: 20 Mayo 2007, 01:31 »

ya esta lo guarda en el directorio donde esta instalado


En línea
romanflyx

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: yaws ( yet another wingate scanner)
« Respuesta #2 en: 20 Mayo 2007, 02:44 »

tengo 5 scanners mas para linux  si alguien tiene alguno  hacemos cambio
que me mande un mail a romanflyx@hotmail.com

gracias!!

En línea
romanflyx

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: yaws ( yet another wingate scanner)
« Respuesta #3 en: 20 Mayo 2007, 03:50 »

les dejo otro y que alguien comente algo o me responda como busco wingates mal configurados que permita telnet en irc u otra forma de buscarlos.

/***************************************
Gateprobe is back...
Version: 2.1 fixed
With lot of news features
Added:
-IP resolving
-Scan class A
-View option
-File save (from misteri0)
-Bug fix and code cleanup
Bong bong26@hotmail.com
PS: Why make a new code for just 3 lines
of code changed, misteri0 ?
****************************************/

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <errno.h>
#define SA struct sockaddr
#define SIN_LEN sizeof(struct sockaddr_in)
#define IPV4_ADDRLEN 16

void ShowHelp(char *);
int ConnectCheck(struct sockaddr_in, int),view;
FILE *stream;
char DestIP[15];
const char *ipv4_ntop(int, const void *, char *, size_t);
const char *ipv4_showname(int , const void *, char *, size_t);

int main(int argc, char *argv[]) {
   int i,j,k,c,status,Children=128,Timeout=7,class;
   char *NetworkID,*num3;
   struct sockaddr_in DestAddress;
   if(argc < 3) ShowHelp(argv[0]);
   NetworkID = argv[1];
   num3=argv[2];
   class=atoi(num3);
   while((c = getopt(argc, argv, "vp:c:t:")) != -1) {
      switch(c) {
         case 'v': view = 1; break;
         case 'c': Children = atoi(optarg); break;
         case 't': Timeout = atoi(optarg); break;
      }
   }
   if(Children < 1) ShowHelp(argv[0]);
   if(Timeout < 1) ShowHelp(argv[0]);
   if(class < 1) ShowHelp(argv[0]);
   if (class > 3) ShowHelp(argv[0]);   
   if (class==1){
   fprintf(stderr, "Scanning %s.*.*.*:23 children:%i,timeout:%i\n\n",
   NetworkID,Children, Timeout);
   for(k = 1; k < 256; k++) {
   for(j = 1; j < 256; j++) {
   for(i = 1; i < Children; i++) {   
      sprintf(DestIP, "%s.%d.%d.%d", NetworkID,k,j, i);
      inet_aton(DestIP, &DestAddress.sin_addr);
      if(!fork()) ConnectCheck(DestAddress, Timeout);
   }
   for(i = Children + 1; i < 256; i++) {
      wait(&status);
      sprintf(DestIP, "%s.%d.%d.%d", NetworkID,k,j,i);
      inet_aton(DestIP, &DestAddress.sin_addr);
      if(!fork()) ConnectCheck(DestAddress, Timeout);
 }
 }
 } 
  }
   if (class==2){
   fprintf(stderr, "Scanning %s.*.*:23 children:%i,timeout:%i\n\n",
   NetworkID,Children, Timeout);
   for(j = 1; j < 256; j++) {
   for(i = 1; i < Children; i++) {
      sprintf(DestIP, "%s.%d.%d", NetworkID,j,i);
      inet_aton(DestIP, &DestAddress.sin_addr);
      if(!fork()) ConnectCheck(DestAddress, Timeout);
   }
   for(i = Children + 1; i < 256; i++) {
      wait(&status);
      sprintf(DestIP, "%s.%d.%d", NetworkID,j,i);
      inet_aton(DestIP, &DestAddress.sin_addr);
      if(!fork()) ConnectCheck(DestAddress, Timeout);
   }
 }
 }
 if (class==3){
   fprintf(stderr, "Scanning %s.*:23 children:%i,timeout:%i\n\n",
   NetworkID,Children, Timeout);
   DestAddress.sin_family = AF_INET;
   DestAddress.sin_port = htons(23);
   for(i = 1; i < Children; i++) {
      sprintf(DestIP, "%s.%d", NetworkID, i); 
      inet_aton(DestIP, &DestAddress.sin_addr);
      if(!fork()) ConnectCheck(DestAddress, Timeout);
   }   
   for(i = Children + 1; i < 256; i++) {
      wait(&status);
      sprintf(DestIP, "%s.%d", NetworkID, i);
      inet_aton(DestIP, &DestAddress.sin_addr);
      if(!fork()) ConnectCheck(DestAddress, Timeout);

   }
   for(;;) {
      if((waitpid(-1, &status, WNOHANG) == -1) && (errno == ECHILD))
            exit(EXIT_SUCCESS);   
}   
}
}

int ConnectCheck(struct sockaddr_in DestAddr, int Timeout)
 {
   int result,ret,SocketFD;
   char Hostname[60],buffer1[64];
   if (view==1) printf("%s\n",DestIP);
   if((SocketFD = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(EXIT_FAILURE);
   alarm(Timeout);
   result = connect(SocketFD, (SA *)&DestAddr, SIN_LEN);
   if (!result) {
      alarm(Timeout);
      memset(buffer1, '\0', 64);
         if ((ret = read(SocketFD, buffer1, 64))  > 0)
         {
            ret = read(SocketFD, buffer1, 64);
            if(!(memcmp(buffer1, "WinGate>", 8)) ||
               !(memcmp(buffer1, "Too man", 7)))
            {
     printf("Wingate found: %s\n\a",
     ipv4_showname(AF_INET,&DestAddr.sin_addr.s_addr,Hostname,59));
     stream = fopen("wingatelist.txt","a");
     fprintf(stream,"%s\n",
     ipv4_showname(AF_INET,&DestAddr.sin_addr.s_addr,Hostname,59));
     fclose(stream);
     }}
      close(SocketFD);
  }
   exit(EXIT_SUCCESS);
}

const char *
ipv4_ntop(int family, const void *addrptr, char *strptr, size_t len) {
   const u_char *p = (const u_char *)addrptr;                         
   if(family == AF_INET) {
      char temp[IPV4_ADDRLEN];
      snprintf(temp, sizeof(temp), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
      if(strlen(temp) >= len) {
         return(NULL);
      }
      strcpy(strptr, temp);
      return(strptr);
   }
   return(NULL);
}

const char *
ipv4_showname(int family, const void *addrptr, char *strptr, size_t len) {
   struct hostent *hentry;
   size_t aflen;
   if(family == AF_INET) aflen = 4;
   else {
      return(NULL);
   }
   if((hentry = gethostbyaddr(addrptr, aflen, family)) != NULL) {
      if(strlen(hentry->h_name) < len) {
         strcpy(strptr, hentry->h_name);
         return(strptr);
      }
   }
   return(ipv4_ntop(family, addrptr, strptr, len));
}

void ShowHelp(char *argv0) {
   printf("\nBong Wingate scanner 2.1\n");
   printf("Usage: %s <network> <class> [option]\n",argv0);
   printf("Class: 1 --> A network ID <X> \n");
   printf("       2 --> B network ID <X.X> \n");
   printf("       3 --> C network ID <X.X.X> \n");
   printf(" [-c <children>]\tmaximum simultaneous children\n");
   printf(" [-t <timeout>] \tseconds before connection timeout\n");
   printf(" [-v]           \tdebug mode view the IP to scan\n\n");
   exit (EXIT_FAILURE);
}
En línea
romanflyx

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: yaws ( yet another wingate scanner)
« Respuesta #4 en: 21 Mayo 2007, 05:20 »



si tienen ubuntu feisty 7.04
cuando lo compilaba al principio me tiraba muchos errores
lo que tienen que hacer es

sudo aptitude purge gcc

y luego

sudo aptitude install gcc

luego lo compilan posicionandose en el mismo directorio donde guardaron el Gateprobe.c o el yaws.c
les va a tirar algunos errores pero funciona igual

y hacen gcc Gateprobe.c -o Gateprobe

luego  para ejecutarlo

./Gateprobe <red><clase> opcion
ejemplo:

./Gateprobe 200 1 -v
lo cual escanearia toda la red clase A de ip 200

fin
En línea
rakax


Desconectado Desconectado

Mensajes: 331


http://raka.uni.cc


Ver Perfil WWW
Re: yaws ( yet another wingate scanner)
« Respuesta #5 en: 29 Mayo 2007, 18:41 »

Buenas, que quiere decir el termino WinGate, escaner de puertos o algo asi.. :S
San google no dice nada muy claro
Saludos
En línea

Cuanto mas aprendo mas cuenta me doy de lo ignorante que soy.

www.raka.uni.cc
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines