Captcha Cracker For PHPBB written in Ruby

0
948

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

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here