Anyone got some C code that loops over all used IP addresses? Can you come up with any special optimizations? (I need to handle them in the "%u.%u.%u.%u"-form; computations are independant and can be run in parallel)
Name:
Anonymous2009-03-03 5:34
Here's the code I already had, by the way:
for (a = 58; a < 223; ++a) {
if (a == 100) { a = 107; continue; }
if (a == 127) continue;
if (a == 175) { a = 177; continue; }
if (a == 179) { a = 183; continue; }
if (a == 185) continue;
for (b = 0; b < 256; ++b) {
for (c = 0; c < 256; ++c) {
for (d = 1; d < 255; ++d) {
SHA1_Init(&ctx);
sprintf(prefix1, "%u.%u.%u.%u", a, b, c, d);
SHA1_Update(&ctx, prefix1, strlen(prefix1));
SHA1_Update(&ctx, prefix2, 12);
SHA1_Update(&ctx, salt, 448);
SHA1_Final(md, &ctx);
if (memcmp(search, md, sizeof(search)) == 0)
goto done;
}
}
}
printf("%u/8 done.\n", a);
}