Browse Source

* preliminary java captcha cracker

* renamed dprintf to pwnprint to avoid conflicts.


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@1000 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 18 years ago
parent
commit
ad61008335
5 changed files with 121 additions and 21 deletions
  1. +1
    -0
      src/Makefile.am
  2. +1
    -1
      src/common.h
  3. +91
    -0
      src/java.c
  4. +26
    -19
      src/main.c
  5. +2
    -1
      src/scode.c

+ 1
- 0
src/Makefile.am View File

@@ -9,6 +9,7 @@ pwntcha_SOURCES = \
common.h \
authimage.c \
clubic.c \
java.c \
linuxfr.c \
livejournal.c \
lmt.c \


+ 1
- 1
src/common.h View File

@@ -35,7 +35,7 @@ extern char *argv0;
extern char *share;

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

/* available CAPTCHA decoders */
char *decode_authimage(struct image *img);


+ 91
- 0
src/java.c View File

@@ -0,0 +1,91 @@
/*
* java.c: decode java captchas I forgot about
* $Id$
*
* Copyright: (c) 2005 Sam Hocevar <sam@zoy.org>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Do What The Fuck You Want To
* Public License as published by Banlu Kemiyatorn. See
* http://sam.zoy.org/projects/COPYING.WTFPL for more details.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#include "config.h"
#include "common.h"

/* Main function */
char *decode_java(struct image *img)
{
struct image *tmp;
int x, y, dx, dy, best = 0, bestx, besty;
int r, g, b, r2, g2, b2, r3, g3, b3, r4, g4, b4, i, j, c;

tmp = image_dup(img);
filter_threshold(tmp, 245);

for(dy = 0; dy < 20; dy++)
{
if(dy > -5 && dy < 5)
continue;

for(dx = -20; dx < 20; dx++)
{
int good = 0;

if(dx > -5 && dx < 5)
continue;

for(y = 0; y < tmp->height - dy; y++)
{
for(x = 0; x < tmp->width; x++)
{
getpixel(tmp, x, y, &r, &g, &b);
getpixel(tmp, x + dx, y + dy, &r2, &g2, &b2);

if(r && r2)
good++;
}
}

if(good > best)
{
best = good;
bestx = dx;
besty = dy;
}
}
}

for(y = 0; y < tmp->height - besty; y++)
{
for(x = 0; x < tmp->width; x++)
{
getpixel(tmp, x, y, &r, &g, &b);
getpixel(tmp, x + bestx, y + besty, &r2, &g2, &b2);
getpixel(tmp, x - bestx, y - besty, &r3, &g3, &b3);
getpixel(tmp, x + 2 * bestx, y + 2 * besty, &r4, &g4, &b4);

if(r && r2)
{
if(r3 && r4)
setpixel(img, x, y, 0, 127, 0);
else
setpixel(img, x, y, 0, 255, 255);
}
else if(r)
setpixel(img, x, y, 0, 0, 127);
else
setpixel(img, x, y, 0, 0, 0);
}
}

image_save(img, "test.bmp");
image_free(tmp);

return NULL;
}


+ 26
- 19
src/main.c View File

@@ -121,14 +121,14 @@ int main(int argc, char *argv[])
img = image_load(argv[optind]);
if(!img)
{
dprintf("cannot load %s\n", input);
pwnprint("cannot load %s\n", input);
printf("\n");
continue;
}

count = filter_count(img);
dprintf("image size %ix%i, %i colours\n",
img->width, img->height, count);
pwnprint("image size %ix%i, %i colours\n",
img->width, img->height, count);

if(!strcmp(mode, "test"))
result = decode_test(img);
@@ -136,6 +136,8 @@ int main(int argc, char *argv[])
result = decode_authimage(img);
else if(!strcmp(mode, "clubic"))
result = decode_clubic(img);
else if(!strcmp(mode, "java"))
result = decode_java(img);
else if(!strcmp(mode, "linuxfr"))
result = decode_linuxfr(img);
else if(!strcmp(mode, "livejournal"))
@@ -158,72 +160,77 @@ int main(int argc, char *argv[])
{
if(img->width == 155 && img->height == 50)
{
dprintf("probably an authimage captcha\n");
pwnprint("probably an authimage captcha\n");
result = decode_authimage(img);
}
else if(img->width == 175 && img->height == 35)
{
dprintf("probably a livejournal captcha\n");
pwnprint("probably a livejournal captcha\n");
result = decode_livejournal(img);
}
else if(img->width == 100 && img->height == 40 && count < 6)
{
dprintf("probably a linuxfr captcha\n");
pwnprint("probably a linuxfr captcha\n");
result = decode_linuxfr(img);
}
else if(img->width == 69 && img->height == 35)
{
dprintf("probably a lmt.lv captcha\n");
pwnprint("probably a lmt.lv captcha\n");
result = decode_lmt(img);
}
else if(img->width == 208 && img->height == 26)
{
dprintf("probably a Paypal captcha\n");
pwnprint("probably a Paypal captcha\n");
result = decode_paypal(img);
}
else if(img->width == 320 && img->height == 50)
{
dprintf("probably a phpBB captcha\n");
pwnprint("probably a phpBB captcha\n");
result = decode_phpbb(img);
}
else if(img->width == 170 && img->height == 50)
{
dprintf("probably a Xanga captcha\n");
pwnprint("probably a Xanga captcha\n");
result = decode_xanga(img);
}
else if(img->height <= 40 && count < 10)
{
dprintf("probably a scode/trencaspammers captcha\n");
pwnprint("probably a scode/trencaspammers captcha\n");
result = decode_scode(img);
}
else if(img->height <= 30 && count < 100)
{
dprintf("probably a clubic captcha\n");
pwnprint("probably a clubic captcha\n");
result = decode_clubic(img);
}
else if(img->height == 69)
{
dprintf("probably a slashdot captcha\n");
pwnprint("probably a slashdot captcha\n");
result = decode_slashdot(img);
}
else if(img->width == 200 && img->height == 100)
{
pwnprint("probably a java captcha\n");
result = decode_java(img);
}
else if(img->width == 200 && img->height == 40)
{
dprintf("probably a tickets.com captcha\n");
pwnprint("probably a tickets.com captcha\n");
result = decode_tickets(img);
}
else if(img->height == 61)
{
dprintf("probably a vbulletin captcha\n");
pwnprint("probably a vbulletin captcha\n");
result = decode_vbulletin(img);
}
else if(img->width == 480 && img->height == 360 && count == 253)
{
dprintf("probably not a captcha\n");
pwnprint("probably not a captcha\n");
result = decode_easter_eggs(img);
}
else
{
dprintf("could not guess captcha type\n");
pwnprint("could not guess captcha type\n");
printf("\n");
image_free(img);
continue;
@@ -234,7 +241,7 @@ int main(int argc, char *argv[])

if(!result)
{
dprintf("sorry, decoding failed\n");
pwnprint("sorry, decoding failed\n");
printf("\n");
continue;
}
@@ -247,7 +254,7 @@ int main(int argc, char *argv[])
return 0;
}

void dprintf(const char *fmt, ...)
void pwnprint(const char *fmt, ...)
{
va_list args;



+ 2
- 1
src/scode.c View File

@@ -221,8 +221,9 @@ static char find_glyph(struct image *img, int xmin, int xmax)
case 2378: return '7';
case 5375: return '8';
case 4710: return '9';
/* quotatispro font */
default:
dprintf("don't know about checksum %i\n", count);
pwnprint("don't know about checksum %i\n", count);
return '?';
}
}


Loading…
Cancel
Save