mIRC Home    About    Download    Register    News    Help

Print Thread
#38819 29/07/03 06:55 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Does anyone know exactly when and how to send the authentication information through a socket when connection to the htaccess protected directory on a webserver. I tried

on *:SOCKOPEN:sockname: {
if ($sockerr) { echo -a 4 error opening socket | return }
sockwrite -n $sockname GET /path/to/prot-dir HTTP/1.1
sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
sockwrite -n $sockname host: www.domain.com
sockwrite -n $sockname Authentication: Basic $encode(username:password, m)
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}

but that only returns the 401 page (when using the same username and password in my web browser, I get access). I also tried waiting for the socket to receive the text

WWW-Authenticate: Basic realm="blahblah"

and then sockwrite the authentication information, but that isn't working either.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#38820 29/07/03 02:33 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Try "Authorization:" instead of "Authentication:".

#38821 29/07/03 04:16 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
not it.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#38822 29/07/03 05:22 PM
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
First off, Online is right, the header you should be sending is Authorization, not Authentication. Other than that it seems, correct. According to RFC2617 which defines both the basic and digest authorization methods:

If the user agent wishes to send the userid "Aladdin" and password "open sesame", it would use the following header field:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

And indeed, //echo -a $encode(Aladdin:open sesame,m) does return that string.

Also, waiting for WWW-Authenticate doesn't seem like a good idea. According to the RFC, the server MAY send this header, but that doesn't mean it has to.

If that doesn't work, what I'd suggest you do is download a little program called netcat and make it "fake" an http server on your machine. You then want to make it send out the stuff to tell your browser to authenticate. Doing this will allow you to see exactly what your browser is sending to the server.

#38823 29/07/03 05:34 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Beats the heck out of me why, but before when I tried with authorization it didn't work, it does work now. tx


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius

Link Copied to Clipboard