Solved

Remotely login on a LAN with Perl Win32

Posted on 2000-02-24
15
243 Views
Last Modified: 2010-05-18
Hi

I have a simple problem:

I want to be able to login on a remote machine on my LAN and be able
to launch/kill programs on this machine.

I have looked at all the CPAN modules for Win32, but none is about
remote login.

Do you know a simple way to do that?
Thanks a lot
0
Comment
Question by:gaggio
  • 7
  • 4
  • 2
  • +1
15 Comments
 
LVL 1

Author Comment

by:gaggio
ID: 2555488
Well, I should have added that all the machines are Windows NT4 machines (SP6)!
0
 
LVL 1

Expert Comment

by:omere
ID: 2556114
Depending on what kind of programs you want to run remotely, you
can probably take the easy route to solving this.

You can use the "at" command to time a program to run at a specific
time, thus you can schedule a command to run, say, 5 seconds after
timing it - thereby actually "launching" it.

You can use the same thing in order to kill a program remotely, however,
the BackOffice Resource Kit contains an executable that will do this for you,
or alternatively you can use rclient (you need rconsole installed on the remote machine) to issue a command remotely.

You can also use rexec on NT, again, it comes with the BORK.

Good luck.
0
 
LVL 3

Expert Comment

by:jyu_88
ID: 2556218
you can use at to issue schdule job remotely.
1) to list scheduled job at \\remoteServer
at \\remoteServer
2) to schedule one if permission allow
at \\remoteServer 06:00 /every:M,T d:\perl\myJobPerl.bat

/pub/CPAN/modules/by-category/22_Microsoft_Windows_Modules/Win32/Win32_AdminMisc_v961016.zip
will allow you impersonate NT user and start process. didn't mention kill process though.

libwin32-0.15.zip at same dir containx win32/Process extension, hope you can find it there.
0
 
LVL 1

Author Comment

by:gaggio
ID: 2556251
Ok, well, thanks a lot.
You seem to know a lot more than me, although I have been using NT for quite a while.
I did not know anything about the at command.
I'll try that tomorrow and will let you know.
What is weird is that I have already the module libwin32 and adminmisc.
The documentation is so poorly written!

I would appreciate if you could give more code, though. Isn't there anything
Perl Specific (at command is not perl!).

Thanks
0
 
LVL 1

Expert Comment

by:omere
ID: 2556281
There is no way to remotely execute a command on an NT machine w-o using some sort of service/daemon running on that machine. Since writing a daemon in Perl, just for this purpose, seems like overkill - why not use the tools that already exist. If you don't want to use at, use rexec or rclient.

Note that both of those need additional services installed on the NT machine (rexec/rconsole), while at just needs the schedule service to be started on the NT machine.

The best way to do something is the right way to do it, you don't
_have_ to use Perl for everything.

If you really must use Perl, you can start the schedule service with it :)
use Win32::Service;
StartService($machine, $serviceName);

Again, you could always use xnet which lets you start services remotely (as well as modify them) - another NT Resource Kit utility (not BORK)
0
 
LVL 1

Author Comment

by:gaggio
ID: 2558174
Thanks
But what the hell is BORK, and where can you get the NT Resource Kit Utility? Is that free?
0
 
LVL 1

Expert Comment

by:omere
ID: 2558279
BORK = BackOffice Resource Kit
It's not the same as the NT Resource Kit (Server/Workstation) - it contains tools and utlities that deal with MS's BackOffice (BO, ahem) applications (Exchange, SMS, SNA, SQL etc).

You get it if you have a TechNet subscription (or an MSDN subscription, obviously) - and they hand these out at a lot of conventions around here, so I guess you can probably find these utilities at their site, look for "xnet" or "winat" (GUI version of at, from the RK)
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:gaggio
ID: 2558316
Jyu, you were talking about AdminMisc.
I have NO documentation at all for this module. Where can I find that?

I tried the at command, but there is one drawback: I need to find some way to get the exact current time (so that I can launch, as suggested, a program let's say, 5sec after the at command has been issued).

The computers on the network are not time-synchronized, AFAIK. So, how can I solve this problem?
0
 
LVL 3

Expert Comment

by:jyu_88
ID: 2558401
set a scheduled job on your NT box(es) to run the following:
net time \\YourDomainController /set /y
Depends on how critical is your time coordination, you may want to run it once a day, a week, an hour, whatever.

This will at least sync all boxes to one single source, i.e., relative time will be right. The DomainController or whatever machine provide this time service should sync with some external source to get the absolute time right, right.

'time /T' at command line will get you the current time.
0
 
LVL 1

Expert Comment

by:fragtastic
ID: 2558637
Just thought I'd chip in a bit of info. For documentation on AdminMisc take a look at http://www.roth.net/perl/adminmisc/
0
 
LVL 1

Expert Comment

by:fragtastic
ID: 2558651
ooops, should have read a bit more.

Instead of using the at command, why not use soon?

It works exactly like at, except you don't have to give it a fixed time, just a number of seconds from now to launch the command.

e.g

soon \\pdc 20 notepad.exe

will start notepad on machine pdc 20 seconds after it recieves the soon command.

You don't have to worry about the clocks matching then :)
0
 
LVL 1

Author Comment

by:gaggio
ID: 2558699
Hey!
Thanks A LOT for all those comments.
They are all very useful.

Soon seems actually better, but I'm sorry, I don't have the soon command.
Where do you get this one?

Also, fragtastic, thanks very much for this pointer to very good documentation.
I printed the whole manual for AdminMisc, and it is pretty big!
0
 
LVL 1

Author Comment

by:gaggio
ID: 2566714
Finally...
Well, you all helped me a lot.
I think everybody would deserve some points,
but I don't know who I have to pick, since
I learned a lot, but did not finally use any idea
posted here.

All the AT-type commands are crap: the WinNT
scheduler is not very slick. I even found a free
utility called atonce.exe which is a lot better than soon.exe, but still works only half of the time.

So...
I came back to my Perl, and wrote, QUICKLY, my own Perl little server, which will run on each machine I will administrate.
Now, there is NO delay anymore, and each command is reliably sent, from any Internet connected machine.

Isn't that cool?
0
 
LVL 1

Accepted Solution

by:
omere earned 50 total points
ID: 2566737
Make sure you secure it properly, you wouldn't want anyone to be able to sniff commands sent to it and then kill off your processes. SSL might be the easiest way to go (gift-wrap your packets).

Yes, the NT scheduler is ****. There is a new one that you can use if you install IE4 (or above), called Task Scheduler. That one actually works, but I haven't touched it yet and have no clue on how to schedule tasks from the command line.

BTW, you can kill processes remotely on NT machines (with a resource kit utility) - called rkill (how original) and comes with resource kit pro (or RK Pro 2000, forgot).
0
 
LVL 1

Author Comment

by:gaggio
ID: 2569554
Omere, you have been helping me the most. Thanks, you deserve the points!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now