Procházet zdrojové kódy

* keep the font loaded across decodings.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@421 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam před 20 roky
rodič
revize
336bac428c
4 změnil soubory, kde provedl 35 přidání a 22 odebrání
  1. +8
    -5
      src/linuxfr.c
  2. +7
    -4
      src/phpbb.c
  3. +12
    -8
      src/slashdot.c
  4. +8
    -5
      src/vbulletin.c

+ 8
- 5
src/linuxfr.c Zobrazit soubor

@@ -18,6 +18,7 @@
#include "common.h"

#define FONTNAME "share/font_linuxfr.png"
static struct image *font = NULL;

/* Main function */
char *decode_linuxfr(struct image *img)
@@ -26,15 +27,18 @@ char *decode_linuxfr(struct image *img)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
char *result;
struct image *tmp, *font;
struct image *tmp;
int x, y, r, g, b, i, j, c;
int stats[40];

font = image_load(FONTNAME);
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 */
@@ -141,7 +145,6 @@ char *decode_linuxfr(struct image *img)
}

image_free(tmp);
image_free(font);

if(strlen(result) != 7)
{


+ 7
- 4
src/phpbb.c Zobrazit soubor

@@ -19,6 +19,7 @@

/* Our macros */
#define FONTNAME "share/font_phpbb.png"
static struct image *font = NULL;

/* Main function */
char *decode_phpbb(struct image *img)
@@ -26,7 +27,6 @@ char *decode_phpbb(struct image *img)
char all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
char *result;
struct image *tmp1, *tmp2, *tmp3;
struct image *font = image_load(FONTNAME);
int x, y, i = 0;
int r, g, b;
int xmin, xmax, ymin, ymax, cur, offset = -1;
@@ -34,8 +34,12 @@ char *decode_phpbb(struct image *img)

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 */
@@ -125,7 +129,6 @@ char *decode_phpbb(struct image *img)
image_free(tmp1);
image_free(tmp2);
image_free(tmp3);
image_free(font);

return result;
}


+ 12
- 8
src/slashdot.c Zobrazit soubor

@@ -18,16 +18,17 @@
#include "config.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 */
#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

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 */
struct { int xmin, ymin, xmax, ymax; } objlist[100];
@@ -237,7 +238,6 @@ static struct image *find_glyphs(struct image *img)
}
glyphs[22];
struct image *dst;
struct image *font = image_load(FONTNAME);
int x, y, i = 0;
int r, g, b;
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)
{
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);


+ 8
- 5
src/vbulletin.c Zobrazit soubor

@@ -18,21 +18,25 @@
#include "common.h"

#define FONTNAME "share/font_vbulletin.png"
static struct image *font = NULL;

/* Main function */
char *decode_vbulletin(struct image *img)
{
char all[] = "2346789ABCDEFGHJKLMNPRTWXYZ";
char *result;
struct image *tmp1, *tmp2, *tmp3, *font;
struct image *tmp1, *tmp2, *tmp3;
int limits[6] = { 26, 53, 80, 107, 134, 160 };
int x, y, r, g, b, i, j;

font = image_load(FONTNAME);
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 */
@@ -134,7 +138,6 @@ char *decode_vbulletin(struct image *img)
image_free(tmp1);
image_free(tmp2);
image_free(tmp3);
image_free(font);

return result;
}


Načítá se…
Zrušit
Uložit