git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@421 92316355-f0b4-4df1-b90c-862c8a59935fmaster
@@ -18,6 +18,7 @@ | |||||
#include "common.h" | #include "common.h" | ||||
#define FONTNAME "share/font_linuxfr.png" | #define FONTNAME "share/font_linuxfr.png" | ||||
static struct image *font = NULL; | |||||
/* Main function */ | /* Main function */ | ||||
char *decode_linuxfr(struct image *img) | char *decode_linuxfr(struct image *img) | ||||
@@ -26,15 +27,18 @@ char *decode_linuxfr(struct image *img) | |||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||||
"0123456789"; | "0123456789"; | ||||
char *result; | char *result; | ||||
struct image *tmp, *font; | |||||
struct image *tmp; | |||||
int x, y, r, g, b, i, j, c; | int x, y, r, g, b, i, j, c; | ||||
int stats[40]; | int stats[40]; | ||||
font = image_load(FONTNAME); | |||||
if(!font) | if(!font) | ||||
{ | { | ||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
font = image_load(FONTNAME); | |||||
if(!font) | |||||
{ | |||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
} | |||||
} | } | ||||
/* linuxfr captchas have 7 characters */ | /* linuxfr captchas have 7 characters */ | ||||
@@ -141,7 +145,6 @@ char *decode_linuxfr(struct image *img) | |||||
} | } | ||||
image_free(tmp); | image_free(tmp); | ||||
image_free(font); | |||||
if(strlen(result) != 7) | if(strlen(result) != 7) | ||||
{ | { | ||||
@@ -19,6 +19,7 @@ | |||||
/* Our macros */ | /* Our macros */ | ||||
#define FONTNAME "share/font_phpbb.png" | #define FONTNAME "share/font_phpbb.png" | ||||
static struct image *font = NULL; | |||||
/* Main function */ | /* Main function */ | ||||
char *decode_phpbb(struct image *img) | char *decode_phpbb(struct image *img) | ||||
@@ -26,7 +27,6 @@ char *decode_phpbb(struct image *img) | |||||
char all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; | char all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; | ||||
char *result; | char *result; | ||||
struct image *tmp1, *tmp2, *tmp3; | struct image *tmp1, *tmp2, *tmp3; | ||||
struct image *font = image_load(FONTNAME); | |||||
int x, y, i = 0; | int x, y, i = 0; | ||||
int r, g, b; | int r, g, b; | ||||
int xmin, xmax, ymin, ymax, cur, offset = -1; | int xmin, xmax, ymin, ymax, cur, offset = -1; | ||||
@@ -34,8 +34,12 @@ char *decode_phpbb(struct image *img) | |||||
if(!font) | if(!font) | ||||
{ | { | ||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
font = image_load(FONTNAME); | |||||
if(!font) | |||||
{ | |||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
} | |||||
} | } | ||||
/* phpBB captchas have 6 characters */ | /* phpBB captchas have 6 characters */ | ||||
@@ -125,7 +129,6 @@ char *decode_phpbb(struct image *img) | |||||
image_free(tmp1); | image_free(tmp1); | ||||
image_free(tmp2); | image_free(tmp2); | ||||
image_free(tmp3); | image_free(tmp3); | ||||
image_free(font); | |||||
return result; | return result; | ||||
} | } | ||||
@@ -18,16 +18,17 @@ | |||||
#include "config.h" | #include "config.h" | ||||
#include "common.h" | #include "common.h" | ||||
static struct image *count_objects(struct image *img); | |||||
static struct image *rotate(struct image *img); | |||||
static struct image *cut_cells(struct image *img); | |||||
static struct image *find_glyphs(struct image *img); | |||||
/* Our macros */ | /* Our macros */ | ||||
#define FACTOR 1 | #define FACTOR 1 | ||||
#define FONTNAME "share/font_slashdot.png" // use with 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.png" // use with FACTOR = 2 | ||||
//#define FONTNAME "share/font_dilated.png" // use with FACTOR = 2 | //#define FONTNAME "share/font_dilated.png" // use with FACTOR = 2 | ||||
static struct image *count_objects(struct image *img); | |||||
static struct image *rotate(struct image *img); | |||||
static struct image *cut_cells(struct image *img); | |||||
static struct image *find_glyphs(struct image *img); | |||||
static struct image *font = NULL; | |||||
/* Global stuff */ | /* Global stuff */ | ||||
struct { int xmin, ymin, xmax, ymax; } objlist[100]; | struct { int xmin, ymin, xmax, ymax; } objlist[100]; | ||||
@@ -237,7 +238,6 @@ static struct image *find_glyphs(struct image *img) | |||||
} | } | ||||
glyphs[22]; | glyphs[22]; | ||||
struct image *dst; | struct image *dst; | ||||
struct image *font = image_load(FONTNAME); | |||||
int x, y, i = 0; | int x, y, i = 0; | ||||
int r, g, b; | int r, g, b; | ||||
int xmin, xmax, ymin, ymax, incell = 0, count = 0, startx = 0, cur = 0; | int xmin, xmax, ymin, ymax, incell = 0, count = 0, startx = 0, cur = 0; | ||||
@@ -245,8 +245,12 @@ static struct image *find_glyphs(struct image *img) | |||||
if(!font) | if(!font) | ||||
{ | { | ||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
font = image_load(FONTNAME); | |||||
if(!font) | |||||
{ | |||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
} | |||||
} | } | ||||
dst = image_new(img->width, img->height); | dst = image_new(img->width, img->height); | ||||
@@ -18,21 +18,25 @@ | |||||
#include "common.h" | #include "common.h" | ||||
#define FONTNAME "share/font_vbulletin.png" | #define FONTNAME "share/font_vbulletin.png" | ||||
static struct image *font = NULL; | |||||
/* Main function */ | /* Main function */ | ||||
char *decode_vbulletin(struct image *img) | char *decode_vbulletin(struct image *img) | ||||
{ | { | ||||
char all[] = "2346789ABCDEFGHJKLMNPRTWXYZ"; | char all[] = "2346789ABCDEFGHJKLMNPRTWXYZ"; | ||||
char *result; | char *result; | ||||
struct image *tmp1, *tmp2, *tmp3, *font; | |||||
struct image *tmp1, *tmp2, *tmp3; | |||||
int limits[6] = { 26, 53, 80, 107, 134, 160 }; | int limits[6] = { 26, 53, 80, 107, 134, 160 }; | ||||
int x, y, r, g, b, i, j; | int x, y, r, g, b, i, j; | ||||
font = image_load(FONTNAME); | |||||
if(!font) | if(!font) | ||||
{ | { | ||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
font = image_load(FONTNAME); | |||||
if(!font) | |||||
{ | |||||
fprintf(stderr, "cannot load font %s\n", FONTNAME); | |||||
exit(-1); | |||||
} | |||||
} | } | ||||
/* vBulletin captchas have 6 characters */ | /* vBulletin captchas have 6 characters */ | ||||
@@ -134,7 +138,6 @@ char *decode_vbulletin(struct image *img) | |||||
image_free(tmp1); | image_free(tmp1); | ||||
image_free(tmp2); | image_free(tmp2); | ||||
image_free(tmp3); | image_free(tmp3); | ||||
image_free(font); | |||||
return result; | return result; | ||||
} | } | ||||