Copy Link
Add to Bookmark
Report

strscan2b1.c

Scans a range of ips on a given port for (string). (In our honest opinion #1)

eZine's profile picture
Published in 
In our honest opinion
 · 8 months ago

/*                 ( IOHO 2001 #og irc.ndrsnet.com )                     */ 
/* strscan.c v2b1 by ka0z@ndrsnet for IOHO E-Zine http://chickenz.net/og */
/* Basically, I made this for myself and it was suggested that I put */
/* this in the e-zine so I did. Any ideas on how to implement the */
/* multiple line banner checking would be greatly appreciated. */
/* this has been optimized with ntohl and htonl and shit like that blah */
/* blah blah blah.....ok */

#include <stdio.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>

int usage(char *);
int validip(char *);

int main(int argc, char *argv[]){
struct sockaddr_in sin;
struct in_addr addr;
unsigned long start,end;
long i;
int sock;
char buff[1024],*str,*check;

if(argc<5)
usage(argv[0]);

if(validip(argv[1]) || validip(argv[2])){
printf("you stupid jew you dont even know what the hell an ip is do you?\n");
exit(-1);
}

start=inet_addr(argv[1]);
end=inet_addr(argv[2]);

str=argv[4];

for(i=ntohl(start);i<=ntohl(end);i++){
if((i&0xff)==255)
i++;
if((i&0xff)==0)
i++;

addr.s_addr=htonl(i);

sin.sin_addr.s_addr=addr.s_addr;
sin.sin_port=htons(atoi(argv[3]));
sin.sin_family=AF_INET;

if((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0){
perror("socket");
exit(-1);
}

if(connect(sock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in))==-1)
goto err;
read(sock,buff,1024);
check=&buff[0];
if(*check == '\n')
goto err;
if(strstr(buff,str)){
printf("%s\n",inet_ntoa(addr));
fflush(stdout);
break;
}
err:
bzero((char *)&sin,sizeof(struct sockaddr_in));
bzero(buff,sizeof(buff));
close(sock);
}
exit(0);
}

int validip(char *ip){ /* props to mixter for this function :) */
int a,b,c,d,*check;
sscanf(ip,"%d.%d.%d.%d",&a,&b,&c,&d);
check=&a;
if(*check<0)
return(-1);
if(*check>255)
return(-1);
check=&b;
if(*check<0)
return(-1);
if(*check>255)
return(-1);
check=&c;
if(*check<0)
return(-1);
if(*check>255)
return(-1);
check=&d;
if(*check<0)
return(-1);
if(*check>255)
return(-1);
return(0);
}

int usage(char *p){
printf("strscan v2b1 by ka0z for IOHO\n"
"usage: %s <begin ip> <end ip> <port> <string>\n",p);
exit(-1);
}

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Recent Articles

Recent Comments

Francesco's profile picture
Francesco Arca (@Francesco)
14 Nov 2024
Congratulations :)

guest's profile picture
@guest
12 Nov 2024
It is very remarkable that the period of Atlantis’s destruction, which occurred due to earthquakes and cataclysms, coincides with what is co ...

guest's profile picture
@guest
12 Nov 2024
Plato learned the legend through his older cousin named Critias, who, in turn, had acquired information about the mythical lost continent fr ...

guest's profile picture
@guest
10 Nov 2024
الاسم : جابر حسين الناصح - السن :٤٢سنه - الموقف من التجنيد : ادي الخدمه - خبره عشرين سنه منهم عشر سنوات في كبرى الشركات بالسعوديه وعشر سنوات ...

lostcivilizations's profile picture
Lost Civilizations (@lostcivilizations)
6 Nov 2024
Thank you! I've corrected the date in the article. However, some websites list January 1980 as the date of death.

guest's profile picture
@guest
5 Nov 2024
Crespi died i april 1982, not january 1980.

guest's profile picture
@guest
4 Nov 2024
In 1955, the explorer Thor Heyerdahl managed to erect a Moai in eighteen days, with the help of twelve natives and using only logs and stone ...

guest's profile picture
@guest
4 Nov 2024
For what unknown reason did our distant ancestors dot much of the surface of the then-known lands with those large stones? Why are such cons ...

guest's profile picture
@guest
4 Nov 2024
The real pyramid mania exploded in 1830. A certain John Taylor, who had never visited them but relied on some measurements made by Colonel H ...

guest's profile picture
@guest
4 Nov 2024
Even with all the modern technologies available to us, structures like the Great Pyramid of Cheops could only be built today with immense di ...
Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT