Crushdepth Posted February 26, 2008 Posted February 26, 2008 My ISP (WLAN.net) has a very annoying practice: They forcibly log me out at least three times a day with no warning. Login is web-based, after I've been kicked off opening a browser redirects me to a 'login' page, where I have to submit my user name and password again. Needless to say, this is quite inconvenient. Is there a way that I can get my computer to automatically sign in again? Like a script or something that will check internet connectivity every 10 minutes or so and launch Firefox/try to log in if it finds I've been kicked off? The reason is that I want to make my personal files available via a Hamachi VPN while I travel, and also to synchronise files between several machines using Office Groove. This is just not possible at the moment, as the services are cut every few hours. Thanks
Crushdepth Posted March 1, 2008 Author Posted March 1, 2008 Ok I found a way to do this. It's a bit of a kludge but it works: 1. Installed iMacros demo version, which is a program that lets you record macros in Firefox. Basically you just tell it to 'record' then log in to the ISP with your user name and password, so you can 'replay' this action in future. 2. Wrote a small windows batch file, which pings a reliable website as a test to see if my internet connection is live or not. If it gets no response, it assumes the connection has been cut and launches the 'login' macro. If the connection is live, it does nothing. 3. I used Windows Task Scheduler to run the batch file every 10 minutes. So, when my ISP cuts me off my computer will detect it and login again within 10 minutes. This will allow me to keep my my private VPN and Groove account online :-) The downside: iMacros is not free (there is a free firefox plugin but it can't be run via scheduler). I would therefore like to modifiy my batch file to POST the username/login details to the login website directly via https. If anyone can point me to a tutorial on how to create/send custom https requests would appreciate it. Can I do that with telnet or something? The batch file looks like this: @ECHO OFF ECHO Checking connection, please wait... PING (insert IP of a reliable site here) |FIND "Reply from " > NUL IF NOT ERRORLEVEL 1 ECHO You have an active connection to the internet IF ERRORLEVEL 1 cd \d %ProgramFiles(x86)%\iMacros START imacros.exe -macro crushdepth EXIT If anyone can think of a more efficient way to do this please let me know. I'm kind of suprised that browsers don't have automatic login features in this day and age.
briley Posted March 2, 2008 Posted March 2, 2008 You don't say if dial up or broadband. On broadband most routers will auto connect if a request for an Internet address is made - but it might need to be enabled in you router If using Dial up (or a USB connection through a router that needs to be 'connected') there are a number of small free programs that will auto redial if the connection is lost. In addition using MS windows you can set the dial up connection options to reconnect if the connection is lost.
Crushdepth Posted March 2, 2008 Author Posted March 2, 2008 Thanks its broadband. The issue is the ISP is logging me off, and I have to login through a a web form before any other pages can be loaded. When I'm logged out all page requests get redirected to their login page. My kludge is working pretty well so far, my VPN stayed up overnight for the first time ever, but I'd really like to find an alternative to iMacros. Is it possible to send pre-made http requests via puTTy or telnet or something? So I can 'login' without having to actually use a browser?
dsys Posted March 2, 2008 Posted March 2, 2008 Thanks its broadband. The issue is the ISP is logging me off, and I have to login through a a web form before any other pages can be loaded. When I'm logged out all page requests get redirected to their login page.My kludge is working pretty well so far, my VPN stayed up overnight for the first time ever, but I'd really like to find an alternative to iMacros. Is it possible to send pre-made http requests via puTTy or telnet or something? So I can 'login' without having to actually use a browser? First off good cludge. To get a more robust free solution should be relatively painless, here's how I would go about it. 1. Get a copy of visual studio vb.net (download free version from microsoft) 2. Use the browser object model ( DOM) part of vb.net to "interface with " your website. 3. call the dom script from your batch file. There are loads of ways to do it google "dom scripting autologin" here is a java dom script that will get you part of the way :: note gpl license and header must stay attached // Allow Password Remembering // version 0.1 // 2005-04-06 // Copyright © 2005, Julien Couvreur // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html // Based on the remember password bookmarklet: // http://www.squarefree.com/bookmarklets/for...member_password // -------------------------------------------------------------------- // // // // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/ // Then restart Firefox and revisit this script. // Under Tools, there will be a new menu item to "Install User Script". // Accept the default configuration and install. // If you want, you can configure the Included and Excluded pages in // the GreaseMonkey configuration. // // To uninstall, go to Tools/Manage User Scripts, // select "Allow Password Remembering", and click Uninstall. // // -------------------------------------------------------------------- // // WHAT IT DOES: // Sites can direct the browser not to save some password fields (for // increased security). They do it by tagging the password field with // autocomplete="off", in the HTML. "Allow Password Remembering" removes // these tags, so that the user can decide which password the browser // should save. // // -------------------------------------------------------------------- // // ==UserScript== // @name Allow Password Remembering // @namespace http://blog.monstuff.com/archives/cat_greasemonkey.html // @description Removes autocomplete="off" attributes // @include http://* // @include https://* // ==/UserScript== // Updated (2005/09/09): // Included Mark Pilgrim's fix for DeerPark: // must access element.attributes as an array of objects and use .name and .value properties, can't shortcut with element.attributes['autocomplete'] var allowAutoComplete = function(element) { var iAttrCount = element.attributes.length; for (var i = 0; i < iAttrCount; i++) { var oAttr = element.attributes; if (oAttr.name == 'autocomplete') { oAttr.value = 'on'; break; } } } var forms = document.getElementsByTagName('form'); for (var i = 0; i < forms.length; i++) { var form = forms; var elements = form.elements; allowAutoComplete(form); for (var j = 0; j < elements.length; j++) { allowAutoComplete(elements[j]); } }
Guest Reimar Posted March 2, 2008 Posted March 2, 2008 Normaly you have the login in the Modem Router. But if you use one from the ISP with software which force you for to keyin username and password, than may you need to change the Modem/Router. The normal procedure for Username and Password is one step setup while setup the Modem Router for to connect to the internet. The main infos are: VPI/VCI value (TRUE 0/100), PPPoE, LLC for encapsulation, MTU (max 1500) and U/P Last you have to key in an field like this: If all your aother settings are correct, you should be able to connect now ans aty connectd as long as you want, which means, until you power off the Modem/Router! Cheers.
Crushdepth Posted March 2, 2008 Author Posted March 2, 2008 Thanks for your replies. I think maybe I need to clarify the login situation a bit more. My building has a captive portal internet service (a bit like a starbucks cafe except it is wired access), run by a Colubris Networks MSC-3200 Multiservice Controller. They gave me a modem (T-LAN SU-400), but it doesn't handle the actual login and I don't have administrative access password for it. The login is done through a webpage (eg. http://your_building_name/wlan.net/login.asp) that pops up automatically when I open a browser. ie. if I'm not logged in, my browser gets redirected to the captive portal page and I have to sign in there, then it will allow me to surf wherever. Until they cut it
autonomous_unit Posted March 2, 2008 Posted March 2, 2008 You might want to look at some OSS programs like "wget" or "curl" which are scriptable command-line tools often used to retrieve a web page but also support authenticated logins and form posting. They support FTP, HTTP, etc. You'll have to figure out the right mechanism to re-login, but then you should be able to automate it from a simple script. The question is how to detect when it is down... can you just ping an external host and determine it is logged out because the pings fail? Or do you actually have to fetch a web page and determine that it was redirected to the login? Either way, you ought to be able to automate this too (with some ugly hacks to recognize the redirect content). I don't know about Windows ports of these, but wget and curl are light enough to run inside a Linux-based router. They probably are available via CygWin or similar.
Crushdepth Posted March 2, 2008 Author Posted March 2, 2008 No need to actually load a page to test for connectivity. At the moment my batch file tries to ping an external website as an indicator of connection status (run every 10 minutes by Task Scheduler). If I have been logged out the ping fails and then the batch file launches the 'login' macro. The scheduled ping test seems to work fairly well. The batch file could also easily be made to launch Firefox, open the login page and 'remember' the username/password. However, the one thing I can't think how to automate is pressing that 'submit' button!! Could a Javascript do that and be triggered to run when a certain page (the login page) is loaded, via Greasemonkey? Any Javascript heads can comment on feasibility?
Crushdepth Posted March 2, 2008 Author Posted March 2, 2008 Ok, I now have a complete and free solution! To solve the automatic form submission problem I installed the Greasemonkey addon for Firefox (this is very, very cool - allows you to run custom scripts against particular websites) and I found an excellent auto-login script which submits forms if Firefox has been previously told to 'remember' their details. So the whole set up finally consists of: 1. Install the Greasemonkey addon for Firefox (lets you install/automatically run custom scripts on visiting a certain web page). 2. Install an Greasemonkey autologin script (just visit the link and Greasemonkey will automatically offer to install it for you - but be sure to view the source code first!) 3. A small windows batch file, which pings a reliable website as a test to see if my internet connection is live or not. If it gets no response, it assumes the connection has been cut and launches launches Firefox with the login page URL as an argument. I have previously told Firefox to 'remember' the username/password, so Firefox autocompletes the form which triggers Greasemonkey to submit it. 4. Set up Windows Task Scheduler to run the batch file every 10 minutes. So, when my ISP cuts me off my computer will detect it and login again within 10 minutes. The final batch file: @ECHO OFF PING insert-reliable-website-ip-here |FIND "Reply from " > NUL IF NOT ERRORLEVEL 1 ECHO You have an active connection to the internet IF ERRORLEVEL 1 cd "%ProgramFiles(x86)%\Mozilla Firefox" && START firefox.exe "http://url.ofyour.loginpage" EXIT
Crushdepth Posted March 13, 2008 Author Posted March 13, 2008 I had problems with many instances of firefox accumulating and jamming things up (I think, when the connection is cut by factors other than my ISP), so small change to the batch file - it first tries to close firefox, before opening an instance. @ECHO OFF PING insert-reliable-website-ip-here |FIND "Reply from " > NUL IF NOT ERRORLEVEL 1 ECHO You have an active connection to the internet IF ERRORLEVEL 1 taskkill /IM firefox.exe && cd "%ProgramFiles(x86)%\Mozilla Firefox" && START firefox.exe "url-of-your-isp-login-page" EXIT
kitjohnson Posted August 17, 2009 Posted August 17, 2009 Ok, I now have a complete and free solution!To solve the automatic form submission problem I installed the Greasemonkey addon for Firefox (this is very, very cool - allows you to run custom scripts against particular websites) and I found an excellent auto-login script which submits forms if Firefox has been previously told to 'remember' their details. So the whole set up finally consists of: 1. Install the Greasemonkey addon for Firefox (lets you install/automatically run custom scripts on visiting a certain web page). 2. Install an Greasemonkey autologin script (just visit the link and Greasemonkey will automatically offer to install it for you - but be sure to view the source code first!) 3. A small windows batch file, which pings a reliable website as a test to see if my internet connection is live or not. If it gets no response, it assumes the connection has been cut and launches launches Firefox with the login page URL as an argument. I have previously told Firefox to 'remember' the username/password, so Firefox autocompletes the form which triggers Greasemonkey to submit it. 4. Set up Windows Task Scheduler to run the batch file every 10 minutes. So, when my ISP cuts me off my computer will detect it and login again within 10 minutes. The final batch file: @ECHO OFF PING insert-reliable-website-ip-here |FIND "Reply from " > NUL IF NOT ERRORLEVEL 1 ECHO You have an active connection to the internet IF ERRORLEVEL 1 cd "%ProgramFiles(x86)%\Mozilla Firefox" && START firefox.exe "http://url.ofyour.loginpage" EXIT This looks useful. The link to the greasemonkey script is broken. Don't suppose you could post the code please? Thanks.
Crushdepth Posted August 17, 2009 Author Posted August 17, 2009 Will look it up tonight, I think I still have it.
kitjohnson Posted August 18, 2009 Posted August 18, 2009 Will look it up tonight, I think I still have it. I'll be right here waiting!
Crushdepth Posted August 18, 2009 Author Posted August 18, 2009 Here you go: // Auto-login v0.7.1 // (c) 2005-2006, Clem // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/ // // Combine with 'Allow Password Remembering' for perfect auto-login =) // -------------------------------------------------------------------- // ==UserScript== // @name AutoLogin // @namespace http://labs.beffa.org/greasemonkey/ // @description Auto-login // @include http://* // @include https://* // ==/UserScript== (function() { var al_KeyPressed = false; var al_Init = function() { var passfield = false; if (!document.getElementsByTagName) return; var forms = document.getElementsByTagName("form"); for (var i=0;i<forms.length;i++) { var formElement = forms[i].elements; for (var j=0; j < formElement.length; j++) { var thisElement = formElement[j]; if (thisElement.type == "password") { //to prevent submit to stupid site which put fake login / pass value if (thisElement.value != thisElement.defaultValue) { passfield = true; thisElement.addEventListener('keypress', al_KeyPress, true); } } } } if (passfield) setTimeout(al_CheckPass, 10); } var al_KeyPress = function (){ al_KeyPressed = true; } var al_CheckPass = function () { if (!al_KeyPressed) { if (!document.getElementsByTagName) return; var forms = document.getElementsByTagName("form"); for (var i=0;i<forms.length;i++) { var formElement = forms[i].elements; for (var j=0; j < formElement.length; j++) { var thisElement = formElement[j]; if (thisElement.type == "password") { if(thisElement.value.length>1){ submit = false; for (var input, k=0; input=formElement[k]; k++) if (input.type == "submit") submit = input; if (submit) { submit.click(); } else { forms[i].submit(); } return; } } } } setTimeout(al_CheckPass, 100); } } al_Init(); })();
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now