Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #!/usr/bin/env sh
  2.  
  3. [ -n "$1" ] && LOGIN=$1
  4. [ -n "$2" ] && PASSWORD=$2
  5. #JAR=$LOGIN.jar
  6. JAR=/usr/local/cookie/`date +%H%M%S`.jar
  7. TIMEOUT=5m
  8. [ -n "$3" ] && PROXY=$3
  9.  
  10. [ -z "$LOGIN" -o -z "$PASSWORD" ] \
  11. && echo 'Usage: ./lurker.sh LOGIN PASSWORD [PROXY]. You may also pass args with environment variables' >&2 \
  12. && exit 1
  13.  
  14. do_curl() {
  15. curl \
  16. -H 'Pragma: no-cache' \
  17. -H 'Origin: https://naruto-shippuuden.ru' \
  18. -H 'Accept-Language: en-US,en;q=0.9,ru;q=0.8,fil;q=0.7' \
  19. -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36' \
  20. -H 'Accept: application/xml, text/xml, */*; q=0.01' \
  21. -H 'Cache-Control: no-cache' \
  22. -H 'DNT: 1' \
  23. `[ -n "$PROXY" ] && echo --proxy "$PROXY"` \
  24. "$@"
  25. }
  26.  
  27. do_login() {
  28. do_curl https://naruto-shippuuden.ru/index/sub/ \
  29. -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
  30. -H 'Referer: https://naruto-shippuuden.ru/index/1' \
  31. -H 'X-Requested-With: XMLHttpRequest' \
  32. --data "user=$LOGIN&password=$PASSWORD&rem=1&a=2&ajax=1&rnd=226&_tp_=xml" \
  33. --cookie-jar "$JAR" \
  34. > /dev/null 2>&1
  35. }
  36.  
  37. get_main() {
  38. do_curl https://naruto-shippuuden.ru \
  39. --cookie "$JAR"
  40. }
  41.  
  42. is_request_successful() {
  43. RESPONSE=$1
  44. INDICATOR=`echo $RESPONSE | grep '.Ru</ti'`
  45. [ -n "$INDICATOR" ]
  46. }
  47.  
  48. do_request() {
  49. RESPONSE=`get_main 2>/dev/null`
  50. is_request_successful "$RESPONSE"
  51. }
  52.  
  53. # If running interactively, don't do anything
  54. case $- in
  55. *i*) return;;
  56. esac
  57.  
  58. echo 'Cookie jar file is' $JAR >&2
  59.  
  60. do_login
  61.  
  62. while :
  63. do
  64. do_request || (do_login && do_request) || (echo 'Broken' >&2; exit 1)
  65.  
  66. [ "$?" -ne 0 ] && break
  67.  
  68. sleep "$TIMEOUT"
  69. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement