diff --git a/.gitignore b/.gitignore index 6c02155..f7c556c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.conf venv +.vscode # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/README.md b/README.md index 63be43b..91e7d8f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,23 @@ And many people will be comfortable with YAML configurations! It's almost like J The quickest way to start is to grab a template from the templates folder in this repository.
Make sure to correctly pass the MeshCentral websocket API as `wss:///control.ashx`.
And make sure to fill in the credentails of an account which has remote commands permissions.
-Then make a yaml with a target and some commands! See below examples as a guideline. And do not forget to look at the bottom's notice. +Then make a yaml with a target and some commands! See below examples as a guideline. And do not forget to look at the bottom's notice.
+To install, follow the following commands:
+ +```shell +python3 -m venv ./venv +``` +```shell +source ./venv/bin/activate +cd ./meshbook +``` +```shell +pip3 install -r requirements.txt +``` +Then you can use meshbook, for example: +```shell +python3 meshbook.py -pb examples/ping.yaml +``` # Example: diff --git a/meshbook/examples/ping.yaml b/meshbook/examples/ping.yaml index bc6a11f..0a39d9a 100644 --- a/meshbook/examples/ping.yaml +++ b/meshbook/examples/ping.yaml @@ -3,4 +3,7 @@ name: Ping Multiple Points company: Temp-Agents tasks: - name: Ping Cloudflare - command: "ping 1.1.1.1 -c 4" \ No newline at end of file + command: "ping 1.1.1.1 -c 4" + + - name: Ping Google + command: "ping 8.8.8.8 -c 4" \ No newline at end of file diff --git a/meshbook/meshbook.py b/meshbook/meshbook.py index 5db0c8d..b6d0c72 100644 --- a/meshbook/meshbook.py +++ b/meshbook/meshbook.py @@ -116,7 +116,10 @@ class MeshcallerWebSocket: async def ws_handler(self, uri: str, username: str, password: str): """Main WebSocket connection handler.""" login_string = f'{MeshcallerUtilities.base64_encode(username)},{MeshcallerUtilities.base64_encode(password)}' - ws_headers = {'User-Agent': 'MeshCentral API client', 'x-meshauth': login_string} + ws_headers = { + 'User-Agent': 'MeshCentral API client', + 'x-meshauth': login_string + } if not args.silent: print("Attempting WebSocket connection...") @@ -286,6 +289,7 @@ async def main(): processor_task = asyncio.create_task(processor.receive_processor(python_client)) await MeshcallerActions.process_arguments(python_client, args.playbook) await asyncio.gather(websocket_task, processor_task) + except ScriptEndTrigger as e: if not args.silent: print(e) diff --git a/meshbook/requirements.txt b/meshbook/requirements.txt index 385511c..3d3098d 100644 --- a/meshbook/requirements.txt +++ b/meshbook/requirements.txt @@ -1,6 +1,5 @@ asyncio argparse configparser -json pyyaml websockets \ No newline at end of file