Jump to content

Interactive Command Prompt


develogy
 Share

Recommended Posts

Hello Everyone,

New here as a registered user, but been reading and learning for several months.

I have a question, I am working on a remote administration tool, and one of the features I would like is a remote command prompt.

The system so far is designed to request messages from the server in our office, and then execute the request on the customers machine. For example download a file, then install it.

With the command prompt I would like to have a window on our tech computer that they can then send commands to the client PC, for example if they send ipconfig /all the system sends the response back to the tech console.

Simple commands like that should be easy enough with StdinWrite.

I am having issues with handling commands that require a command that then based on the response require additional input.

Any Ideas?

Its getting late, but if more clarification is needed let me know.

Thanks for any suggestions

Link to comment
Share on other sites

  • Developers

With the command prompt I would like to have a window on our tech computer that they can then send commands to the client PC, for example if they send ipconfig /all the system sends the response back to the tech console.

Why not use PSEXEC for that which is easily shelled from a script and output captured?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

here is a script i've created for a remote cmd on comptuers.

it uses psexec

#include <GUIConstants.au3>
#include <GuiButton.au3>
#Include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("pc tools", 380, 308, 240, 140 )
GUISetBkColor(0xA6CAF0)

$Tab1 = GUICtrlCreateTab(8, 8, 360, 265)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Remote Push")
$Label1 = GUICtrlCreateLabel("Computer Name", 16, 40, 80, 17)
$Input1 = GUICtrlCreateInput("", 16, 56, 137, 21)
$combo = GUICtrlCreateCombo("", 160, 56, 193, 25)
GUICtrlSetData(-1, "Remote_cmd")
$Button25 = GUICtrlCreateButton("Execute", 280, 80, 73, 57, 0)

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button25
$app = GUICtrlRead($combo)
$pc = GUICtrlRead($Input1)
Call($app, $pc)


;~ remote push tab
Func Remote_cmd($pc)
ShellExecute ("c:\pstools\psexec.exe" , "\\" & $pc &" -u domain\admin -p pwd cmd" )
EndFunc


EndSwitch
WEnd
Link to comment
Share on other sites

My problem is the the computer I intend to be running the command from is across the internet, which rules out psexec.

I don't have code for this yet, as I am looking for ideas at this point.

My train of thought so far is as follows:

A main System Agent program about every minute check with my server for any messages assigned to its system id, if it finds a request for remote command, it will then run another compiled script, that will then on its own check the server for commands, each command it receives it will run, then echo back the response to the server for display back on the tech console. When it receives an "end" it will close.

Does that make sense? do you think its possible, have any suggestions for implementing it?

I have played around with StndIn and while it does write to the console as expected, each command sent is in a new command window.

For example if I use the command "cd C:Dell"

Then Send "dir"

The response back from the "dir" is the directory listing of the folder the script is running in, rather than the "c:Dell" folder as intended.

Link to comment
Share on other sites

  • Developers

When this is across the Internet, doesn't make it pretty unsafe unless you either use some flavour of VPN or SSL encryption?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I intend to have the connection back to the server to be using SSL. Plus if I can implement it like I am hoping, the only connection is from the client computer outbound, so there is less risk of having issues with possible attacks on the command proccessor itself as it would not be exposed.

Link to comment
Share on other sites

I think I may not be explaining myself well enough, because both Kaseya, and DesktopCentral have this feature in them, where a tech can login to the web portal, and pick a machine, then open the Remote Command, and enter commands that are sent to the specified client computer. The security here is in the fact that the commands can only come from the server, and only when the "command processor" program checks for "messages" intended for it, there is no direct access to the client machine or "command processor" program from the internet or otherwise, as yes the client machines are all behind firewalls.

Link to comment
Share on other sites

  • Developers

You should be pretty safe when the PC's "call home" by connecting to a central server via https, retrieving commands and posting results.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...