Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env sh
- [ -n "$1" ] && LOGIN=$1
- [ -n "$2" ] && PASSWORD=$2
- #JAR=$LOGIN.jar
- JAR=/usr/local/cookie/`date +%H%M%S`.jar
- TIMEOUT=5m
- [ -n "$3" ] && PROXY=$3
- [ -z "$LOGIN" -o -z "$PASSWORD" ] \
- && echo 'Usage: ./lurker.sh LOGIN PASSWORD [PROXY]. You may also pass args with environment variables' >&2 \
- && exit 1
- do_curl() {
- curl \
- -H 'Pragma: no-cache' \
- -H 'Origin: https://naruto-shippuuden.ru' \
- -H 'Accept-Language: en-US,en;q=0.9,ru;q=0.8,fil;q=0.7' \
- -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36' \
- -H 'Accept: application/xml, text/xml, */*; q=0.01' \
- -H 'Cache-Control: no-cache' \
- -H 'DNT: 1' \
- `[ -n "$PROXY" ] && echo --proxy "$PROXY"` \
- "$@"
- }
- do_login() {
- do_curl https://naruto-shippuuden.ru/index/sub/ \
- -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
- -H 'Referer: https://naruto-shippuuden.ru/index/1' \
- -H 'X-Requested-With: XMLHttpRequest' \
- --data "user=$LOGIN&password=$PASSWORD&rem=1&a=2&ajax=1&rnd=226&_tp_=xml" \
- --cookie-jar "$JAR" \
- > /dev/null 2>&1
- }
- get_main() {
- do_curl https://naruto-shippuuden.ru \
- --cookie "$JAR"
- }
- is_request_successful() {
- RESPONSE=$1
- INDICATOR=`echo $RESPONSE | grep '.Ru</ti'`
- [ -n "$INDICATOR" ]
- }
- do_request() {
- RESPONSE=`get_main 2>/dev/null`
- is_request_successful "$RESPONSE"
- }
- # If running interactively, don't do anything
- case $- in
- *i*) return;;
- esac
- echo 'Cookie jar file is' $JAR >&2
- do_login
- while :
- do
- do_request || (do_login && do_request) || (echo 'Broken' >&2; exit 1)
- [ "$?" -ne 0 ] && break
- sleep "$TIMEOUT"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement