Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env lua
- function md5sum(str)
- local command="echo -n "..str.." | md5sum"
- local f=io.popen(command)
- local out=f:read('*all')
- return out:sub(1,-5)
- --f:close()
- end
- --print(md5sum("asdf")) -- 912ec803b2ce49e4a541068d495ab570
- --START HERE
- function get_account(username,password)
- local ver="Tyroth"
- local temp=string.format("%X",os.time())
- username=string.upper(username)
- local s=temp..ver..username..password
- local m=string.upper(md5sum(s))
- m=string.sub(m,1,20)
- local encodedaccont="~ghca"..temp.."2002"..m..username
- return encodedaccont
- end
- --print(get_account(arg[1],arg[2]))
- function get_account_v07(username,password)
- --the encrypt algorithm version 07
- --For backup
- local ver="jepyid"
- local temp=string.format("%X",os.time())
- username=string.upper(username)
- local s=ver..username..temp..password
- local m=string.upper(md5sum(s))
- m=string.sub(m,1,20)
- local encodedaccont="~ghca"..temp.."2007"..m..username
- return encodedaccont
- end
- function pppoe_dial(username,password)
- --restore network config file
- local restore="if [ ! -f /etc/config/network ];then cp /root/network.bak /etc/config/network;fi"
- os.execute(restore)
- print("Dialing...")
- --print(username)
- local setuser="uci set network.wan.username="..get_account_v07(username,password)
- local setpass="uci set network.wan.password="..password
- os.execute(setuser)
- os.execute(setpass)
- os.execute("uci commit")
- os.execute("/etc/init.d/network restart")
- os.execute("logread|grep pppd |tail -n 20 >/root/ppplog")
- --local pppd="pppd plugin rp-pppoe.so mtu 1492 mru 1492"
- --if not io.open("/etc/crontabs/root") then
- --cron--
- os.execute("killall -9 crond")
- --local mycron="flag=0;for ip in 126.com 163.com qq.com; do if ping -c 1 $ip | grep 'ttl' >/dev/null;then flag=1; break;fi; done; if [ $flag -eq 0 ] ;then STRD "..username.." "..password.." >/dev/null;fi;"
- local mycron="*/1 * * * * flag=0;for ip in 126.com 163.com qq.com; do if ping -c 1 $ip | grep 'ttl' >/dev/null;then flag=1; break;fi; done; if [ $flag -eq 0 ] ;then sh /etc/rc.local >/dev/null;else cp -f /etc/config/network /root/network.bak;fi; 2>/dev/null"
- --local setcron="*/1 * * * * "..mycron.." 2>/dev/null"
- crontab=io.open("/etc/crontabs/root","w")
- crontab:write(mycron)
- crontab:close()
- local startcron="crond -c /etc/crontabs"
- os.execute(startcron)
- --end
- print("Done!")
- end
- --main--
- if arg[1] and arg[2] then
- pppoe_dial(arg[1],arg[2])
- else
- print("USAGE:\n "..arg[0].." USERNAME PASSWORD\n")
- end
- os.exit(0)
- --end main--
Add Comment
Please, Sign In to add comment