[TOOL] IPv6 Security Scanner

From: support@securiteam.com
Date: 06/15/02


From: support@securiteam.com
To: list@securiteam.com
Date: Sat, 15 Jun 2002 21:48:21 +0200 (CEST)

The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion

When was the last time you checked your server's security?
How about a monthly report?
http://www.AutomatedScanning.com - Know that you're safe.
- - - - - - - - -

  IPv6 Security Scanner
------------------------------------------------------------------------

DETAILS

The following is a simple implementation of a security scanner that
supports the IPv6 protocol convention.

Tool code:
/*
v6scan.c
by phased
phased@snosoft.com

 ipv6 port scanner
 06/02
 
  "there be some deepmagic going on"
  
*/

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in6 structure */
#include <netdb.h> /* gethostbyname2 */

#define VERSION "1.0"

int ports[] = {
  21,
    22,
    23,
    25,
    79,
    80,
    110,
    113,
    139,
    143,
    515,
    1433,
    5000,
    6000};
  
  /* add more */
  
  int main(int argc, char *argv[]) {
    int delay, port, i;
    
    printf ("v6scan version %s\n", VERSION);
    
    if (argc < 3) {
      usage(argv[0]);
    }
    
    delay = atoi(argv[2]);
    printf(" scanning %s\n", argv[1]);
    printf(" using %i second delay\n", delay);
    printf(" checking %d ports\n", sizeof(ports)/sizeof(ports[0]));
    
    for(i=0;i<sizeof(ports)/sizeof(ports[0]);i++) {
      checkhost(argv[1], i, delay);
      sleep(delay);
    }
  }
  
  checkhost(char *host, int port) {
    int sock;
    struct sockaddr_in6 target;
    struct hostent *hostname;
    
    if (( sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0 ) {
      printf("error creating socket ipv6 may not be supported\n");
      exit(0);
    }
    
    memset((char *)&target, 0, sizeof(target));
    if ((hostname = gethostbyname2(host, AF_INET6)) == NULL) {
      printf("error gethostbyname2\n");
      exit(0);
    }
    
    target.sin6_port = htons(port);
    target.sin6_family = AF_INET6;
    memcpy((char *)&target.sin6_addr, hostname->h_addr,
hostname->h_length);
    
    if ((connect(sock,(struct sockaddr *)&target,
      sizeof(struct sockaddr_in6))) < 0) {
      close(sock);
      return(0);
    }
    else {
      printf (" connected to port %d\n", ports[port]);
    }
    close(sock);
  }
  
  int usage(char *progname) {
    printf("%s <host> <delay>\n", progname);
    exit(0);
  }

ADDITIONAL INFORMATION

The information has been provided by <mailto:phased@mail.ru> James Green.

========================================

This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

====================
====================

DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.



Relevant Pages