?
Solved

Send user name and pw to server

Posted on 1998-12-06
12
Medium Priority
?
172 Views
Last Modified: 2013-12-25
Hello,
I'm writing a perl script that should save an EE question to my hard disk (for practice. not sure I'll ever use it...). Now, I'm opening sockets and downloading and everything. The problem is that I must supply user name and password.

This is what I've tried:
print SOCKET "GET $page 1.0\nAuthorization: martinag password\n\n";

(no, that isn't my real password...:-))

I've tried a few solutions like this but I can't find the format to use when supplying user name and password.
Could you help me?

And by the way, is this secure? Is it just as secure as when I enter the information in my browser or should I do something (like using crypt) to get it more secure?

Martin
0
Comment
Question by:martinag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
12 Comments
 
LVL 4

Author Comment

by:martinag
ID: 1830012
I've found something at ftp://ftp.ietf.org/internet-drafts/draft-ietf-http-authentication-03.txt about the Authentication-Info header. I guess I should use it, but I don't understand anything of it...

Martin
0
 
LVL 4

Author Comment

by:martinag
ID: 1830013
Ok, think I've understood a bit now...
I think I should
  print SOCKET "GET $page 1.0\nAuthorization: Basic $info\n\n";
where $info is "martinag:password", base64 encoded.

But how do I base64 encode?

Martin
0
 
LVL 7

Expert Comment

by:jconde
ID: 1830014
Hi, in order to do that you must
do the following:

fprintf (socket, "POST /your/page HTTP/1.0\n");
sprintf (tmp,"Authorization: Basic %s\n\n",base64_encode("username:password"));
fprintf (socket, tmp);

0
Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

 
LVL 4

Author Comment

by:martinag
ID: 1830015
Where do I find base64_encode?

Martin
0
 
LVL 4

Author Comment

by:martinag
ID: 1830016
Your code seems like C. Is it? I'm using Perl...

Anyone know about a base 64 function for Perl?

Martin
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1830017
perldoc MIME::Base64

(part of the LWP package, I think)

0
 
LVL 7

Expert Comment

by:jconde
ID: 1830018
Yes it is b2pi, its part of LWP :)
0
 
LVL 4

Author Comment

by:martinag
ID: 1830019
Ok, I visited www.perl.com and looked up LWP but I didn't find any MIME (not even Base64). Anyone got a URL?

Martin
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1830020
0
 
LVL 4

Author Comment

by:martinag
ID: 1830021
I'll give the points to b2pi.

Great url you gave me. I've always wondered where to download all those modules.
BTW, it was http://perl.com/cgi-bin/cpan_mod?module=MIME::Base64 :-)

Martin
0
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1830022
Great.  I love the multiplexor (in spite of my poor cut and paste skills) It also has the advantage of trying to find a server that's geographically (or at least network-wise) 'near' you, in order to increase speed.  You can get more info about it at http://language.perl.com/news/cpan-mux.html, and the source is at http://language.perl.com/misc/cpan_module

0
 
LVL 4

Author Comment

by:martinag
ID: 1830023
Thanks!

Martin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question