hecky

catpcha-cracker-1.sh

May 6th, 2013
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.47 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. image="$(ls Captcha.jpg)"
  4. pixelaje=$(convert -identify $image /dev/null | awk '{print $3}')
  5. let px_x="$(echo $pixelaje | cut -d"x" -f1 | tr -d "\n")"
  6. let px_y="$(echo $pixelaje | cut -d"x" -f2 | tr -d "\n")"
  7. black="(  0,  0,  0)  #000000  black"
  8. white="(255,255,255)  #FFFFFF  white"
  9. txt_out="captcha_clean.txt"
  10.  
  11. echo -e "\t\t\e[1;4mCaptcha Cracker by \e[m\e[1;4;36m@hecky\e[m"
  12. echo -e "\n\e[1;33m[+]\e[m\e[1;35mAnalizando:\e[m "$image
  13. echo -e "\e[1;33m[+]\e[m\e[1;34mTamaño:\e[m $pixelaje px"
  14.  
  15. if [[ -e $txt_out ]];then
  16.     echo -e "\n\e[36m> $txt_out ya existe!!\n> Eliminandolo...\e[m"
  17.     rm -rf $txt_out
  18. fi
  19.  
  20. echo -e "\n\e[1;31m[*]\e[m\e[1;32mLimpiando Imagen!!\e[m"
  21. echo "# ImageMagick pixel enumeration: $px_x,$px_y,255,srgb" > $txt_out
  22.  
  23. for ((y=0;y<$px_y;y++));do
  24.     for ((x=0;x<$px_x;x++));do
  25.         rgb=$(convert "$image"[1x1+$x+$y] txt: | grep "(.*)" -wo | cut -d ")" -f1 | tr -d "(" | tr -d "\n" | tr -d " "| tr "," " ")
  26.         let r=$(echo $rgb | awk '{print $1}')
  27.         let g=$(echo $rgb | awk '{print $2}')
  28.         let b=$(echo $rgb | awk '{print $3}')
  29.  
  30.         if [[ $r -gt 100 || $g -gt 100 || $b -gt 100 ]];then
  31.             echo "$x,$y: $black" >> $txt_out
  32.         else
  33.             echo "$x,$y: $white" >> $txt_out
  34.         fi
  35.     done
  36. done
  37. convert $txt_out captcha_clean.pnm && echo -e "\e[1;31m[*]\e[m\e[1;33mImagen procesada, exitosamente!! =)\e[m" ; rm -rf $txt_out
  38. cracked=$(echo $(gocr captcha_clean.pnm))
  39. echo -e "\n<<< Captcha: \e[1;33;41m$cracked\e[m >>>"
  40. echo -e "\n\e[33;41mNeobits.org\e[m"
Add Comment
Please, Sign In to add comment