20 Sep 2019 
Support Center » Knowledgebase » Scripts for DSL/Cable modems / routers » Router wrt54g / Tomato Firmware v1.27.1798, Modem SURFboard SBG900 Software version: SBG900-2.1.15.0-SCM00-NOSH
 Router wrt54g / Tomato Firmware v1.27.1798, Modem SURFboard SBG900 Software version: SBG900-2.1.15.0-SCM00-NOSH
Article function findSid(s) {
 m="sessionId=";
 i=s.IndexOf(m);
 if (i==-1) return null;
 s=s.Substring(i+m.Length);
 i=s.IndexOf("\"");
 if (i==-1) return null;
 s=s.Substring(0, i);
 return s;
}

function findTid(s) {
 m="_http_id=";
 i=s.IndexOf(m);
 if (i==-1) return null;
 s=s.Substring(i+m.Length);
 i=s.IndexOf("\'");
 if (i==-1) return null;
 s=s.Substring(0, i);
 return s;
}

hsm=new HTTPScript();
hsm.Data="userId=admin&password=motorola&btnLogin=Log In";
s=hsm.POST("http://192.168.0.1/frames.asp");
sid=findSid(s);
if (sid==null) {
 Info ("Could not log in to the modem");
 return false;
}
Info("Logged into the modem, session ID="+sid);

hsr=new HTTPScript("root", "admin");
s=hsr.GET("http://192.168.1.1/");
tid=findTid(s);
if (tid==null) {
 Info ("Could not log in to the router");
 return false;
}
Info("Logged into the router, session ID="+tid);
vMac=RandomMAC();
vMac=MACToString(vMac, ":");
Info("Generated random MAC address: "+vMac);
hsr.Data="_ajax=1&_nextpage=advanced-mac.asp&_nextwait=10&_service=*&mac_wan="+vMac+"&mac_wl=&_http_id="+tid;
s=hsr.POST("http://192.168.1.1/tomato.cgi");
if (!s.Contains("Settings saved")) {
 Info("MAC change failed: "+s);
 return false;
}
Info("Changed WAN MAC on the router to "+vMac);


hsm.Data="urlOk=redirect.asp&urlError=redirect.asp?error=error&General.Modem.state=2";
s=hsm.POST("http://192.168.0.1/goform/AlFrame?sessionId="+sid);
if (!s.Contains("index.asp")) {
 Info("Modem reboot failed: "+s);
 return false;
}
Info("Rebooting the modem");
Wait(5000);
return true;


Article Details
Article ID: 152
Created On: 30 Jan 2011 6:26 PM

 This article was helpful  This article was not helpful

 Back
 Log in [Lost Password] 
E-mail:
Password:
Remember Me:
 
 Search
 Article Options
Home | Submit a Ticket | Knowledgebase | Troubleshooter
Language:

Help Desk Software by Kayako SupportSuite v3.70.02