From 77c29132ea68b8a90d6cbe071ddf5ec93c47a636 Mon Sep 17 00:00:00 2001 From: i128 Date: Tue, 26 Jul 2022 14:49:16 -0500 Subject: [PATCH] Update sccmwtf.py Added some minor error checking on requests --- sccmwtf.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sccmwtf.py b/sccmwtf.py index 49ea36a..10665ab 100755 --- a/sccmwtf.py +++ b/sccmwtf.py @@ -132,11 +132,16 @@ def sendCCMPostRequest(self, data, auth=False, username="", password=""): r = requests.request("CCM_POST", f"{self._serverURI}/ccm_system_windowsauth/request", headers=headers, data=data, auth=HttpNtlmAuth(username, password)) else: r = requests.request("CCM_POST", f"{self._serverURI}/ccm_system/request", headers=headers, data=data) - - multipart_data = decoder.MultipartDecoder.from_response(r) - for part in multipart_data.parts: - if part.headers[b'content-type'] == b'application/octet-stream': - return zlib.decompress(part.content).decode('utf-16') + + if r.status_code == 200: + multipart_data = decoder.MultipartDecoder.from_response(r) + for part in multipart_data.parts: + if part.headers[b'content-type'] == b'application/octet-stream': + return zlib.decompress(part.content).decode('utf-16') + elif r.status_code == 403: + print(f"[!] Unauthorized!") + else: + print(f"[!] Unexpected Error code from SCCM Server: {r.status_code}") def requestPolicy(self, url, clientID="", authHeaders=False, retcontent=False): headers = {