Beispiel #1
0
extern char *BX_one_to_another (const char *what)
{
	if (isdigit(what[strlen(what)-1]) || strchr(what, ':'))
		return ip_to_host (what);
	else
		return host_to_ip (what);
}
int main(int argc, char *argv[])
{
  u_long  src_addr, dst_addr;
  int i, bs=1, port=0;
  char hostname[32];

  if (argc < 2)
    usage (argv[0]);

  gethostname (hostname, 32);
  src_addr = host_to_ip(hostname);

  while ((i = getopt (argc, argv, "s:p:h")) != EOF)
  {
    switch (i)
    {
      case 's':
        dst_addr = host_to_ip(optarg);
        if (!dst_addr)
          quit("Bad source address given.");
        break;

      case 'p':
        port = atoi(optarg);
        if ((port <=0) || (port > 65535))
          quit ("Invalid port number given.");
        break;

      case 'h':
      default:
        usage (argv[0]);
    }
  }

  dst_addr = host_to_ip(argv[argc-1]);
  if (!dst_addr)
    quit("Bad destination address given.");

  spf_sck = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
  if (!spf_sck)
    quit("socket()");
  if (setsockopt(spf_sck, IPPROTO_IP, IP_HDRINCL, (char *)&bs,
      sizeof(bs)) < 0)
    quit("IP_HDRINCL");

  do_frags (spf_sck, src_addr, dst_addr, port);
}
Beispiel #3
0
extern char *BX_one_to_another (const char *what)
{

	if (!isdigit((unsigned char)what[strlen(what)-1]))
		return host_to_ip (what);
	else
		return ip_to_host (what);
}
Beispiel #4
0
void get_nat_address(UserhostItem *stuff, char *nick, char *args)
{
char *h;
	if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN"))
		return;
	if (isdigit((unsigned char)*stuff->host))
		h = stuff->host;
	else
		h = host_to_ip(stuff->host);
	nat_address.s_addr = inet_addr(h); 
	bitchsay("using NAT address for DCC");
}
Beispiel #5
0
void boink_main(int argc, char *argv[])
{
        u_long  src_addr,
                dst_addr;

        int     i,
               /* src_prt = 55,
                  dst_prt = 55, */ 
                start_port,
                stop_port,
                bs = 1,
                pkt_count;

        if (argc < 5)
                boink_usage();

        start_port = (u_short) atoi (argv[ 3 ]);
        stop_port = (u_short) atoi (argv[ 4 ]);        
        if (argc == 6)
              pkt_count = atoi (argv[ 5 ]);
        
        
        if (start_port >= stop_port ||
            stop_port <= start_port) {
                
                start_port = 25;
                stop_port = 65;
        
        }
        
            
        if (pkt_count == 0)	pkt_count = 10;
        
        /* Resolve hostnames */

        src_addr = host_to_ip(argv[1]);
        if (!src_addr)
                quit("bad source host");
        dst_addr = host_to_ip(argv[2]);
        if (!dst_addr)
                quit("bad target host");

        spf_sck = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
        if (!spf_sck)
                quit("socket()");
        if (setsockopt(spf_sck, IPPROTO_IP, IP_HDRINCL, (char *) &bs,
        sizeof(bs)) < 0)
                quit("IP_HDRINCL");

        for (i = 0; i < pkt_count; ++i)
        {
                int j;
                
                printf ("(%d)%s:%d->%d\n", i, argv[ 2 ], start_port, stop_port);
                
                for (j = start_port; j != stop_port; j++) {
                
                 /* fondle(spf_sck, src_addr, dst_addr, src_prt, dst_prt); */
                    fondle (spf_sck, src_addr, dst_addr, j, j);

                }
                usleep(10000);
        }

        printf("Done.\n");
}
Beispiel #6
0
static int 
muse_connect( const char* host, int port )
{
    int                rsrv = INVALID_SOCKET;
    struct sockaddr_in rsrvINETAddress;
    struct sockaddr    *rsrvSockAddrPtr = NULL;
    int                selret, conret;
    struct timeval     tval = {5, 0}; 
    fd_set             rset, wset;

    rsrvSockAddrPtr = (struct sockaddr*)&rsrvINETAddress;
    memset( (char*)&rsrvINETAddress, 0, sizeof(rsrvINETAddress) );
    rsrvINETAddress.sin_family      = AF_INET;
    rsrvINETAddress.sin_addr.s_addr = host_to_ip( host );
    rsrvINETAddress.sin_port        = htons( port );
    
    rsrv = socket( AF_INET, SOCK_STREAM, 0 );
    if ( !socket_nonblock(rsrv) ) {
        close( rsrv );
        return INVALID_SOCKET;
    }

    conret = rconnect( rsrv, (struct sockaddr*)rsrvSockAddrPtr, sizeof(rsrvINETAddress) ); 
    if ( conret == 0 )
        goto ok;
    
    if ( conret < 0 && errno != EINPROGRESS ) {
        close( rsrv ); 
        return INVALID_SOCKET;
    }
    errno = 0;
    
    /* 
     * Else wait for connection.  Cannot use cfgst_microsleep 
     */
     
    FD_ZERO( &rset );
    FD_SET( rsrv, &rset );
    wset = rset; 
    selret = rselect( rsrv+1, &rset, &wset, NULL, &tval ); 
    if ( selret == 0 ) {
        close( rsrv );        /* timeout */
        errno = ETIMEDOUT;
        return INVALID_SOCKET;
    }

    if ( FD_ISSET(rsrv, &rset) || FD_ISSET(rsrv, &wset) ) {
        int error=0, optret, len=sizeof(error);
        optret = getsockopt( rsrv, SOL_SOCKET, SO_ERROR, &error, (socklen_t*)&len ); 
        if ( optret < 0 || error != 0 ) {
            /* Solaris pending error */ 
            errno = error; 
            warning("  SOL_SOCKET SO_ERROR=%d", error); 
            /*perror( "cfgst_connect" );*/
            close( rsrv );
            return INVALID_SOCKET;    
        }
    } else {
        warning("  select error: sockfd not set"); 
        close( rsrv );
        return INVALID_SOCKET;
    }
        
    if ( !socket_block(rsrv) ) {
        close( rsrv );
        return INVALID_SOCKET;
    }
ok:
    notice("Connected to %s:%d", host, port); 
    return rsrv;
}