# 前言
一只都在使用Padavan的閃訊登陸。一直都是很方便,但是有一個問題不能固定。有些同學或許可以固定,我之前為了固定閃訊密碼這個事情還投訴到工信部結果還受到了人身威脅。經(jīng)過反復交涉最終還是沒能固定下來。所以為了解決這個問題,我換了一個思路?;灸軐崿F(xiàn)了閃訊密碼的偽固定??梢詫崿F(xiàn)在閃訊密碼過期之后自動的發(fā)送短信接收短信并且同步到路由器上,讓路由器進行自動的更新密碼操作達到自動更換的目的。
# 使用方法
## 閃訊密碼偽固定,路由器shell腳本.
# 通過請求[myjson.com](https://www.myjson.com) 網(wǎng)站提供的臨時json數(shù)據(jù)存放.
```
server_back=$(curl -s https://api.myjson.com/bins/XXXX)
```
# 從路由器的nvram當中獲取當前的路由器信息和時間戳
```shell
#query nvram get now password.
now_password=$(nvram get wan_pppoe_passwd)
# get current timestamp
now_timestamp=$(date +%s)
# get ephone new timestamp
next_timestamp=$(date -d "$next_update_time" +%s)
```
# 判斷時間是否已經(jīng)過期,并且密碼已經(jīng)不同
```shell
if [ $(expr $now_timestamp - $next_timestamp) -lt 0 ]
then
if [ "$now_password" == "$new_password" ]
then
? ? ? ? echo "The password is the same does not need to be modified"
else
# can update password
# Modify the password value of pppoe directly
nvram set wan0_pppoe_passwd=$new_password
nvram set wan_pppoe_passwd=$new_password
# commit nvram
nvram commit
# restart wan auto_connect
restart_wan
echo "The password has been modified successfully"
? ? ? ? restart_wan
fi
else
echo "Expiration time hasn't arrived yet"
fi
```
# AutoReboot-GetPassword-App閃訊密碼助理
自動獲取閃訊密碼的手機app 自動分析過期時間 自動修改路由器閃訊密碼
[app地址](https://github.com/egdw/AutoReboot-GetPassword-App)
## 鏈接生成地址
1. [鏈接生成](http://myjson.com/)
2. 復制下面的數(shù)據(jù)到輸入框中.
```
{"new_password":"000000","next_update_time":"2018-12-10 22:27:22"}
```
3. 獲取生成的鏈接
## 配合Pandavan進行聯(lián)動.
通過自己寫的下面的腳本,可以直接在過期時間之后自動更換Pandavan中的閃訊密碼.達到閃訊密碼的偽固定功能.
>server_back=$(curl -s http://api.myjson.com/bins/XXXXX) 只需要修改這里的請求地址即可
```shell
#!/bin/bash
server_back=$(curl -s http://api.myjson.com/bins/XXXXX)
new_password=${server_back:17:6}
next_update_time=${server_back:45:19}
echo $new_password
echo $next_update_time
now_password=$(nvram get wan_pppoe_passwd)
now_timestamp=$(date +%s)
next_timestamp=$(date -d "$next_update_time" +%s)
# 相差的時間
if [ $(expr $now_timestamp - $next_timestamp) -lt 0 ]
then
if [ "$now_password" == "$new_password" ]
then
? ? ? ? echo "The password is the same does not need to be modified"
else
# can update password
# Modify the password value of pppoe directly
nvram set wan0_pppoe_passwd=$new_password
nvram set wan_pppoe_passwd=$new_password
# commit nvram
nvram commit
# restart wan auto_connect
restart_wan
echo "The password has been modified successfully"
? ? ? ? restart_wan
fi
else
echo "Expiration time hasn't arrived yet"
fi
```
設置好相應的sh腳本權限.然后在pandavan中的 高級設置->系統(tǒng)管理->服務->其他服務->計劃任務
相當于每30分鐘執(zhí)行一次腳本
```
*/30 * * * * /腳本地址/腳本名字.sh
```
## app設置
在app中也需要設置好請求地址才可以相互聯(lián)動.
## 注意
1. 需要通過ssh連接到路由器
2. 腳本權限記得加 chmod +x 腳本.sh

3. 記得設置好crontab計劃任務.不然不能定時執(zhí)行了.
4. app加入白名單.并給予發(fā)送短信和接收通知短信的權限.(安全中心中.)