git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@430 92316355-f0b4-4df1-b90c-862c8a59935fmaster
@@ -18,7 +18,7 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#define FONTNAME "share/font_authimage.png" | |||
#define FONTNAME "font_authimage.png" | |||
static struct image *font = NULL; | |||
/* Main function */ | |||
@@ -31,10 +31,12 @@ char *decode_authimage(struct image *img) | |||
if(!font) | |||
{ | |||
font = image_load(FONTNAME); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||
@@ -20,7 +20,7 @@ | |||
static struct image *find_glyphs(struct image *img); | |||
/* Our macros */ | |||
#define FONTNAME "share/font_clubic.png" | |||
#define FONTNAME "font_clubic.png" | |||
static struct image *font = NULL; | |||
char *result; | |||
@@ -31,10 +31,12 @@ char *decode_clubic(struct image *img) | |||
if(!font) | |||
{ | |||
font = image_load(FONTNAME); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||
@@ -17,6 +17,9 @@ struct image | |||
void *priv; | |||
}; | |||
/* global variables */ | |||
extern char *share; | |||
/* debug function */ | |||
void dprintf(const char *fmt, ...); | |||
@@ -17,12 +17,6 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
/* Our macros */ | |||
#define FACTOR 1 | |||
//#define FONTNAME "share/font.png" // use with FACTOR = 2 | |||
//#define FONTNAME "share/font_dilated.png" // use with FACTOR = 2 | |||
#define FONTNAME "share/font_dilated_half.png" // use with FACTOR = 1 | |||
/* Functions */ | |||
void filter_flood_fill(struct image *img, int x, int y, int r, int g, int b) | |||
{ | |||
@@ -17,7 +17,7 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#define FONTNAME "share/font_linuxfr.png" | |||
#define FONTNAME "font_linuxfr.png" | |||
static struct image *font = NULL; | |||
/* Main function */ | |||
@@ -33,10 +33,12 @@ char *decode_linuxfr(struct image *img) | |||
if(!font) | |||
{ | |||
font = image_load(FONTNAME); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||
@@ -26,6 +26,7 @@ | |||
/* Used for the debug messages */ | |||
char *argv0 = NULL; | |||
char *share = NULL; | |||
int debug = 1; | |||
int main(int argc, char *argv[]) | |||
@@ -35,6 +36,7 @@ int main(int argc, char *argv[]) | |||
int digit_optind = 0; | |||
argv0 = argv[0]; | |||
share = "share"; | |||
for(;;) | |||
{ | |||
@@ -43,16 +45,17 @@ int main(int argc, char *argv[]) | |||
int option_index = 0; | |||
static struct option long_options[] = | |||
{ | |||
{ "mode", 1, 0, 'm' }, | |||
{ "help", 0, 0, 'h' }, | |||
{ "mode", 1, 0, 'm' }, | |||
{ "share", 1, 0, 's' }, | |||
{ "quiet", 0, 0, 'q' }, | |||
{ "version", 0, 0, 'v' }, | |||
{ 0, 0, 0, 0 } | |||
}; | |||
c = getopt_long(argc, argv, "hm:qv", long_options, &option_index); | |||
c = getopt_long(argc, argv, "hm:s:qv", long_options, &option_index); | |||
#else | |||
c = getopt(argc, argv, "hm:qv"); | |||
c = getopt(argc, argv, "hm:s:qv"); | |||
#endif | |||
if(c == -1) | |||
break; | |||
@@ -62,15 +65,17 @@ int main(int argc, char *argv[]) | |||
case 'h': /* --help */ | |||
printf("Usage: %s [OPTION]... FILE...\n", argv[0]); | |||
#ifdef HAVE_GETOPT_LONG | |||
printf(" -m, --mode force operating mode\n"); | |||
printf(" -q, --quiet do not print information messages\n"); | |||
printf(" -h, --help display this help and exit\n"); | |||
printf(" -v, --version output version information and exit\n"); | |||
printf(" -m, --mode <mode> force operating mode\n"); | |||
printf(" -s, --share <dir> specify shared dir\n"); | |||
printf(" -q, --quiet do not print information messages\n"); | |||
printf(" -h, --help display this help and exit\n"); | |||
printf(" -v, --version output version information and exit\n"); | |||
#else | |||
printf(" -m force operating mode\n"); | |||
printf(" -q do not print information messages\n"); | |||
printf(" -h display this help and exit\n"); | |||
printf(" -v output version information and exit\n"); | |||
printf(" -m <mode> force operating mode\n"); | |||
printf(" -s <dir> specify shared dir\n"); | |||
printf(" -q do not print information messages\n"); | |||
printf(" -h display this help and exit\n"); | |||
printf(" -v output version information and exit\n"); | |||
#endif | |||
return 0; | |||
case 'm': /* --mode */ | |||
@@ -79,6 +84,9 @@ int main(int argc, char *argv[]) | |||
case 'q': /* --quiet */ | |||
debug = 0; | |||
break; | |||
case 's': /* --quiet */ | |||
share = optarg; | |||
break; | |||
case 'v': /* --version */ | |||
printf("pwntcha (captcha decoder) %s\n", VERSION); | |||
printf("Written by Sam Hocevar.\n"); | |||
@@ -18,7 +18,7 @@ | |||
#include "common.h" | |||
/* Our macros */ | |||
#define FONTNAME "share/font_phpbb.png" | |||
#define FONTNAME "font_phpbb.png" | |||
static struct image *font = NULL; | |||
/* Main function */ | |||
@@ -34,10 +34,12 @@ char *decode_phpbb(struct image *img) | |||
if(!font) | |||
{ | |||
font = image_load(FONTNAME); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||
@@ -25,9 +25,9 @@ static struct image *find_glyphs(struct image *img); | |||
/* Our macros */ | |||
#define FACTOR 1 | |||
#define FONTNAME "share/font_slashdot.png" // use with FACTOR = 1 | |||
//#define FONTNAME "share/font.png" // use with FACTOR = 2 | |||
//#define FONTNAME "share/font_dilated.png" // use with FACTOR = 2 | |||
#define FONTNAME "font_slashdot.png" // use with FACTOR = 1 | |||
//#define FONTNAME "font.png" // use with FACTOR = 2 | |||
//#define FONTNAME "font_dilated.png" // use with FACTOR = 2 | |||
static struct image *font = NULL; | |||
/* Global stuff */ | |||
@@ -245,10 +245,12 @@ static struct image *find_glyphs(struct image *img) | |||
if(!font) | |||
{ | |||
font = image_load(FONTNAME); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||
@@ -19,7 +19,7 @@ | |||
#include "common.h" | |||
/* Our macros */ | |||
#define FONTNAME "share/font_phpbb.png" | |||
#define FONTNAME "font_phpbb.png" | |||
static struct image *find_glyphs(struct image *img); | |||
@@ -61,8 +61,7 @@ char *decode_test(struct image *img) | |||
static struct image *find_glyphs(struct image *img) | |||
{ | |||
char all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; | |||
struct image *dst; | |||
struct image *font = image_load(FONTNAME); | |||
struct image *dst, *font; | |||
int x, y, i = 0; | |||
int r, g, b; | |||
int xmin, xmax, ymin, ymax, incell = 0, count = 0, cur = 0, offset = -1; | |||
@@ -70,8 +69,14 @@ static struct image *find_glyphs(struct image *img) | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
exit(-1); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||
dst = image_new(img->width, img->height); | |||
@@ -17,7 +17,7 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#define FONTNAME "share/font_vbulletin.png" | |||
#define FONTNAME "font_vbulletin.png" | |||
static struct image *font = NULL; | |||
/* Main function */ | |||
@@ -31,10 +31,12 @@ char *decode_vbulletin(struct image *img) | |||
if(!font) | |||
{ | |||
font = image_load(FONTNAME); | |||
char fontname[BUFSIZ]; | |||
sprintf(fontname, "%s/%s", share, FONTNAME); | |||
font = image_load(fontname); | |||
if(!font) | |||
{ | |||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||
fprintf(stderr, "cannot load font %s\n", fontname); | |||
exit(-1); | |||
} | |||
} | |||