51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

[原创]美国Google Voice保号Shell脚本

因特殊需要申请了Google Voice的号码,根据Google的续约规则需要定期进行号码拨打或接听,故编写该Shell脚本。

本脚本依赖于ifftt的免费拨号服务,不保证更新,仅供参考。

使用教程

脚本依赖

本脚本运行于Centos7环境中,其他环境未测试。

  1. 需要通过邮箱注册ifttt网站;
  2. 用户号码示例(无需加+1):5672000003 。
  3. 编辑User_Phone_List变量,多个号码以空格为分隔符。
脚本内容

将以下脚本内容复制到Linux系统中,并修改Username,Password,User_Phone参数内容。

#!/bin/bash
# Google Voice保号脚本
# Author: admin@lolicp.com
# Date: 2022-07-28
# Version: 0.0.2

邮箱名称
====



Username=''


密码
===



Password=''


接收手机号
=====



User_Phone_List=(5000000000 9000000000)


数据存储
====



File_Cookie='/tmp/voice.db'


Echo_Date_Out(){
echo "\[$(date "+%Y-%m-%d %H:%M:%S")\] $@"
}


Curl_Init(){
curl -s -c "${File_Cookie}" -A 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36' "${@}"
}


Login_Cookie(){
curl -s -b "${File_Cookie}" -A 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36' "${@}"
}


验证登录状态
======



Ver_Login_Status=`curl -s -v -b "${File_Cookie}" -A 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36' https://ifttt.com/settings 2>&1 1>/dev/null`
if \[\[ "${Ver_Login_Status}" =\~ 'HTTP/1.1 200 OK' \]\];then
Echo_Date_Out "用户在线,无需重新登录。"
else
Echo_Date_Out "用户未登录,开始初始化"
Curl_Init -H 'Referer: https://ifttt.com/' "https://ifttt.com/login?wp_=1" \&\> /dev/null
# 获取登录token
Authenticity_Token=`Login_Cookie -c "${File_Cookie}" -H 'Referer: https://ifttt.com/session/new?wp_=1' "https://ifttt.com/csrf_token.json" |python -m json.tool |awk -F'"' '/"token"/ {print $4}'|sed -re 's/=/%3D/g' -e 's#/#%2F#g' -e 's/\+/%2B/g'`
if \[ -z "${Authenticity_Token}" \];then
Echo_Date_Out "获取token失败"
exit 1
fi
# 登录状态
Login_Info=`Login_Cookie -v -X POST -c "${File_Cookie}" -H 'Referer: https://ifttt.com/session/new?wp_=1' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' -d "utf8=%E2%9C%93&authenticity_token=${Authenticity_Token}&return_to=&psu_=&user%5Busername%5D=${Username/@/%40}&user%5Bpassword%5D=${Password}&commit=Log in" "https://ifttt.com/session" 2>&1`
if \[\[ "${Login_Info}" =\~ 'https://ifttt.com/explore"\>redirected' \]\];then
Echo_Date_Out "用户登录成功"
else
Echo_Date_Out "登录失败:${Login_Info}"
exit 1
fi
fi


根据列表循环发送
========


`for User_Phone in ${User_Phone_List[@]};do
# 号码发送请求
Phone_Send_Query=``Login_Cookie -H 'Referer: https://ifttt.com/channels/phone_call/activate?activation_failure_path=https%3A%2F%2Fifttt.com%2Fbulk_channel_activation%2Ffailed&activation_success_path=https%3A%2F%2Fifttt.com%2Fbulk_channel_activation%2Fcontinue&is_web_view=1' -X PUT -d "utf8=%E2%9C%93&live_channel%5Blive_channel_fields_attributes%5D%5B0%5D%5Bchannel_field_id%5D=8&live_channel%5Blive_channel_fields_attributes%5D%5B0%5D%5Bvalue%5D=${User_Phone}%E2%80%AC&live_channel%5Blive_channel_fields_attributes%5D%5B1%5D%5Bchannel_field_id%5D=93&live_channel%5Blive_channel_fields_attributes%5D%5B1%5D%5Bvalue%5D=&pin=" "https://ifttt.com/channels/phone_call/send_pin"``
if [[ "${Phone_Send_Query}" =~ '4-digit PIN' ]];then
Echo_Date_Out "发送PIN至 ${User_Phone} 成功"
else
Echo_Date_Out "发送PIN至 ${User_Phone} 失败"
fi
done`

运行情况
[root@localhost ~]# bash Google_Voice.sh
[2022-07-28 09:07:43] 用户在线,无需登录。
[2022-07-28 09:07:45] 发送PIN成功
赞(0)
未经允许不得转载:工具盒子 » [原创]美国Google Voice保号Shell脚本