|
-
July 23rd, 2004, 05:40 AM
#1
Member
why?!!?
I keep gettingcompiling errors and i don't know why. the source code is copied directly from the book and as far as i can tell there aren't any errors. i'm using dev c++ as a compiler.
here's the code:
/*******************************************************\
* Password Probability Matrix * File: ppm_gen.c *
*********************************************************
* *
* Author: John Erickson <[email protected]> *
* Organization: Phiral Research Laboratories *
* *
* This is the generate program for the PPM proof of *
* concept. It generates a file called 4char.ppm, which *
* contains information regarding all possible 4 *
* character passwords salted with 'je'. This file can *
* be used to quickly crack passwords found within this *
* keyspace with the corresponding ppm_crack.c program. *
* *
\*******************************************************/
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define HEIGHT 16384
#define WIDTH 1129
#define DEPTH 8
#define SIZE HEIGHT * WIDTH * DEPTH
int singleval(char a)
{
int i, j;
i= (int)a;
if((i >= 46) && (i <= 57))
j = i - 46;
else if ((i >= 97) && (i <= 122))
j = i - 59;
return j;
}
int tripleval(char a, char b, char c)
{
return (((singleval(c)%4)*4096)+(singleval(a)*64)+singleval(b));
}
main()
{
char *plain;
char *code;
char *data;
int i, j, k, l;
unsigned int charval, val;
FILE *handle;
if (!(handle = fopen("4char.ppm", "w")))
{
printf("Error: Couldn't open file '4char.ppm' for writing.\n");
exit(1);
}
data = (char *) malloc(SIZE+19);
if (!(data))
{
printf("Error Couldn't allocate memory.\n");
exit(1);
}
plain = data+SIZE;
code = plain+5;
for(i=32; i<127; i++)
{
for(j=32; j<127; j++)
{
print("Adding %c%c** to 4char.ppm..\n", i, j);
for(k=32; k<127; k++)
{
for(l=32; l<127; l++)
{
plain[0] = (char)i;
plain[1] = (char)j;
plain[2] = (char)k;
plain[3] = (char)l;
plain[4] = 0;
code =crypt(plain, "je");
val = tripleval(code[2], code[3], code[4]);
charval = (i-32)*95 + (j-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT * 4);
charval = (k-32)*95 + (l-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val = HEIGHT + tripleval(code[4], code[5], code[6]);
charval = (i-32)*95 + (j-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT * 4);
charval = (k-32)*95 + (l-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val = (2 * HEIGHT) + tripleval(code[6], code[7], code[8]);
charval = (i-32)*95 + (j-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT * 4);
charval = (k-32)*95 + (l-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val = (3 * HEIGHT) + tripleval(code[8], code[9], code[10]);
charval = (i-32)*95 + (j-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
val += (HEIGHT * 4);
charval = (k-32)*95 + (l-32);
data[(val*WIDTH)+(charval/8)] |= (1<<(charval%8));
}
}
}
}
printf("finished.. saving..\n");
fwrite(data, SIZE, 1, handle);
free(data);
fclose(handle);
}
i know that the program is supposed to be used to crack passwords. it's an exercise in the book Hacking: The Art of Exploitation by Jon Erickson. these the errors that i get:
ln: message:
[warning]in function 'main'
83 [warning]assignment makes pointer without a cast
[warning]in function 'main'
[link error]undefined reference to 'print'
[link error]undefined reference to 'crypt'
any help that can be given on resolving these errors would be awesome! Thanks!
-=[the]Punisher=-
\"People should not be afraid of their governments. Governments should be afraid of their people.\" - V
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|