Parcourir la source

* support for -s / --share

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@430 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam il y a 20 ans
Parent
révision
84b64ad5ae
10 fichiers modifiés avec 64 ajouts et 42 suppressions
  1. +5
    -3
      src/authimage.c
  2. +5
    -3
      src/clubic.c
  3. +3
    -0
      src/common.h
  4. +0
    -6
      src/filters.c
  5. +5
    -3
      src/linuxfr.c
  6. +19
    -11
      src/main.c
  7. +5
    -3
      src/phpbb.c
  8. +7
    -5
      src/slashdot.c
  9. +10
    -5
      src/test.c
  10. +5
    -3
      src/vbulletin.c

+ 5
- 3
src/authimage.c Voir le fichier

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


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


/* Main function */ /* Main function */
@@ -31,10 +31,12 @@ char *decode_authimage(struct image *img)


if(!font) if(!font)
{ {
font = image_load(FONTNAME);
char fontname[BUFSIZ];
sprintf(fontname, "%s/%s", share, FONTNAME);
font = image_load(fontname);
if(!font) if(!font)
{ {
fprintf(stderr, "cannot load font %s\n", FONTNAME);
fprintf(stderr, "cannot load font %s\n", fontname);
exit(-1); exit(-1);
} }
} }


+ 5
- 3
src/clubic.c Voir le fichier

@@ -20,7 +20,7 @@
static struct image *find_glyphs(struct image *img); static struct image *find_glyphs(struct image *img);


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


@@ -31,10 +31,12 @@ char *decode_clubic(struct image *img)


if(!font) if(!font)
{ {
font = image_load(FONTNAME);
char fontname[BUFSIZ];
sprintf(fontname, "%s/%s", share, FONTNAME);
font = image_load(fontname);
if(!font) if(!font)
{ {
fprintf(stderr, "cannot load font %s\n", FONTNAME);
fprintf(stderr, "cannot load font %s\n", fontname);
exit(-1); exit(-1);
} }
} }


+ 3
- 0
src/common.h Voir le fichier

@@ -17,6 +17,9 @@ struct image
void *priv; void *priv;
}; };


/* global variables */
extern char *share;

/* debug function */ /* debug function */
void dprintf(const char *fmt, ...); void dprintf(const char *fmt, ...);




+ 0
- 6
src/filters.c Voir le fichier

@@ -17,12 +17,6 @@
#include "config.h" #include "config.h"
#include "common.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 */ /* Functions */
void filter_flood_fill(struct image *img, int x, int y, int r, int g, int b) void filter_flood_fill(struct image *img, int x, int y, int r, int g, int b)
{ {


+ 5
- 3
src/linuxfr.c Voir le fichier

@@ -17,7 +17,7 @@
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"


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


/* Main function */ /* Main function */
@@ -33,10 +33,12 @@ char *decode_linuxfr(struct image *img)


if(!font) if(!font)
{ {
font = image_load(FONTNAME);
char fontname[BUFSIZ];
sprintf(fontname, "%s/%s", share, FONTNAME);
font = image_load(fontname);
if(!font) if(!font)
{ {
fprintf(stderr, "cannot load font %s\n", FONTNAME);
fprintf(stderr, "cannot load font %s\n", fontname);
exit(-1); exit(-1);
} }
} }


+ 19
- 11
src/main.c Voir le fichier

@@ -26,6 +26,7 @@


/* Used for the debug messages */ /* Used for the debug messages */
char *argv0 = NULL; char *argv0 = NULL;
char *share = NULL;
int debug = 1; int debug = 1;


int main(int argc, char *argv[]) int main(int argc, char *argv[])
@@ -35,6 +36,7 @@ int main(int argc, char *argv[])
int digit_optind = 0; int digit_optind = 0;


argv0 = argv[0]; argv0 = argv[0];
share = "share";


for(;;) for(;;)
{ {
@@ -43,16 +45,17 @@ int main(int argc, char *argv[])
int option_index = 0; int option_index = 0;
static struct option long_options[] = static struct option long_options[] =
{ {
{ "mode", 1, 0, 'm' },
{ "help", 0, 0, 'h' }, { "help", 0, 0, 'h' },
{ "mode", 1, 0, 'm' },
{ "share", 1, 0, 's' },
{ "quiet", 0, 0, 'q' }, { "quiet", 0, 0, 'q' },
{ "version", 0, 0, 'v' }, { "version", 0, 0, 'v' },
{ 0, 0, 0, 0 } { 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 #else
c = getopt(argc, argv, "hm:qv");
c = getopt(argc, argv, "hm:s:qv");
#endif #endif
if(c == -1) if(c == -1)
break; break;
@@ -62,15 +65,17 @@ int main(int argc, char *argv[])
case 'h': /* --help */ case 'h': /* --help */
printf("Usage: %s [OPTION]... FILE...\n", argv[0]); printf("Usage: %s [OPTION]... FILE...\n", argv[0]);
#ifdef HAVE_GETOPT_LONG #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 #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 #endif
return 0; return 0;
case 'm': /* --mode */ case 'm': /* --mode */
@@ -79,6 +84,9 @@ int main(int argc, char *argv[])
case 'q': /* --quiet */ case 'q': /* --quiet */
debug = 0; debug = 0;
break; break;
case 's': /* --quiet */
share = optarg;
break;
case 'v': /* --version */ case 'v': /* --version */
printf("pwntcha (captcha decoder) %s\n", VERSION); printf("pwntcha (captcha decoder) %s\n", VERSION);
printf("Written by Sam Hocevar.\n"); printf("Written by Sam Hocevar.\n");


+ 5
- 3
src/phpbb.c Voir le fichier

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


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


/* Main function */ /* Main function */
@@ -34,10 +34,12 @@ char *decode_phpbb(struct image *img)


if(!font) if(!font)
{ {
font = image_load(FONTNAME);
char fontname[BUFSIZ];
sprintf(fontname, "%s/%s", share, FONTNAME);
font = image_load(fontname);
if(!font) if(!font)
{ {
fprintf(stderr, "cannot load font %s\n", FONTNAME);
fprintf(stderr, "cannot load font %s\n", fontname);
exit(-1); exit(-1);
} }
} }


+ 7
- 5
src/slashdot.c Voir le fichier

@@ -25,9 +25,9 @@ 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.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; static struct image *font = NULL;


/* Global stuff */ /* Global stuff */
@@ -245,10 +245,12 @@ static struct image *find_glyphs(struct image *img)


if(!font) if(!font)
{ {
font = image_load(FONTNAME);
char fontname[BUFSIZ];
sprintf(fontname, "%s/%s", share, FONTNAME);
font = image_load(fontname);
if(!font) if(!font)
{ {
fprintf(stderr, "cannot load font %s\n", FONTNAME);
fprintf(stderr, "cannot load font %s\n", fontname);
exit(-1); exit(-1);
} }
} }


+ 10
- 5
src/test.c Voir le fichier

@@ -19,7 +19,7 @@
#include "common.h" #include "common.h"


/* Our macros */ /* Our macros */
#define FONTNAME "share/font_phpbb.png"
#define FONTNAME "font_phpbb.png"


static struct image *find_glyphs(struct image *img); 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) static struct image *find_glyphs(struct image *img)
{ {
char all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; char all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
struct image *dst;
struct image *font = image_load(FONTNAME);
struct image *dst, *font;
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, cur = 0, offset = -1; 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) 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); dst = image_new(img->width, img->height);


+ 5
- 3
src/vbulletin.c Voir le fichier

@@ -17,7 +17,7 @@
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"


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


/* Main function */ /* Main function */
@@ -31,10 +31,12 @@ char *decode_vbulletin(struct image *img)


if(!font) if(!font)
{ {
font = image_load(FONTNAME);
char fontname[BUFSIZ];
sprintf(fontname, "%s/%s", share, FONTNAME);
font = image_load(fontname);
if(!font) if(!font)
{ {
fprintf(stderr, "cannot load font %s\n", FONTNAME);
fprintf(stderr, "cannot load font %s\n", fontname);
exit(-1); exit(-1);
} }
} }


Chargement…
Annuler
Enregistrer