/*
Arcturus Darkstar Enterprises Inc. 1988-2006
Darkstar WarTech Technologies
Created bY eddiewrc <eddiewrc@alice.it>
L'autore +*NON*+ può essere ++IN ALCUN MODO++ ritenuto responsabile
per eventuali danni o illegalità commesse DAL o CON il suo programma.
Il software è stato creato ed è distribuito a scopo puramente DIDATTICO.
Ne è libero l'uso, la modifica e la distribuzione finchè rimane presente
il nome del programma e il nick dell'autore. Arcturus Darkstar Enterprises...
ecc. è un nome fittizio che non fa riferimento a *NIENTE*.
*/
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <winsock.h>
#include <signal.h>
#define WSA_ERROR 0
#define INVALID_SOCK_OPERANDI 10
#define INVALID_SOCK 9
#define INVALID_IP 8
#define INVALID_NUMBERS_OF_SOCKET 7
#define INVALID_NUMBER_OF_STAR_PORT 6
#define INVALID_NUMBER_OF_FINISH_PORT 5
#define CANT_OPEN_LOG 4
int SOCK_N;
WSADATA wsaData;
SOCKADDR_IN soc;
char ip[16];
int s_p, f_p;
FILE *ofp;
int i, h, k;
void on_error_exit(int sig);
int main(void)
{
signal(SIGINT, on_error_exit);
if (WSAStartup(MAKEWORD(2,2), &wsaData))
on_error_exit(WSA_ERROR);
printf("\nArcturus Darkstar Enterprises Inc. 1988-2006");
printf("\nAD ASTRA! :: NightMare Heaven");
printf("\nInput IP of target host: ");
if (!scanf("%s", ip))
on_error_exit(INVALID_IP);
printf("\nInput the number of socket: ");
if (!scanf("%d", &SOCK_N))
on_error_exit(INVALID_NUMBERS_OF_SOCKET);
SOCKET s[SOCK_N];
int r[SOCK_N];
if (!scanf("%d", &s_p))
on_error_exit(INVALID_NUMBER_OF_STAR_PORT);
if (!scanf("%d", &f_p))
on_error_exit(INVALID_NUMBER_OF_STAR_PORT);
if (!(ofp = fopen("log.txt", "w")))
on_error_exit(CANT_OPEN_LOG);
for (i = 0; i < SOCK_N; i++)
if( !(s[i] = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP)) )
on_error_exit(INVALID_SOCK);
soc.sin_family = AF_INET;
soc.sin_addr.s_addr = inet_addr(ip);
fprintf(ofp, "\n%s\n%s\n%s\n%s\n\n",
"Arcturus Darkstar Enterprises Inc. 1988-2006",
"Darkstar WarTech Technologies",
"AD ASTRA! - Nightmare Heaven",
"Created bY eddiewrc");
for (i = s_p; i < f_p; )
{
h = i;
fprintf(ofp, "\nConnection");
for (k = 0; k < SOCK_N; k++)
{
printf("\nOpening the %d socket", k
);
soc.sin_port = htons(i++);
r[k] = connect( s[k], (SOCKADDR*) &soc, sizeof(soc) );
}
// _sleep(2);
fprintf(ofp, "\nChecking..");
for (k = 0; k < SOCK_N; k++)
{
if (r[k] == SOCKET_ERROR)
{
printf("\nProcessing Port %d; Status = CLOSE", (h
+ k
));
fprintf(ofp, "\nProcessing Port %d; Status = CLOSE", (h + k));
}
else
{
printf("\nProcessing Port %d; Status = OPEN", (h
+ k
));
fprintf(ofp, "\nProcessing Port %d; Status = OPEN", (h + k));
closesocket(s[k]);
if( !(s[k] = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP)) )
on_error_exit(INVALID_SOCK_OPERANDI);
}
}
}
getch();
return 0;
}
void on_error_exit(int sig)
{
if (sig == WSA_ERROR)
else if (sig == INVALID_SOCK_OPERANDI)
else if (sig == INVALID_SOCK)
else if (sig == INVALID_NUMBERS_OF_SOCKET)
printf("\nInvalid Numbers of Socket");
else if (sig == INVALID_NUMBER_OF_STAR_PORT)
printf("\nInvalid Number of start port");
else if (sig == INVALID_NUMBER_OF_FINISH_PORT)
printf("\nInvalid number of finish port");
else if (sig == CANT_OPEN_LOG)
{
printf("\nCan't open the log file");
printf("\nWould you (E)xit or (C)ontinue?");
if((getch()) == 'e' )
exit(0);
else
return;
}
else if (sig == SIGINT)
{
printf("\nScanning stopped. \nWould you (E)xit or (C)ontinue?");
if((getch()) == 'e' )
exit(0);
else
return;
}
getch();
exit(1);
return;
}