jerebenz Posted September 30, 2011 Share Posted September 30, 2011 Dear All, I want to create an Autoit program that I can install on all the computer I manage (200). I want this program to be able to run autoit code. I searched on the forum without success, even if I think it allready has been done. Does anyone has a tip for me ? Best Regards, Jerebenz Link to comment Share on other sites More sharing options...
hannes08 Posted September 30, 2011 Share Posted September 30, 2011 Hi jerebenz, what you try to accomplish might be a dangerous thing. But if you wan to do that, you'll need several things: A TCP Client Lots (200) of TCP Servers The RunFromMemory UDF (maybe?) The Service UDF And a good encryption. Look at the help file for TCP*() functions there you will find examples for the first two points. Your first step maybe to get you Server application (which is located on the clients) to write the .au3 file to disk and then run it. Second step to run the application as service. Third step to run the AutoIT Code from memory. Fourth step to implement security into your project (See _Crypt*() function in the halpfile) Good luck! Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
jerebenz Posted September 30, 2011 Author Share Posted September 30, 2011 Thanks hannes08, I'll take a look at the TCP functions. Link to comment Share on other sites More sharing options...
jerebenz Posted January 23, 2012 Author Share Posted January 23, 2012 Hello All, I'm back after more than one year ! I've finaly taken a look at the TCP function and I've made a little Client / Server script that can do what I wanted. Just want to share with you guys. So with this script, you can run the server on computer 1, launch the client on computer 2 and execute a script on computer 1. Info 1 : I tested the code on windows 7. Info 2 : You need to put AutoIt3.exe (you can find it in the AutoIt folder) in the same folder of the script before compiling Info 3 : I encrypted the data on the network, so you should be safe (I guess..) Info 4 : The code is very uglu, so it can largely be improved Info 5 : That a lot of infos ! The server : expandcollapse popup#include <Crypt.au3> Global $MainSocket, $ConnectedSocket Global $ReceivedCode = "" FileInstall("AutoIt3.exe", "AutoIt3.exe") _Crypt_Startup() ServerStart() While 1 WaitConnection() WEnd Func ServerStart() $ServerIP = "127.0.0.1" $Port = 80 TCPStartup() $MainSocket = TCPListen($ServerIP, $Port, 5000) EndFunc Func ServerStop() CloseConnection() SimpleConsole("Shuting down TCP server") TCPShutdown() _Crypt_Shutdown() Exit EndFunc Func CloseConnection() SimpleConsole("Closing socket") TCPCloseSocket($ConnectedSocket) EndFunc Func WaitConnection() Do Sleep(100) $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 SimpleConsole("Incoming connection : " & $ConnectedSocket) WaitData() EndFunc Func WaitData() While 1 $ReceivedCode = BinaryToString(_Crypt_DecryptData(TCPRecv($ConnectedSocket, 4194304, 1), "password", $CALG_AES_256)) If $ReceivedCode <> "ÿÿÿÿ" Then Switch $ReceivedCode Case "close" CloseConnection() ExitLoop Case "shutdown" ServerStop() Case Else ExecuteCode() EndSwitch EndIf Sleep(100) WEnd EndFunc Func SimpleConsole($message) ConsoleWrite($message & @CRLF) EndFunc Func ExecuteCode() Local $CodeFile = FileOpen(@ScriptDir & "\code.au3", 2) Sleep(100) FileWrite($CodeFile, $ReceivedCode) Sleep(100) FileClose($CodeFile) Sleep(100) RunWait("""" & @ScriptDir & "\AutoIt3.exe"" """ & @ScriptDir & "\code.au3""", @ScriptDir) FileDelete(@ScriptDir & "\code.au3") EndFunc And the Client That can execute code on the server (with the exemple code, you can run the client and server on the same computer to test) expandcollapse popup#include <Crypt.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> TCPStartup() _Crypt_Startup() $ServerIP = "127.0.0.1" $ServerPort = 80 $ConnectedSocket = TCPConnect($ServerIP, $ServerPort) If @error Then MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error) Else $CodeGUI = GUICreate("Connected to Server : " & $ServerIP, 800, 650) $CodeGUIEdit = GUICtrlCreateEdit("msgbox(0, """", ""Hello World !"")", -1, -1, 800, 600) $CodeGUISendButton = GUICtrlCreateButton('Send', 10, 610) $CodeGUICancelButton = GUICtrlCreateButton('Cancel', 60, 610) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $CodeGUICancelButton ExitLoop Case $msg = $CodeGUISendButton $szData = GUICtrlRead($CodeGUIEdit) TCPSend($ConnectedSocket, _Crypt_EncryptData($szData, "password", $CALG_AES_256)) If @error Then ExitLoop EndSelect Sleep(100) WEnd $szData = "close" TCPSend($ConnectedSocket, _Crypt_EncryptData($szData, "password", $CALG_AES_256)) Sleep(100) GUIDelete() _Crypt_Shutdown() EndIf See you !Server.au3Client.au3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now