来源:
https://github.com/mixool/script/blob/debian-9/hostloc.sh
https://www.hostloc.com/forum.php?mod=viewthread&tid=545329&highlight=%E7%A7%AF%E5%88%86
运行结果展示:
1 2 3 4 5 6 7 8 9 10 11 |
bash /var/www/html/www/tools/hostloc.sh hostloc用户名 hostloc密码 Tue May 7 15:52:47 CST 2019 登陆...www.hostloc.com Tue May 7 15:52:48 CST 2019 成功 Tue May 7 15:52:50 CST 2019 目前积分为:4642 Tue May 7 15:52:50 CST 2019 访问空间.............. .....Tue May 7 15:55:54 CST 2019 完成 Tue May 7 15:55:55 CST 2019 目前积分为:4662 Tue May 7 15:55:55 CST 2019 huzongsi Accomplished. Thanks! |
创建hostloc.sh脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#!/usr/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # Usage: ## wget --no-check-certificate https://raw.githubusercontent.com/mixool/script/debian-9/hostloc.sh && chmod +x hostloc.sh.sh && bash hostloc.sh ### bash <(curl -s https://raw.githubusercontent.com/mixool/script/debian-9/hostloc.sh) ${username} ${password} # user info: change them to yours or use parameters instead. username="$1" password="$2" # UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" # workdir workdir="/root/hostloc_cookie" [[ ! -d "$workdir" ]] && mkdir $workdir function login() { echo echo -n $(date) 登陆... data="mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1&fastloginfield=username&username=$username&cookietime=$(shuf -i 1234567-7654321 -n 1)&password=$password&quickforward=yes&handlekey=ls" curl -s -H "$UA" -c $workdir/cookie_$username --data "$data" "https://www.hostloc.com/member.php" | grep -o "www.hostloc.com" && echo -n $(date) 成功 || status="1" [[ $status -eq 1 ]] && echo -n $(date) 失败 && exit 1 } function credit() { echo creditall=$(curl -s -H "$UA" -b $workdir/cookie_$username "https://www.hostloc.com/home.php?mod=spacecp&ac=credit&op=base" | grep -oE "积分: </em>\w*" | awk -F'[>]' '{print $2}') echo $(date) 目前积分为:$creditall } function view() { echo echo -n $(date) 访问空间 for((i = 6610; i <= 6630; i++)) do echo -n . curl -s -H "$UA" -b $workdir/cookie_$username "https://www.hostloc.com/space-uid-$i.html" | grep -o "最近访客" >/dev/null && count[i]=$i sleep 10 && [[ ${#count[*]} -eq 10 ]] && echo && break done echo -n $(date) 完成 } function main() { login credit view credit # clean rm -rf $workdir # exit echo echo $(date) $username Accomplished. Thanks! } main |
运行:
1 |
bash /var/www/html/www/tools/hostloc.sh hostloc用户名 hostloc密码 |
增加计划任务(使用tmux后台回话):
crontab -e
1 2 3 4 |
#hostloc 0 2 * * * tmux new-session -s hostloc -d #新建tmux会话 0 3 * * * tmux send-keys -t hostloc 'bash /var/www/html/www/tools/hostloc.sh 用户1 密码1' C-m 0 15 * * * tmux send-keys -t hostloc 'bash /var/www/html/www/tools/hostloc.sh 用户2 密码2' C-m #其中C-m 表示回车键 |
查看tmux会话:
1 |
tmux a -t hostloc |