Browse Source

* bugfixes in the linuxfr captcha decoder, and new control.txt

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@420 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 20 years ago
parent
commit
60c710a115
2 changed files with 77 additions and 78 deletions
  1. +21
    -22
      src/linuxfr.c
  2. +56
    -56
      testsuite/linuxfr/control.txt

+ 21
- 22
src/linuxfr.c View File

@@ -76,8 +76,8 @@ char *decode_linuxfr(struct image *img)
* each line; they're base column candidates */ * each line; they're base column candidates */
for(x = 0; x < img->width - 9 * 7 + 1; x++) for(x = 0; x < img->width - 9 * 7 + 1; x++)
{ {
int xcan = 1;
for(c = 0; c < 7; c++, xcan)
int goodx = 1;
for(c = 0; c < 7 && goodx; c++)
{ {
for(j = 3; j < 10; j++) for(j = 3; j < 10; j++)
{ {
@@ -94,50 +94,49 @@ char *decode_linuxfr(struct image *img)
} }
if(count < 2) if(count < 2)
{ {
xcan = 0;
goodx = 0;
break; break;
} }
} }
} }
if(!xcan)
if(!goodx)
continue; continue;


/* Now we have an (x,y) candidate - try to fit 7 characters */ /* Now we have an (x,y) candidate - try to fit 7 characters */
for(c = 0; c < 7; c++, xcan)
for(c = 0; c < 7 && goodx; c++)
{ {
int r2, g2, b2, test, tcan;
for(test = 0; test < 62; test++)
int r2, g2, b2, ch;
int minerror = INT_MAX;
for(ch = 0; ch < 62; ch++)
{ {
tcan = 1;
for(j = 0; j < 12; j++, tcan)
int error = 0, goodch = 1;
for(j = 0; j < 12 && goodch; j++)
for(i = 0; i < 8; i++) for(i = 0; i < 8; i++)
{ {
getpixel(tmp, x + c * 9 + i, y + j, &r, &g, &b); getpixel(tmp, x + c * 9 + i, y + j, &r, &g, &b);
getpixel(font, test * 9 + i, j, &r2, &g2, &b2);
getpixel(font, ch * 9 + i, j, &r2, &g2, &b2);
/* Only die if font is black and image is white */ /* Only die if font is black and image is white */
if(r > r2) if(r > r2)
{ {
tcan = 0;
goodch = 0;
break; break;
} }
else if(r < r2)
error++;
} }
if(tcan)
if(goodch && error < minerror)
{ {
result[c] = all[test];
minerror = error;
result[c] = all[ch];
result[c+1] = '\0'; result[c+1] = '\0';
break;
} }
} }
if(!tcan)
{
xcan = 0;
break;
}
if(minerror == INT_MAX)
goodx = 0;
} }
if(xcan)
{
/* Wow, that was a good guess! Exit this loop */
if(goodx)
break; break;
}
} }
} }




+ 56
- 56
testsuite/linuxfr/control.txt View File

@@ -3,98 +3,98 @@ egcXvmd
PjFvqau PjFvqau
KUhuaDs KUhuaDs
DmwLiUH DmwLiUH
DuLcaHf
DyLcaWf
CSaNFLl CSaNFLl
vGwzWNE vGwzWNE
zoCucuh zoCucuh
WjikOBC WjikOBC
BbEOaSs
wSeAkuu
hjbHvin
xOmBzlq
BbEQaSs
wSeAkyu
hjbNvin
xQmBzIq
McCUroO McCUroO
TFdmmiK TFdmmiK
gkHaGEK gkHaGEK
XzfqbuS
BFlOzwq
XzfqbyS
BRTOzwq
NFDBmfm NFDBmfm
qzzDilT
qzzDiIT
ZdusZnh ZdusZnh
PmhzZPL
AOeCsPD
PmhzZRL
AOeGsRD
btZGKnl btZGKnl
wpfVpai wpfVpai
rtDPugJ
PvspMJO
PKFrJTX
EVbKlUM
TOXOzuY
pFbSBTD
rtDRygJ
RvspMJO
RKHrJTX
EVbKIUM
TQXQzuY
pHbSBTD
ZkFVWhk ZkFVWhk
CBlSCkh
CBISCkh
MpjaaDq MpjaaDq
vouZvvk vouZvvk
GOucaYn
phPtpdq
GQycaYn
phRtpdq
VmGnfZC VmGnfZC
JSEVPZH
BtqpOUC
ZlLWZWu
DXYndfL
JSEVPZN
BtqpQUC
ZTLWZWy
DXYndfN
fqqhGYL fqqhGYL
GEnJVJH GEnJVJH
xfHJsBV xfHJsBV
XuOuFjt
XuQyFjt
HLqjlza HLqjlza
MhwutaO
JugmBlc
FcmLZFu
MhwytaO
JugmBIc
FcmLZFy
JuaocqJ JuaocqJ
VvFfSdT VvFfSdT
muAASFU
jmvPflE
lnusBSe
u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