Tool for scanning networks which generates an list of IP addresses between a starting and ending ip.
a1f8e25c3c7b61b129cb7c4fbb6f06e931da51c972b3ad396b0a0c01d00403d2
/*
2000 .[.I.m.p.e.r.f.e.c.t.i.o.n.]. 2000
Imperfection Security Team presents range.
A tool that outputs every IP per IP range.
A gift from shake (shake@linuxstart.com)
Usage: ./range 127.0.0.0 127.2.0.255 >file
Hellos: unknown, dayve, syntax, tom, blitz,
justin, vicci, wolf, punish, kindred, alg.
Can be used with stdin scanners, or other fine tools.
*/
#include <stdio.h>
#include <string.h>
void usage(void) {
fprintf(stderr, "\n.[.I.m.p.e.r.f.e.c.t.i.o.n.].\n");
fprintf(stderr, "imp-range.c (v1.0) by shake\n");
fprintf(stderr, "Echos every IP in a specified range.\n\n");
fprintf(stderr, "Usage:\t./range <LowerIpRange> <HigherIpRange>\n");
fprintf(stderr, "E.G.:\t./range 3.1.33.7 3.1.35.255 >ipdb.txt\n\n");
fflush(stderr);
}
int main(int argc, char *argv[])
{
char *lowhost, *hihost;
/* option parsing */
unsigned int la, lb, lc, ld, ln;
unsigned int ha, hb, hc, hd, hn;
unsigned int laddr[4], haddr[4];
if (argc != 3) {
usage();
return 1;
}
lowhost = argv[1];
hihost = argv[2];
ln=sscanf(lowhost, "%u.%u.%u.%u", &la, &lb, &lc, &ld);
hn=sscanf(hihost, "%u.%u.%u.%u", &ha, &hb, &hc, &hd);
if (ln != 4 || hn != 4) {
fprintf(stderr, "WTF KIND OF IP ADDRESS IS THAT?!?!? (%s :: %s)", lowhost, hihost);
return 1;
}
laddr[0] = la; haddr[0] = ha;
laddr[1] = lb; haddr[1] = hb;
laddr[2] = lc; haddr[2] = hc;
laddr[3] = ld; haddr[3] = hd;
while (laddr[0] <= haddr[0]) {
while (laddr[1] <= haddr[1]) {
while (laddr[2] <= haddr[2]) {
if ((const int)haddr[3] == 255) {
while ((const int)laddr[3] <= 255) {
/* output class c's .. */
printf("%u.%u.%u.%u\n", laddr[0], laddr[1], laddr[2], laddr[3]);
++laddr[3];
}
fflush(stdout);
}
else if (laddr[3] <= haddr[3]) {
while (laddr[3] <= haddr[3]) {
printf("%u.%u.%u.%u\n", laddr[0], laddr[1], laddr[2], laddr[3]);
++laddr[3];
}
}
laddr[3]=0;
++laddr[2];
}
laddr[2]=0;
++laddr[1];
}
laddr[1]=0;
++laddr[0];
}
fflush(stdout);
return 0;
}