home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hackers Toolkit v2.0
/
Hackers_Toolkit_v2.0.iso
/
HTML
/
archive
/
Porting
/
unix
/
domscan.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-11-04
|
3KB
|
110 lines
/**********************************
* Domain Scanner v2.0 *
* by HoGs HeaD *
* Fixed up the screwy stuff. *
* (C)1998 HoGs HeaD *
* You may not modify and *
* then redistribute *
* this source. *
*********************************/
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <errno.h>
#include <netdb.h>
#include <signal.h>
void brk(int no){
printf("^C Interrupt!\n");
exit(1);
}
void main(int argc, char **argv)
{
struct hostent *host; /* init stuff */
struct sockaddr_in sa;
int net, error;
int port=23, i, done=0;
char *curr_ip, *del, *cm[100];
int A1, A2, A3, A4;
int B1, B2, B3, B4;
int C1, C2, C3, C4;
printf("\nDomain Scanner v2.0 by HoGs HeaD\nHit any key to end.\n");
if(argc < 3){
printf("Usage: domscan ip_begin ip_end port\nwhere ip_start equals the
beginning IP(ie 127.26.26.1)\nand ip_end equals the ending IP(ie 147.26.27.12)\
nand port is the port to check on\n\n");
exit(0);
}
signal(SIGINT, brk);
if(argv[3]==NULL){
}else{
port=atoi(argv[3]);
}
/* Parse in the first Ip.... */
curr_ip=argv[1];
del=(char *)strtok(curr_ip, ".");
A1=atoi(del);
del=(char *)strtok(NULL, ".");
A2=atoi(del);
del=(char *)strtok(NULL, ".");
A3=atoi(del);
del=(char *)strtok(NULL, ".");
A4=atoi(del);
/* Read in Second Ip... */
curr_ip = argv[2];
del=(char *)strtok(curr_ip, ".");
B1=atoi(del);
del=(char *)strtok(NULL, ".");
B2=atoi(del);
del=(char *)strtok(NULL, ".");
B3=atoi(del);
del=(char *)strtok(NULL, ".");
B4=atoi(del);
/* We're finished parsing, now onto the actual scan... */
C1=A1;
C2=A2; /* SaVe DeM VaLueS! */
C3=A3;
C4=A4;
for(A4=C4;A4<=B4; A4++){
for(A3=C3;A3<=B3; A3++){
for(A2=C2;A2<=C2; A2++){
for(A1=C1;A1<=B1; A1++){
sprintf(curr_ip, "%d.%d.%d.%d", A1, A2, A3, A4); /* build the
ip */
if( ( fork() ) == 0){ /* fork a chi
ld */
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = inet_addr(curr_ip);
sa.sin_port = htons(port); /* socket is
set and... */
net = socket(AF_INET, SOCK_STREAM, 0); /* create socket */
if(net < 2){
exit(2);
}
alarm(5); /* wait 5 sec
onds until we cancel connection */
error = connect(net, (struct sockaddr *)&sa, sizeof sa); /* attempt co
nnection */
error < 0 ? printf("Error connecting to: %s %s\n", curr_ip, strerror(errno)) : printf("Connection success at: %s\n", curr_ip);
shutdown(net, 2); /* disconne
ct socket */
exit(0); /* exit chi
ld process */
}
}
}
}
}
gets((char *)i); /* Wait for enter to be pressed to exit */
}