exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

httpscan-v200.c

httpscan-v200.c
Posted Oct 29, 1999
Authored by Skemet

Httpscan scans web servers for version and server type. Takes input from a file. Changes for v2.01 some options for diferent ports and logging.

tags | web, cgi
systems | unix
SHA-256 | 268a19441c98246ffbf87210f0606717f7ffe3a3b95105583f44e79bb6424512

httpscan-v200.c

Change Mirror Download
/*
This is just a little proggie to scan the www server for their
server type and version.

I cannot and will not be held responsible nor legally bound for the
malicious activities of individuals who come into possession of this

[29.10.99] - v2.01 some options for diferent ports and logging
[03.10.99] - v1.02 some lame segmentation faults fixed :\
[20.09.99] - v1.01 added the option for mass scan

*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>

#define ERROR -1
#define OK 0
#define MAXDATASIZE 300
#define MESSAGE "HEAD / HTTP/1.0\n\n"
#define DATE "[29.10.99]"
#define VERSION "v2.00"

typedef struct t // structure of control of options
{
int multi;
int single;
int log;
int port;
int run;
} t_ctrl;



/* Function prototypes */
char *GetHTTP(int s,char *); // funtion that scans the host
void usage(); // usage of program
void log(char str[MAXDATASIZE]); // logging function
void scanning(); // starts the scan

/* Global Vars */

t_ctrl control;
char filename[MAXDATASIZE];
char host[MAXDATASIZE];
char *result;
char logfile[MAXDATASIZE];
char name[MAXDATASIZE];

void main(int argc,char *argv[])
{
char c;

int i=0;

/**** Initializing the control for defaults ***/
strcpy(name,argv[0]);
control.single=OK;
control.multi=ERROR;
control.log=ERROR;
control.port=80;
control.run=ERROR;

if (argc<=1)
usage();

while ((c=getopt(argc,argv,"s:vf:p:l:"))!= -1)
{
switch(c)
{
case 'f': strncpy(filename,optarg,MAXDATASIZE);
control.single=ERROR;
control.multi=OK;
control.run=OK;
break;
case 'p': control.port=atoi(optarg);
control.run=OK;
break;
case 'l': strncpy(logfile,optarg,MAXDATASIZE);
control.log=OK;
control.run=OK;
break;
case 's': strncpy(host,optarg,MAXDATASIZE);
control.run=OK;
break;
case 'v': usage();
break;
case '?': usage();
break;

}

}
if (control.run==OK)
scanning();
}




void scanning()
{
FILE *in;
int s;

if ((control.multi==OK) && (control.single==ERROR) )
{
if ((in=fopen(filename, "r+"))==NULL)
{
printf("Error: Unable to open IP file\n");
exit(1);
};

while (!feof(in))
{
memset(host,0,MAXDATASIZE);
fscanf(in,"%s",host);

if ((s=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
printf("ERROR: socket() failed\n");
exit(0);
};
printf("\nServer: %s\n",host);

result=(char *) GetHTTP(s,host);
if (control.log==OK)
{
log(host);
log(result);
}
printf("%s",result);

};
fclose(in);
}

if ((control.multi==ERROR) && (control.single==OK))
{
if ((s=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
printf("ERROR: socket() failed\n");
exit(0);
};

printf("SERVER: %s\n",host);
printf("%s\n",GetHTTP(s,host));
exit(0);
}
else
{
usage();
}
};


char *GetHTTP(int s,char *host)
{
char *p;
int i;
int numbytes;
static char buf[MAXDATASIZE];

struct sockaddr_in sock;
struct hostent *he;


if ((he=gethostbyname(host)) == NULL)
{
perror("gethostbyname()");
exit(1);
}

sock.sin_family = AF_INET;
sock.sin_port = htons(control.port);
sock.sin_addr = *((struct in_addr *)he->h_addr);
bzero(&(sock.sin_zero), 8);

if (connect(s, (struct sockaddr *)&sock, sizeof(struct sockaddr)) == ERROR)
{
perror("connect()");
}
else
if ((send(s, MESSAGE, strlen(MESSAGE), 0)) == ERROR)
perror("send()");
else
if ((numbytes=recv(s, buf, MAXDATASIZE, 0)) == ERROR)
perror("recv()");

close(s);
return buf;
}

void usage()
{
printf("\n%s %s\n",name,VERSION);
printf("\nCoded By SkeMet");
printf("\n%s",DATE);
printf("\n\nusage:");
printf("\n -s ip");
printf("\n -f filename");
printf("\n -p port number (default 80)");
printf("\n -l log file name (not enabled))");
printf("\n\nCoded by Skemet, U might fool many people but U can't fool your self!\n\n");
exit(0);
};

void log(char str[MAXDATASIZE])
{
FILE *fd;

if ((fd=fopen(logfile,"a"))==NULL)
{
perror("Error fopen()");
fprintf(stderr,"Not Logging!!!!!");
return;
};

fprintf(fd,"\n%s",str);
fclose(fd);
}






Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close