Execute Commands on remote computers

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mrandyman.

Hi, I'm new to Purebasic and am trying to write an interface that will allow me to install programs on networked computers at work (i.e. hotfixes, 3rd part apps, etc). Anyways, is there an easy way to accomplish this? Sysinternals has a freeware command that does what I am looking for (http://www.sysinternals.com/ntw2k/freeware/psexec.shtml) I just wanted it to be 100% purbasic if possible.
Andy
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

You can write a little server that is waiting for commands.
Commands that you can specify yourself. When the server receives
the command "EXECUTE c:\cool.exe" for example, it simply starts
a RunProgram() with the argument.
On the client site you write a program that takes such commands
as input and sends it out to the server.
To automate this task you could read all the commands out of a
script file for example.

You can make all you want. For example the server sends the command
"READY." back after the last command was successfully executed, so
the client knows it can send the next command now.
At the end, this could become a complete scripting language to completely
control other PCs over network (control mouse, send screenshots back etc..).

Just do it.

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mrandyman.

yeah...that would have work--I admit.
But i'm trying to send commands to a machine that doesn't have any sort of server installed and is not "anticipating" anything. Thats the challenge.

...then i'll JUST DO IT :),
Andy
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TheBeck.

> i'm trying to send commands to a machine that doesn't have any sort of server installed and is not "anticipating" anything.

Security experts make a living trying to prevent this. There is no way to update software on a remote machine without the remote machine being set up for it, unless you are exploiting security hole.

My suggestion if I may, have your client app download a update.txt file from a predetermined URL. The update.txt need only contain the latest update version number, for the client to check it's self against and the URL for the update file. The client then downloads the update file and runs it to update it's self, if needed.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mrandyman.

UPDATEEXPERT does this ( http://www.stbernard.com/products/updat ... expert.asp ) and I want to do this also.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mrandyman.

given the correct permissions (ie domain admin) this shouldn't be an issue since NT 4.0. i.e. how does Dameware take remote control of a system?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DemonHell.

@mrandyman.
AFAIK, UpdateExpert doesn`t upload/install patches. It`s just a network tool to test for known security vulnerabilities, and from that, it can tell what patch are and aren`t installed on the server.

And as others have said, to try this on machines without them having an "upgrade server" would mean you`d be running very insecure machines.
What would stop others from installing their own DDOS clients etc?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mrandyman.

DemonHell, thanks for the info. I use UPDATEEXPERT at work for DEPLOYMENT on a regular basis. Does it scan? Yes it does? Does it deploy without an "update server"? Absolutely. "UpdateEXPERT enables you to research available fixes, scan your workstations and servers, deploy updates to any number of networked machines - without remote agents - and validate that the job was done right." This is quoted from the makers of Update Expert. Anyways, I'm still looking for a way to "PUSH" software without writing one from scratch.
Thanks,
Andy
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

It is possible on NT-2K-XP machines, using the admin Shares C$ and ADMIN$, and the remote registry connect feature.
The user who does the update must exist on target machine with admin rights.
I use this daily to push Sophos Antivirus from server to workstations.
This uses NetBIOS, so i would not try this over the internet, very unsecure.

You will need API to connect to remote registry, this way you can check what soft is installed.
Writing a file is easy, just open file at '\\remotePC\C$\Program Files\test.exe'
How to run that file.....duno....registry...RPC...i have no idea.


Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DemonHell.
Originally posted by mrandyman

DemonHell, thanks for the info. I use UPDATEEXPERT at work for DEPLOYMENT on a regular basis. Does it scan? Yes it does? Does it deploy without an "update server"? Absolutely
Thanks for the correction mrandyman.

Still trying to get my head around the "update without server" idea.
If UpdateExpert can push updates, what to stop a script kiddie from doing the same??
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mrandyman.

Thanks Berikco. Someonehow there's got to be a way to run it. Demonhell, I know how you feel. The other day at work I created an EXE file that "captured" the install of a custom software package and I executed it on appr. 500 machines. Some users even called and said "Why did my screen turn blue and a setup dialog appear?" The setup was noninteractive but I was in a hurry and didn't install the application "quietly:. Berikco, if I remember correctly UpdateExpert "schedules" the install. Maybe that's how it does it. It connects to the registry and "sets up an appointment". (lol--"The doctor will see you now, Mr Andyman")
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.
Originally posted by mrandyman
if I remember correctly UpdateExpert "schedules" the install. Maybe that's how it does it. It connects to the registry and "sets up an appointment". (lol--"The doctor will see you now, Mr Andyman")
Yep, schedules could be a way to do it.
The schedules are in sysdir\tasks as *.job files
You can remotely add a scheduled task using API or the 'AT' command

You almost got it now mrandyman :)

Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.
Originally posted by DemonHell
Still trying to get my head around the "update without server" idea.
If UpdateExpert can push updates, what to stop a script kiddie from doing the same??
Passwords, that's all that stops a scriptkiddy if your computer is open on the internet. (if you don't have firewall hard/software)
Most users don't know NT-w2k-XP got this C$/Admin$ shares.





Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
Post Reply