James Bachini

Captcha Cracker For PHPBB written in Ruby

It’s been a while since I’ve done much in SEO so I am going to start publishing some of my old scripts. This is a captcha cracker which uses gocr and image magick to decipher phpbb captchas. It’s written in ruby and was designed as part of a backlink building module. You’ll need linux, gocr, ruby and imagemagick to run it. apt-get is your friend.

It works by first cleaning up the image and making it more decipherable. You can then build a gocr library to work with designed arround whichever font/captcha you are working with.

#!/usr/bin/env ruby
class Array; def sum; inject( nil ) { |sum,x| sum ? sum+x : x }; end; end

def getcaptcha (capfile)

$capfile = capfile
$capfile2 = $capfile.gsub(‘.png’, ‘2.png’)
system ‘convert ‘ + $capfile + ‘ -crop 320×70+15+145 -colorspace Gray -gaussian-blur 9.0 -level 0,60%,0,1 -paint 1 -depth 1 -quality 100 ‘ + $capfile2

datafile = File.dirname(__FILE__) + ‘/data/’
lista = ‘gocr -p ‘ + datafile + ‘ -m 256 -m 2 -a 25 ‘ + $capfile2
listares = IO.popen(lista)
res = listares.readlines.to_s
res.chomp!
res = res.gsub(‘ ‘, ”).gsub(‘.’, ”)

puts ”
puts ‘—————————————————–‘
puts ‘- Captcha Found: ‘ + res
puts ‘—————————————————–‘

system ‘rm ‘ + $capfile
system ‘rm ‘ + $capfile2
return res

end

def getcaptchamax (capfile)

$capfile = capfile
$capfile2 = $capfile.gsub(‘.png’, ‘c.png’)
system ‘convert ‘ + $capfile + ‘ -crop 320×70+0+0 -colorspace Gray -gaussian-blur 9.0 -level 0,60%,0,1 -paint 1 -depth 1 -quality 100 ‘ + $capfile2

datafile = File.dirname(__FILE__) + ‘/data/’
lista = ‘gocr -p ‘ + datafile + ‘ -m 256 -m 2 -a 25 ‘ + $capfile2
listares = IO.popen(lista)
res = listares.readlines.to_s
res.chomp!
res = res.gsub(‘ ‘, ”).gsub(‘.’, ”)

puts ”
puts ‘—————————————————–‘
puts ‘- Captcha Found: ‘ + res
puts ‘—————————————————–‘

return res

end

 


Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.


Posted

in

by