The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Applications (http://hintsforums.macworld.com/forumdisplay.php?f=5)
-   -   How can I login without opening my browser? (http://hintsforums.macworld.com/showthread.php?t=71274)

ThreeBKK 04-21-2007 04:25 AM

How can I login without opening my browser?
 
I have to login to the network through my browser before I can start accessing the web, and it's gotten quite annoying. Is there some alternative way to login (sans browser) by using one of Apple's net utilities or an Applescript?

mark hunte 04-21-2007 05:14 AM

It would really depend on how you are being asked to login.

Are you being asked to login into the proxy sever. by a drop-down sheet. Comes out of the title bar

If so there should be a 'remember' this password checkbox.

If you have to login using a form on a web page.
Then check this thread out

ThreeBKK 04-21-2007 05:20 AM

Yes, I believe it's a proxy server. At any rate, Safari does remember the password and user name, so I just have to press one or two buttons, and I'm in. The thing is, I'm trying to avoid opening browsers altogether. I would rather have my system login in the background.

Thanks for the hint!

ThreeBKK 04-21-2007 05:39 AM

Maybe it would help if I mention that the URL for the login page is:
http://10.0.0.254/cgi-bin/authen_01.pl

tw 04-21-2007 08:42 AM

Quote:

Originally Posted by ThreeBKK (Post 373679)
Yes, I believe it's a proxy server. At any rate, Safari does remember the password and user name, so I just have to press one or two buttons, and I'm in. The thing is, I'm trying to avoid opening browsers altogether. I would rather have my system login in the background.

you can easily modify the applescript Mark pointed to so that it operates in the background. I use something similar to log into my own system (though I only have to do that once a week). it looks something like:
Code:

tell application "Safari"
  launch
  do JavaScript "document.forms['login_form'].submit()" in document 1
      -- replace login_form with the name of the form
      -- get that by viewing source of the web page
      -- you can also use a numeric index, e.g. document.forms[0]...
      -- don't lose the single quotes
  delay 5
  quit
end tell

'launch' opens safari in the background (as opposed to activate, which brings it to the foreground); submit() sends the form without GUI scripting (which would need Safari in the foreground); quit closes it all. you may need to insert a testing loop or delay command before do JavaScript - depends on how quickly the page loads and autofill completes your entry. The 'delay 5' before the 'quit' is a hack to let the next page load and set whatever cookies it needs to set so that you are logged in; you can probably do that more elegantly by checking the page name or uri.

Not perfectly silent, but unobtrusive.

ThreeBKK 04-25-2007 04:28 AM

That's interesting. Thanks for the info, it's a step in the right direction. I wonder if anything like this could be done through Terminal.

bramley 04-25-2007 10:46 AM

Quote:

Originally Posted by ThreeBKK (Post 374477)
I wonder if anything like this could be done through Terminal.

Almost certainly. Note the URL you have quoted only has meaning on your local subnet. i.e nobody out here on the Internet can see what you see.

Further help is therefore hard to give without lots more detail. Do the scripts posted above work?

tw 04-25-2007 11:59 AM

Quote:

Originally Posted by bramley (Post 374532)
Almost certainly.

if I may cautiously, and partially, disagree... :o

usually, web authentication scripts are processed server-side, which means the only access point is through a web browser. it's possible that the administrators have implemented an ssh login mechanism (you should send them an email and ask); that would make the task tremendously easier, since you could write a cron entry that would periodically connect and log you in invisibly. more likely, though, it's expecting an http connection and setting a cookie in your browser. that means you'd need to write a unix script that fakes being a browser (sending and receiving http POST and GET, storing browser cookies...). gives me a headache just thinking about it.

ThreeBKK 04-25-2007 12:36 PM

Hmm, I'll look for any cookies that seem like they fit the description.
Trying to talk to the network people here is a real exercise in futility.
Take my word for it, I'd rather not explain. :)

mark hunte 04-25-2007 01:43 PM

Quote:

Originally Posted by ThreeBKK (Post 374576)
Hmm, I'll look for any cookies that seem like they fit the description.
Trying to talk to the network people here is a real exercise in futility.
Take my word for it, I'd rather not explain. :)

If you remember I posted a way to use cookies with Curl in this post posts 9 and 13.

AFAIK curl can use POST and GET if needed (don't ask me how to though)

ThreeBKK 04-25-2007 01:47 PM

I remember that post, but it was over my head back then, and still over my head today. I really appreciate the effort though. I'm going to go back and read it over again to make sure that I don't understand it, or vice-versa.

ThreeBKK 04-25-2007 01:57 PM

I've deleted all cookies and logged into the network, and it doesn't seem that there are any cookies being set by the server. The first cookie set is coming from the first page I visit, such as Google or these forums.

tw 04-25-2007 03:34 PM

Quote:

Originally Posted by ThreeBKK (Post 374619)
I've deleted all cookies and logged into the network, and it doesn't seem that there are any cookies being set by the server. The first cookie set is coming from the first page I visit, such as Google or these forums.

interesting. that means they must be keeping a database server-side with all current users. that actually increases the chance that you could log in via ssh (since nothing is being set on your computer, there's no structural need to get your browser involved. look on your provider's webpage and see if they give an address for non-html access (ftp, ssh, etc., or you might even try the address that the computer checks at startup) and the try to ssh into id - from terminal, that's: ssh <username>@<address>. see what happens.

ThreeBKK 04-25-2007 04:05 PM

2 Attachment(s)
I just want to post these screen shots to give you guys, perhaps, a better idea of what the login looks like. Complete with broken English (I don't think we are in Kansas anymore Toto)!

Here's the URL for the link to the lower right-hand side of the first screen.
http://www.nvk.co.th/

Are you beginning to understand why I avoid communication with the ISP and/or network admin.?

ThreeBKK 04-25-2007 04:16 PM

1 Attachment(s)
Here's a diagram of the setup that I think I have at my apt.:

ThreeBKK 04-25-2007 04:39 PM

I typed this in to Terminal:
ssh login@http://10.0.0.254
and got this back:
ssh: http://10.0.0.254: No address associated with nodename

Many different permutations of the above result in the same message. If I'm going to give Terminal a login, shouldn't there be a password as well?

ThreeBKK 04-25-2007 04:48 PM

Ah, this is different:

computername:~ useraccount$ ssh login@10.0.0.246
ssh: connect to host 10.0.0.246 port 22: Connection refused
computername:~ useraccount $ ssh login@10.0.0.254
The authenticity of host '10.0.0.254 (10.0.0.254)' can't be established.
RSA key fingerprint is (very long string of characters here).
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '10.0.0.254' (RSA) to the list of known hosts.
login@10.0.0.254's password:
Permission denied, please try again.
login@10.0.0.254's password:
Permission denied, please try again.

I tried the login password that works through my browser, but it didn't work in the last 4 lines of Terminal. Which password do you think works here?

tw 04-25-2007 08:17 PM

nah, sorry, if it was going to work it would have been easy. it's a secure login, so there's no sense guessing at the entry point. you're going to have to talk to the admins if you want to pursue this solution, or dig around in their webpage until you find something useful (I'd help, but I'm afraid my thai is a little rusty - lol), but my guess is it's going tobe a dead end.

ThreeBKK 04-26-2007 01:55 AM

I see. Thanks anyway!
How would I go about removing 10.0.0.254 from the list of known hosts?

(Warning: Permanently added '10.0.0.254' (RSA) to the list of known hosts.)

bramley 04-26-2007 12:40 PM

Quote:

Originally Posted by ThreeBKK (Post 374657)
these screen shots

Could we see the source code for the login page? i.e the code behind the page shown in login.jpg. Attach it to a post here as a text file.

ThreeBKK 04-26-2007 01:10 PM

1 Attachment(s)
Ok, you sure can.

tw 04-26-2007 01:54 PM

Quote:

Originally Posted by ThreeBKK (Post 374790)
How would I go about removing 10.0.0.254 from the list of known hosts?

(Warning: Permanently added '10.0.0.254' (RSA) to the list of known hosts.)

oh, I wouldn't worry about that. all that means is that ssh has registered this site as a 'safe' site. since there's no ssh connection available there, that's pretty darned safe. :-)

ThreeBKK 04-26-2007 02:07 PM

I see, but the first time I entered that command, the server generated an RSA key and it showed up in the Terminal. Now, when I enter the same command, I just get a password prompt. I guess I really want to know how to generate another RSA key if needed in the future.

ThreeBKK 04-26-2007 02:12 PM

If I try the password three times unsuccessfully, I get this returned to me in the Terminal:
Permission denied (publickey,gssapi-with-mic,password).


All times are GMT -5. The time now is 01:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.