what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

gatescan.c

gatescan.c
Posted Aug 17, 1999
Authored by misteri0

gatescan.c is a class B/C Wingate scanner with several command line options. This version features a log-to-file option and code cleanup. Based on bong's gateprobe.c.

tags | tool, scanner
SHA-256 | 4a52954645f8f428f5330bd1290f7eb6eb1a38dc394012ef610370cf8b6ead30

gatescan.c

Change Mirror Download
/*************************[GateScan.C]************************** 
* Based on the bong's code <-- helped a shitload *
* added... *
* - cleaned the code up a little bit *
* - now logs all wingate servers *
* [MAJOR PROPS GO TO:] *
* codesearc, ]{ewl, Punk182, Nforcer, bong, S-y-S *
* #ehforce@unet, #c@unet, Sslash, as2r|azz, funkey *
* [ANTI PROPS GO TO:[I've got my reasons...]] *
* #fts(2) <-- never really liked them :P *
* #wicked, Ellison, fuCKfaCe (Don't have many enemies...)*
*************************[GateScan.C]**************************
*/


#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
#define cl ""
#define mag ""
#define cyn ""
#define wht ""
#define hbl ""
#define hmag ""
#define hcyn ""
#define hwh ""

void ShowHelp(char *, char *);
void ShowVer()
{
fprintf(stderr, "[%sG%sateScan%s.%sC%s[%smisteri0%s%s@%sunet]]\n",cyn,mag,hbl,cyn,cl,hwh,cl,cyn,cl);
}
int ConnectCheck(struct sockaddr_in, int, int);

const char *ipv4_ntop(int, const void *, char *, size_t);
const char *ipv4_showname(int , const void *, char *, size_t);

FILE *stream; /* Declare the Ol' FILE STREAM */

int main(int argc, char *argv[]) {
int i,j=0,status,Children=128,Timeout=7,Resolve=0,class=0;
char DestIP[15],*NetworkID,c,*num3;
struct sockaddr_in DestAddress;
if(argc < 3) ShowHelp(argv[0], "");
NetworkID = argv[1];
num3=argv[2];
class=atoi(num3);
opterr = 0;
while((c = getopt(argc, argv, "Rp:C:t:")) != -1) {
switch(c) {
case 'R': Resolve = -1; break;
case 'C': Children = atoi(optarg); break;
case 't': Timeout = atoi(optarg); break;
case '?': ShowHelp(argv[0], "ERROR: unrecognized option"); break;
}
}
if(Children < 1) ShowHelp(argv[0], "ERROR: invalid number of children");
if(Timeout < 1) ShowHelp(argv[0], "ERROR: invalid timeout");
ShowVer();
if (class==1)
fprintf(stderr, "Scanning %s.*.*:23 children:%i, timeout:%i\n\n",
NetworkID,Children, Timeout);
if (class==2)
fprintf(stderr, "Scanning %s.*:23 children:%i, timeout:%i\n\n",NetworkID, Children, Timeout);
DestAddress.sin_family = AF_INET;
DestAddress.sin_port = htons(23);
if (class==1){
for(j = 0; j < 256; j++) {
for(i = 0; i < Children; i++) {
sprintf(DestIP, "%s.%d.%d", NetworkID,j, i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout, Resolve);
}
for(i = Children + 1; i < 256; i++) {
wait(&status); /* wait till a child dies to make another */
sprintf(DestIP, "%s.%d.%d", NetworkID,j, i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout, Resolve);
}
}
}
if (class==2){
for(i = 0; i < Children; i++) {
sprintf(DestIP, "%s.%d", NetworkID, i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout, Resolve);
}
for(i = Children + 1; i < 256; i++) {
wait(&status); /* wait till a child dies to make another */
sprintf(DestIP, "%s.%d", NetworkID, i);
inet_aton(DestIP, &DestAddress.sin_addr);
if(!fork()) ConnectCheck(DestAddress, Timeout, Resolve);
}
for(;;) {
if((waitpid(-1, &status, WNOHANG) == -1) && (errno == ECHILD))
exit(EXIT_SUCCESS);
}
}
}

int ConnectCheck(struct sockaddr_in DestAddr, int Timeout, int Resolve)
{
int result,ret,SocketFD;
char Hostname[60],buffer1[64];
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)))
{
stream = fopen("wingatelist.txt","a");
printf("Wingate found: %s\n\a",ipv4_ntop(AF_INET,&DestAddr.sin_addr.s_addr,Hostname,59));
fprintf(stream,"%s\n",ipv4_ntop(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) {
errno = ENOSPC;
return(NULL);
}
strcpy(strptr, temp);
return(strptr);
}
errno = EAFNOSUPPORT;
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 {
errno = EAFNOSUPPORT;
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, char *ErrMsg) {
ShowVer();
printf("Based bong's <bong26@hotmail.com> code\n");
printf("Output of wingate servers will be written in wingatelist.txt\n");
printf("Usage: %s <network> <class> [option]\n",argv0);
printf(" class: 1) class b network ID <x.x> \n");
printf(" 2) class c network ID <x.x.x>\n");
printf(" [-C <children>]\tmaximum simultaneous children\n");
printf(" [-t <timeout>] \tseconds before connection timeout\n\n");
exit (EXIT_FAILURE);
}
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close