User Contributed - Captcha Breaking W/ PHPBB2 Example
This is a fantastic guest post by Harry over at DarkSEO Programming. His blog has some AWESOME code examples and tutorials along with an even deeper explanation of this post so definitely check it out and subscribe so he’ll continue blogging.
This post is a practical explanation of how to crack phpBB2 easily. You need to know some basic programming but 90% of the code is written for you in free software.
Programs you Need
C++/Visual C++ express edition - On Linux everything should compile simply. On windows everything should compile simply, but it doesn’t always (normally?). Anyway the best tool I found to compile on windows is Visual C++ express edition. Download
GOCR - this program takes care of the character recognition. Also splits the characters up for us . It’s pretty easy to do that manually but hey. Download
ImageMagick - this comes with Linux. ImageMagick lets us edit images very easily from C++, php etc. Install this with the development headers and libraries. Download from here
A (modified) phpbb2 install - phpBB2 will lock you out after a number of registration attempts so we need to change a line in it for testing purposes. After you have it all working you should have a good success rate and it will be unlikely to lock you out. Find this section of code: (it’s in includes/usercp_register.php)
if ($row = $db->sql_fetchrow($result))
{
if ($row['attempts'] > 3)
{
message_die(GENERAL_MESSAGE, $lang['Too_many_registers']);
}
}
$db->sql_freeresult($result);
Make it this: if ($row = $db->sql_fetchrow($result))
{
//if ($row[’attempts’] > 3)
//{
// message_die(GENERAL_MESSAGE, $lang[’Too_many_registers’]);
//}
}
$db->sql_freeresult($result);
Possibly a version of php and maybe apache web server on your desktop PC. I used php to automate the downloading of the captcha because it’s very good at interpreting strings and downloading static web pages.
Getting C++ Working First
The problem on windows is there is a vast number of C++ compilers, and they all need setting up differently. However I wrote the programs in C++ because it seemed the easiest language to quickly edit images with ImageMagick. I wanted to use ImageMagick because it allows us to apply a lot of effects to the image if we need to remove different types of backgrounds from the captcha.
Once you’ve installed Visual C++ 2008 express (not C#, I honestly don’t know if C# will work) you need to create a Win32 Application. In the project properties set the include path to something like (depending on your imagemagick installation) C:\Program Files\ImageMagick-6.3.7-Q16\include and the library path to C:\Program Files\ImageMagick-6.3.7-Q16\lib. Then add these to your additional library dependencies CORE_RL_magick_.lib CORE_RL_Magick++.lib CORE_RL_wand.lib. You can now begin typing the programs below.
If that all sounds complicated don’t worry about it. This post covers the theory of cracking phpBB2 as well. I just try to include as much code as possible so that you can see it in action. As long as you understand the theory you can code this in php, perl, C or any other language. I’ve compiled a working program at the bottom of this post so you don’t need to get it all working straight away to play with things.
Getting started
Ok this is a phpBB2 captcha:

It won’t immediately be interpreted by GOCR because GOCR can’t work out where the letters start and end. Here’s the weakness though. The background is lighter than the text so we can exclude it by getting rid of the lighter colors. With ImageMagick we can do this in a few lines of C++. Type the program below and compile/run it and it will remove the background. I’ll explain it below.
using namespace Magick;
int main( int /argc/, char ** argv)
{
// Initialize ImageMagick install location for Windows
InitializeMagick(*argv);
// load in the unedited image
Image phpBB("test.png");
// remove noise
phpBB.threshold(34000);
// save image
phpBB.write("convert.pnm");
return(1);
}
All this does is loads in the image, and then calls the function threshold attached to the image. Threshold filters out any pixels below a certain darkness. On linux you have to save the image as a .png however on windows GOCR will only read .pnm files so on linux we have to put the line instead:
// save image
phpBB.write("convert.png");
The background removed.
Ok that’s one part sorted. Problem 2. We now have another image that GOCR won’t be able to tell where letters start and end. It’s too grainy. What we notice though is that each unjoined dot in a letter that is surrounded by dots 3 pixels away should probably be connected together. So I add a piece of code onto the above program that looks 3 pixels to the right and 3 pixels below. If it finds any black dots it fills in the gaps. We now have chunky letters. GOCR can now identify where each letter starts and ends . We’re pretty much nearly done.
using namespace Magick;
void fill_holes(PixelPacket * pixels, int cur_pixel, int size_x, int size_y)
{
int max_pixel, found;
///////////// pixels to right /////////////////////
found = 0;
max_pixel = cur_pixel+3; // the furthest we want to search
// set a limit so that we can't go over the end of the picture and crash
if(max_pixel>=size_x*size_y)
max_pixel = size_x*size_y-1;
// first of all are we a black pixel, no point if we are not
if(*(pixels+cur_pixel)==Color("black"))
{
// start searching from the right backwards
for(int index=max_pixel; index>cur_pixel; index--)
{
// should we be coloring?
if(found)
*(pixels+index)=Color("black");
if(*(pixels+index)==Color(“black”))
found=1;
}
}
///////////// pixels to bottom /////////////////////
found = 0;
max_pixel = cur_pixel+(size_x*3);
if(max_pixel>=size_x*size_y)
max_pixel = size_x*size_y-1;
if(*(pixels+cur_pixel)==Color(“black”))
{
for(int index=max_pixel; index>cur_pixel; index-=size_x)
{
// should we be coloring?
if(found)
*(pixels+index)=Color("black");
if(*(pixels+index)==Color(“black”))
found=1;
}
}
}
int main( int /argc/, char ** argv)
{
// Initialize ImageMagick install location for Windows
InitializeMagick(*argv);
// load in the unedited image
Image phpBB("test.png");
// remove noise
phpBB.threshold(34000);
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Beef up “holey” parts
/////////////////////////////////////////////////////////////////////////////////////////////////////
phpBB.modifyImage(); // Ensure that there is only one reference to
// underlying image; if this is not done, then the
// image pixels *may* remain unmodified. [???]
Pixels my_pixel_cache(phpBB); // allocate an image pixel cache associated with my_image
PixelPacket* pixels; // 'pixels' is a pointer to a PixelPacket array
// define the view area that will be accessed via the image pixel cache
// literally below we are selecting the entire picture
int start_x = 0;
int start_y = 0;
int size_x = phpBB.columns();
int size_y = phpBB.rows();
// return a pointer to the pixels of the defined pixel cache
pixels = my_pixel_cache.get(start_x, start_y, size_x, size_y);
// go through each pixel and if it is black and has black neighbors fill in the gaps
// this calls the function fill_holes from above
for(int index=0; index
fill_holes(pixels, index, size_x, size_y);
// now that the operations on my_pixel_cache have been finalized
// ensure that the pixel cache is transferred back to my_image
my_pixel_cache.sync();
// save image
phpBB.write("convert.pnm");
return(1);
}
I admit this looks complicated on first view. However you definitely don’t have to do this in C++ though if you can find an easier way to perform the same task. All it does is remove the background and join close dots together.
I’ve given the C++ source code because that’s what was easier for me, however the syntax can be quite confusing if you’re new to C++. Especially the code that accesses blocks of memory to edit the pixels. This is more a study of how to crack the captcha, but in case you want to code it in another language here’s the general idea of the algorithm that fills in the holes in the letters:
-
Go through each pixel in the picture. Remember where we are in a variable called cur_pixel
-
Start three pixels to the right of cur_pixel. If it’s black color the pixels between this position and cur_pixel black.
-
Work backwards one by one until we reach cur_pixel again. If any pixels we land on are black then color the space in between them and cur_pixel black.
-
Go back to step 1 until we’ve been through every pixel in the picture
NOTE: Just make sure you don’t let any variables go over the edge of the image otherwise you might crash your program.
I used the same algorithm but modified it slightly so that it also looked 3 pixels below, however the steps were exactly the same.
Training GOCR
The font we’re left with is not recognized natively by GOCR so we have to train it. It’s not recognized partly because it’s a bit jagged.
Assuming our cleaned up picture is called convert.pnm and our training data is going to be stored in a directory call data/ we’d type this.
gocr -p ./data/ -m 256 -m 130 convert.pnm
Just make sure the directory data/ exists (and is empty). I should point out that you need to open up a command prompt to do this from. It doesn’t have nice windows. Which is good because it makes it easier to integrate into php at a later date.
Any letters it doesn’t recognize it will ask you what they are. Just make sure you type the right answer. -m 256 means use a user defined database for character recognition. -m 130 means learn new letters.
You can find my data/ directory in the zip at the end of this post. It just saves you the time of going through checking each letter and makes it all work instantly.
Speeding it up
Downloading, converting, and training for each phpbb2 captcha takes a little while. It can be sped up with a simple bit of php code but I don’t want to make this post much longer. You’ll find my script at the end in my code package. The php code runs from the command prompt though by typing “php filename.php”. It’s sort of conceptual in the sense that it works, but it’s not perfect.
Done
Ok once GOCR starts getting 90% of the letters right we can reduce the required accuracy so that it guesses the letters it doesn’t know.
Below I’ve reduced the accuracy requirement to 25% using -a 25. Otherwise GOCR prints the default underscore character even for slightly different looking characters that have already been entered. -m 2 means don’t use the default letter database. I probably could have used this earlier but didn’t. Ah well, it doesn’t do a whole lot.
gocr -p ./data/ -m 256 -m 2 -a 25 convert.pnm
We can get the output of gocr in php using:
echo exec(”/full/path/gocr -p ./data/ -m 256 -m 2 -a 25 convert.pnm”);
Alternatives
In some instances you may not have access to GOCR or you don’t want to use it. Although it should be usable if you have access to a dedicated server. In this case I would separate the letters out manually and resize them all to the same size. I would then put them through a php neural network which can be downloaded from here FANN download
It would take a bit of work but it should hopefully be as good as using GOCR. I don’t know how well each one reacts to letters which are rotated though. Neural networks simply memorize patterns. I haven’t checked the inner workings of GOCR. It looks complicated.
My code
All the code can be found here to crack phpBB2 captcha.
In conclusion to this tutorial it’s a nightmare trying to port over all my code from linux to windows unless it’s written in Java . If only Java was small and quick as well.
It’s worth stating that phpbb2 was easy to crack because the letters didn’t touch or overlap. If they had touched or overlapped it would probably have been very hard to crack.
I plan to look at that line and square captcha that comes with phpBB3 over on my site and document how secure it is.
Thanks for the awesome guest post Harry.
Comments (181)
These comments were imported from the original blog. New comments are closed.
gmail captchas have been broken by spammers,
heise.de reports. They have detection rates of 20-30%!
How do they archive that?
yep nice. thx for the guest post.
best regards
Regarding your comment “if Java would be only…” - have a look at Groovy. It runs in the JVM (thus as a normal java application) and “feels” like PHP or other nice scripting languages.
And you get the power of the whole Java API, third party libraries and so on. After all, thanks for your informative post!
Hello guys! Its me, mario!
I just want to say that your site is amazing!
Good luck!
Live within your income, even if you have to borrow to do so.
– Josh Billings —————————————————————————————————-
Hello, I’m newer here and stopping in to say hi.
I hope everyone has a good day. Jaeric
test
tnx for delete this post!
Nice article about captchas but some captchas are really difficult to crack..what you say about it?
Naruto Ninja
Hi, I think its a gread stuff.
Thanks for the good tutorial. By,
Holger
Good Day Just wanted to share my new experience. If your system denies to run due to an error corresponding to missing HAL.DLL, invalid Boot.ini or any other important system boot files you can repair this by using the XP installation CD. Just boot from your XP Setup CD and enter the Recovery Console. Then run “attrib -H -R -S” on the C:\Boot.ini file and remove it. Launch “Bootcfg /Rebuild” and then Fixboot Cheers,
Carl
I began this thread to evaluate public usable web proxies: Which are really anonymous? Which can be used with facebook, myspace etc, in other words: are fresh ? Which can you recommend? Thanks for your help,
Dschibut P.S.: In my country, the freedom of speech is somehow constrained, please give me a hint, if you are not sure about your recommendation.
I know this is a little off-topic but this video is truly relevant to anyone in the civilized world who has money, a home or any form of business.employment:
How has this information not come to light before? I hope the media gives this the attention it deserves!
Hi! I want to extend my SQL knowledge.
I red really many SQL resources and want to
read more about SQL for my occupation as oracle database manager. What can you recommend? Thanks,
Werutz
Hello I hve been hearing lately about credit repairing companies ande the amount of work they get in their business . One of my sister is running a creditt repair business, I have talked to him about the business but. I need mor information on this so that I can start my own credit repair business .
Please do sugest your views on this! Chudi
I have a question for you or anyone else who wants to address this: I know of several folks who have decided to stop contributing to their 401k’s and other retirement accounts and start putting that money towards paying down their mortgage. Right now I put $250/paycheck into my retirement fund, and yet my balance is less than it was six months ago. Is it smarter to just keep with the traditional wisdom of investing the same amount no matter how the market is going, or is a diversion into debt reduction a smart move? FYI I’m about 15 miles out from retirement.
What do you think?
Laura Kauffmann
“Seven Oceans Investments Club”
Реально суперское место, мне тут понравилось, правда…
Столько всего суперского и позновательного, я тут задержусь на долго.
Test message
Sorry me noob…
There was this guy see.
He wasn’t very bright and he reached his adult life without ever having learned “the facts”.
Somehow, it gets to be his wedding day.
While he is walking down the isle, his father tugs his sleeve and says, “Son, when you get to the hotel room…Call me” Hours later he gets to the hotel room with his beautiful blushing bride and he calls his father, “Dad, we are the hotel, what do I do?” “O.K. Son, listen up, take off your clothes and get in the bed, then she should take off her clothes and get in the bed, if not help her. Then either way, ah, call me” A few moments later… “Dad we took off our clothes and we are in the bed, what do I do?” O.K. Son, listen up. Move real close to her and she should move real close to you, and then… Ah, call me.” A few moments later… “DAD! WE TOOK OFF OUR CLOTHES, GOT IN THE BED AND MOVED REAL CLOSE, WHAT DO I DO???” “O.K. Son, Listen up, this is the most important part. Stick the long part of your body into the place where she goes to the bathroom.” A few moments later… “Dad, I’ve got my foot in the toilet, what do I do?”
check out this all new online application , it lets you create your own online id……. came across it yesterday and instantly became a fan of it……..
very easy to use and there is so much we can do with it……check it out yourself , its awesome…
I have a flash site
i’m looking for the script who of google ads on flash.
where can i get it?
Problema ultimi driver nvidia?allora ho un portatiel acer travelmate 2490. e ho comprato il modem sitecom 54g turbo perche quelll delalice che avevo non aveva il wifi.
quando cerco di conneterlo mi dice stato connesso la velociota 54mgps
e i byte ricevuti e inviati ma quando cerco di conneterlo dice connesione a miniport wan fallita. il modem ha la luce del wi/fi lampeggia e di cloore arancione. quando provo a conneterlo con il cavo ethernet non mi si collega. quando lo collego con il modem del alice vado alla pagina che inizia con 192 e mi chiede la nick e la pas io mett admin come ce scritto nel manuale e non funzia. 10 punti al migliore [img][/img]
Hi I’m a working for last 20 years as a Sales professional across various verticals like pharma, fmcg, construction & telecom. Can somebody suggest some good company/website where I can get assistance for professional services in executive job search?
Thanks
sextir.com is a free porn site - We provide the world with free: porn videos,porn movies,xxx free movies,free porn,free sex.
Best porn hub and tube on the web
Good script and its function work details,
thanks
I guess it was only a matter of time before the internets found a way to quantify my dismal abilities with the
opposite sex. I got a score of 33%, meaning im a “below average lover” Anyone out there as bad as me?
here’s the quiz:
Hello folks, I just went akross this awesome forum through google and I like the especialy this form. I really like the design and the team does its job verry good.
I´m Andrew and I´m pleased to be here Greetings
sextir.com is a free porn site - We provide the world with free: porn videos,porn movies,xxx free movies,free porn,free sex.
Best porn hub and tube on the web
hi..all
i have the same question Anime asked..
How well does this Captchas code work?
sextir.com is a free porn site - We provide the world with free: porn videos,porn movies,xxx free movies,free porn,free sex.
Best porn hub and tube on the web
Great stuff brian!
Looking forward to more in-depth strategies.
sextir.com is a free porn site - We provide the world with free: porn videos,porn movies,xxx free movies,free porn,free sex.
Best porn hub and tube on the web
I have recently lost a good amount of weight using acai berry and colon cleanse pills and have created a blog documenting my use of it.
However, I would also like to try out the Wu-Yi weight loss teas and document my progress with that as well.
The problem is i have heard some bad things about these teas. Has anyone tried them? Did you suffer from any of the side effects?
I have recently lost a good amount of weight using acai berry and colon cleanse pills and have created a blog documenting my use of it.
However, I would also like to try out the Wu-Yi weight loss teas and document my progress with that as well.
The problem is i have heard some bad things about these teas. Has anyone tried them? Did you suffer
I have recently lost a good amount of weight using acai berry and colon cleanse pills and have created a blog documenting my use of it.
However, I would also like to try out the Wu-Yi weight loss teas and document my progress with that as well.
The problem is i have heard some bad things about these teas.
I have recently lost a good amount of weight using acai berry and colon cleanse pills and have created a blog documenting my use of it.
However, I would also like to try out the Wu-Yi weight loss teas and document my progress with that as well.
The problem is i have heard some bad things about
I have recently lost a good amount of weight using acai berry and colon cleanse pills and have created a blog documenting my use of it.
However, I would also like to try out the Wu-Yi weight loss teas and document my progress with that as well.
I have recently lost a good amount of weight using acai berry and colon cleanse pills and have created a blog documenting my use of it.
However, I would also like to try out the Wu-Yi weight
Nothing seems to be easier than seeing someone whom you can help but not helping.
I suggest we start giving it a try. Give love to the ones that need it.
God will appreciate it.
yep nice. thx for the guest post.
best regards
Thank You Myspace Comments, Thanks and Thank You Graphics and comment phrases for myspace and other community websites. “Thanks for everything”, “Thank you very much”, “Thanks a Bunch”, “Thanks, you rock” and more.
Hello everyone. The coldest winter I ever spent was a summer in San Francisco. Help me! Please help find sites for: Cotton shower curtain. I found only this - retro curtain info. Some of the latest shower curtains even have convenient pockets to keep lotions, clean look of polished brass to the retro look of brushed nickel, you sure to. Ruffle blue white shower curtain pc towel vintage retro lt willow green bathroom soap dish. Waiting for a reply , Yaro from Comoros.
I think the girl’s name is Cinderella, but i haven’t found any info about her.
She either might have changed her name or she is out of the biz. This clip is worth the download.
If you like skinny girls…this is the one!
Enjoy…… link:
Hi, it’s a job offer. (Sorry if I post it in wrong place) Cyprus company is seeking a Campaign Executive to assist with fundraising, presentations, various administrative and sales management duties. If you have fundraising and sales experience, plus intermediate computer knowledge, this job is for you! Apply with us today! All applicants applying for U.S. job openings must be authorized to work in the United States. All applicants applying for European job openings must be authorized to work in European Union. We are growing advertising and consulting company offering job opportunities ranging from executive and administrative assistants to customer service representatives, receptionists and general support. NOTICE: we do not provide relocation, this position is online based, we are using progressive online administrative system. You will have to use a special online training program for free. Requirements and skills:
Higher Education/College
1 + Sales/Management (desired but optional)
Strong communicative skills
Must have MS Office installed (MS Word)
Must have citizenship or Work Permit
Adult age Education and Experience:
Internet/MS Office/Outlook
Sales/Management/Marketing courses (desired) Hours:
Mon-Fri; 9:30am - 12:30pm Apply for this job now or contact our online branch support for additional information: CV to e-mail [email protected]
I am not sure if I really understood your article.
Can I apply it to a wordpress or drupal blog?
Hello.
I’m new there
Nice forum!
Новый способ давления на кандидата на пост Главы г. Химки Новый способ “наказать” тех, кто посмел участвовать в выборной кампании не на стороне действующей власти изобрели правоохранительные органы г.о. Химки.
Руководствуясь не нормой закона, а чьей-то “волей” сотрудники милиции решили “проверить” все фирмы, внесшие денежные средства в избирательный фонд неудобных кандидатов.
Начались “проверки” с телефонных звонков - где директор, сколько человек работает на фирме. После чего последовали “письма счастья” с просьбой предоставить всю бухгалтерскую документацию, учредительные документы фирмы, и даже, план экспликации БТИ.
Такие запросы химкинским фирмам рассылает 1 отдел Оперативно-розыскной части № 9 Управления по налоговым преступлениям ГУВД Московской области за подписью начальника подполковника милиции Д.В. Языкова.
И всё это в то время, когда Президент дал прямое указание правоохранительным органам о прекращении всех незаконных проверок малого и среднего бизнеса. С это целью внесены изменения в Федеральный закон “О милиции” - из статьи 11 этого закона исключены пункты 25 и 35, на основании которых ранее правоохранительные органы имели право проверять финансово-хозяйственную деятельность предприятий.
Видно, об изменениях действующего законодательства местные правоохранительные органы не уведомлены. И не смотрят телепередачи с выступлениями Президента.
Может быть, эта публикация подвигнет их к исполнению указаний Президента, а также к изучению и соблюдению действующего законодательства
Hey… sorry for my english, where I can [b]download XRumer 5.0 Palladium FOR FREE[/b]??? Thanks!!!
It’s perfect software for promo and SEO, but cant find any crack for it((
cracked XRumer 2.9 and XRumer 3.0 are too old, Im need FRESH!
x
x
x
x
madafakerimpresarionte
Never underestimate the power of the internet. An increasing number of people use the internet
to search for a business or service so having a web presence is an important media for promoting
your company. Web design is a real skill and if your website is to not only look good but work well,
it should be constructed by a professional web designer. If you are interested, you can contact me: hqwebdesign (AT) gmail (DOT) com
Hi Everyone,
I have a carpet cleaning business in Houston,TX that was doing pretty good until the economy went bad, and with it my clientele. I have a website for the business but I dont
know what I have to do the get it to show up in a search. Right now it’s somewhere in the yahoo/google netherworld (LOL). Is there someone on here that can give me some insight or know of anyone that coud give me insight on how I can get my local website on the front
page of a Yahoo or Google search to increase my business without it costing me 5 or 10k $$$? If so please share with me. I thank you and my hungry over-eating children thank you. thanks,
I found the best thing to my sister’s birthday… It’s really hard to find cool and still unique.
So today I saw this thing from ZTARLET on facebook where you can name a real star in the sky and have the certificate and a teddy bear sent to you and pay it by a single SMS. So awesome