Guest User

Makaba autobump (bash-written)

a guest
Jun 7th, 2016
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.62 KB | None | 0 0
  1. # ======== Copy both scripts to ~/bin ========
  2. # ======== autobump.sh ========
  3. # === Usage: ./autobump.sh bumps ===
  4. # === Effect: bumps the thread $bumps times ===
  5. #!/bin/bash
  6. antigate_key=5654233d49951a7cd2c5be2b7f0b12c0
  7. cd ~/bin
  8. if [ ! -d ./2ch-data ]; then
  9.   mkdir 2ch-data
  10. fi
  11. cd 2ch-data
  12. i=1
  13. while ((i <= $1)); do
  14.   curl -q --silent -X POST "https://2ch.hk/makaba/captcha.fcgi?type=2chaptcha" \
  15.   | tail -n 1 > captcha-id # Got captcha ID
  16.   curl -q --silent -X POST "https://2ch.hk/makaba/captcha.fcgi?type=2chaptcha&action=image&id=$(cat captcha-id)" \
  17.   > captcha.png # Got captcha pic
  18.   antigatecaptcha $antigate_key captcha.png 10 # Solved captcha
  19.   captcha_solved=$(cat captcha-answer)
  20.   # Posting:
  21.   if [[ ! $(curl -q --silent -X POST -F "json=1" -F "task=post" -F "board=s" -F "thread=1739561" -F "email=sage" -F "name=bash-autobump" -F "comment=test" -F "captcha_type=2chaptcha" -F "2chaptcha_id=`cat captcha-id`" -F "2chaptcha_value=$captcha_solved" "https://2ch.hk/makaba/posting.fcgi" | grep "Капча невалидна.") ]]
  22.   then
  23.     echo '2ch-autobump:' "$i / $1 posts."
  24.     let 'i = i + 1'
  25.   else
  26.     echo '2ch-autobump:' "Posting error: invalid captcha."
  27.   fi
  28.   rm captcha-id captcha-answer
  29. done
  30. # ======== End of autobump.sh ========
  31.  
  32. # ======== antigatecaptcha.sh ========
  33. # === Source: https://github.com/persona5/bgg/antigatecaptcha.sh ===
  34. # === Modifications: ===
  35. #     - Changed answer-getting cycle from 'while' to 'for'
  36. #     - Added answer-getting attempts parameter
  37. #     - Changed answer output method: printing to stdout -> printing to file
  38. # === Usage: ./antigatecaptcha.sh antigate-key captcha-file get-answer-attempts
  39. # === Effect: requests captcha answer at antigate.com and prints it to 'captcha-answer' file ===
  40. #!/bin/bash
  41.  
  42. antigatekey=$1
  43. filename=$2
  44. iterations=$3
  45. answer_file="captcha-answer"
  46.  
  47. antigate=$(curl -q --silent --user-agent "$useragent"  -i -X POST -H "Content-Type: multipart/form-data" -F "method=post" -F "key=$antigatekey" -F "numeric=1" -F "file=@$filename;" "http://anti-captcha.com/in.php")
  48.  
  49. if [[ $(echo "$antigate" | grep "ERROR") ]];then
  50.   exit 1
  51. else
  52.   antigatecaptchaid=$(echo "$antigate" | awk {'print$1'} | tail -c 10)
  53. fi
  54.  
  55. for i in $(seq $iterations); do
  56.   sleep 10
  57.   captchastatus=$(curl --silent -q --user-agent "$useragent" "http://anti-captcha.com/res.php?key=$antigatekey&action=get&id=$antigatecaptchaid")
  58.   if [[ $(echo "$captchastatus" | grep 'OK|') ]]; then
  59.     break
  60.   fi
  61. done
  62.  
  63. captchaanswer=$(echo "$captchastatus" | sed -e 's/OK|//g')
  64. rm captcha.png
  65. echo $captchaanswer>$answer_file
  66. exit 0
  67. ======== End of antigatecaptcha.sh ========
Advertisement
Add Comment
Please, Sign In to add comment