Skip to content

Instantly share code, notes, and snippets.

@heruoxin
Last active November 15, 2016 03:40
Show Gist options
  • Save heruoxin/8437177 to your computer and use it in GitHub Desktop.
Save heruoxin/8437177 to your computer and use it in GitHub Desktop.
成都理工协同路由脚本……
#!/bin/bash
echo
echo "成都理工协同拨号路由破解脚本"
echo "算法来源:http://fyscu.com/forum.php?mod=viewthread&tid=1104"
echo "本脚本仅适用于ddwrt、openwrt、tomato的路由"
echo "使用前请确认已经在路由设置页面上调整之为PPPoE拨号模式,并最好备过份。"
echo "截至2014年2月,对CD028XXXXX@96301类型的帐号有效,对使用本脚本后的任何意外本人无力负责。"
echo
#判断系统
osame=$(uname)
if [[ $osame == *omato* ]]
then
nextgo=tomato;
elif [[ $osame == *dd*wrt* ]]
then
nextgo=ddwrt;
elif [[ $osame == *open*wrt* ]]
then
nextgo=openwrt;
else
while true; do
read -p '系统识别失败,请输入系统类型(ddwrt/openwrt/tomato):' osname;
case $osname in
"tomato")
nextgo=tomato;
break
;;
"ddwrt")
nextgo=ddwrt;
break
;;
"openwrt")
nextgo=openwrt;
break
;;
*)
;;
esac
done
fi
#输入帐号密码
while true; do
read -p "输入你的帐号名称(格式类似于CD028XXXXX@96301这样):" usrname
if ! [ -z $usrname ]; then
break
fi
done
read -p "输入密码:" passwd
if [ -z $passwd ]; then
echo "未输入密码,使用默认的12345678"
passwd='12345678'
fi
#写入算号步骤并设为自启动
#囧sh在function上语法和bash有区别……
#这下面本来是函数的……
case $nextgo in
"tomato")
echo "你的路由系统为tomato,如判断错误请终止执行"
sleep 3
nvram set script_init="\
_account=$usrname;\
_password=$passwd;\
_random=\$(head /dev/urandom |tr -cd a-f0-9|cut -c 1-8);\
_true_account='~ghca'\$_random'2007'\$(echo -n 'jepyid'\$_account\$_random\$_password|md5sum|cut -c 1-20)\$_account;\
nvram set ppp_username=\$_true_account;\
nvram set ppp_passwd=\$_password;"
echo "3秒后重启……"
echo "tomato可能需要再重启一次,可能哈"
sleep 3
rm cdutrouterdial.sh > /dev/null
reboot
;;
"openwrt")
echo "你的路由系统为openwrt,如判断错误请终止执行"
sleep 3
cat >> /etc/rc.local << EOF
_account=$usrname
_password=$passwd
_random=\$(head /dev/urandom |tr -cd a-f0-9|cut -c 1-8)
_true_account='~ghca'\$_random'2007'\$(echo -n 'jepyid'\$_account\$_random\$_password|md5sum|cut -c 1-20)\$_account
_the_line=' option username '\'\$_true_account\'
sed -i "s/.*username.*/\$_the_line/" /etc/config/network
sed -i "s/.*password.*/ option password \'\$_password\'/" /etc/config/network
sleep 2
/etc/init.d/network restart
EOF
echo "3秒后尝试拨号……"
sleep 3
/etc/rc.local
rm cdutrouterdial.sh > /dev/null
;;
"ddwrt")
echo "你的路由系统为ddwrt,如判断错误请终止执行"
sleep 3
cat >> /etc/rc.local << EOF
_account=$usrname
_password=$passwd
_random=\$(head /dev/urandom |tr -cd a-f0-9|cut -c 1-8)
_true_account='~ghca'\$_random'2007'\$(echo -n 'jepyid'\$_account\$_random\$_password|md5sum|cut -c 1-20)\$_account
sed -i "s/^user.*/user \'\$_true_account\'/g" /tmp/ppp/options.pppoe
sed -i "s/^password.*/password \'\$_password\'/g" /tmp/ppp/options.pppoe
killall redial
killall pppd
pppd file /tmp/ppp/options.pppoe&
EOF
echo "3秒后尝试拨号……"
sleep 3
/etc/rc.local
rm cdutrouterdial.sh > /dev/null
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment