Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > win32 - access shared folder

Reply
Thread Tools

win32 - access shared folder

 
 
Sebastian Scholz
Guest
Posts: n/a
 
      06-29-2004
Hi

I like to do a simple copy to a shared folder, which is basically no problem
until the user is not connected to the maschine and has to enter a username
and password.

copy("c:/test.htm","//192.168.1.192/wwwroot/test.htm");

The shared folder needs a login with login information that the user is not
suppose to have, so the login data has to be hard coded. What do I have to
do that the script does an automatic login ?

Thanks,

Sebastian


 
Reply With Quote
 
 
 
 
MrReallyVeryNice
Guest
Posts: n/a
 
      06-30-2004
First of all, let me offer you a little _untested_ sample script that will
hopefully help you:

--- Beginning ---
use strict;
use warnings;

my $IP=192.168.1.192; # define $IP to match your environment
my $ShareName='wwwroot'; # define $ShareName to match your environment
my $UserName='Administrator'; # define $UserName to match your environment
my $Password='SensitivePassword'; # define $UserName to match your
environment

# the following net use should connect to the share using the credentials
# defined for $UserName and $Password.
system ("net use \\\\$IP\\$ShareName /u:$IP\\$UserName $Password");
#you should now have access to the share and should be able to copy your
file over
system ("copy client.pl \\\\$IP\\$ShareName\\*.*");

--- End -----


Not being a native english speaker, I must admit that I'm slightly shooting
dark because the following statment is ambiguous (to me):

"The shared folder needs a login with login information that the user is not
suppose to have, so the login data has to be hard coded. What do I have to
do that the script does an automatic login ?"

Let me try to address what I believe to be your concern. As you requested,
if you hard code the login data (username/password) in the script, it is
really not secure. It is pretty much equivalent to handing over the
information to the end user running the script. Of course you might be in an
environment where users are not computer literate but it is only a matter of
time before one user reads your source code and figure out the
username/password.

You will find many threads concerning 'hidding' your source code. Run the
command 'perldoc -q hide' on your system or google. The bottom line is that
there is no way to hide the information once the script is running on the
user machine. You can try to create an executable or to offuscate the info,
however, another person with a bit of motivation and knowledge will
eventually reverse engineer your code. My purpose is not to scare you but
to make you aware. Writing a script containing a sensitive username and
password is just not secure.

To 'minimize' the risk, you might want to create a generic user that is
limited to writing to the share that you want the user to access. Don't use
any sensitive user belonging to your administrators group. Also, you
have to realize that upon exit of the sample script provided above, the
connection to the share will still be there. You should consider removing
the connection to the share:

system ("net use \\\\$IP\\$ShareName /d"); # untested code


Don't hesitate to ask further questions or to report problems/success.

MrReallyVeryNice


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fix folder picture in a shared folder across network Talista Computer Support 1 01-23-2009 07:53 PM
SOLVED - windows xp rename folder within shared folder, notrefreshing window jameshanley39@yahoo.co.uk Computer Information 0 07-30-2008 06:33 PM
Cannot view/access new laptop shared folder on network T5 Wireless Networking 3 03-20-2006 08:52 PM
I can see the shared folder but can't access it =?Utf-8?B?c2FyYWZpbmE2Mw==?= Wireless Networking 1 02-03-2006 05:22 PM
Problem with access to shared memory(W2K) / ORIGINALLY (win32) speedfan api control Thomas Heller Python 6 04-08-2005 11:59 PM



Advertisments