hecky

captcha-cracker-neobits.sh

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