diff --git a/integrations/intezer/manifest.yaml b/integrations/intezer/manifest.yaml new file mode 100644 index 0000000..ca8ddaf --- /dev/null +++ b/integrations/intezer/manifest.yaml @@ -0,0 +1,96 @@ +id: intezer +name: Intezer +version: 1.0.0 +description: "Intezer Analyze (API v2) — genetic malware analysis: analyze files (base64), hashes and URLs, retrieve analysis verdicts, IOCs, metadata and sub-analyses. API-key authentication (exchanged for a short-lived access token); stdlib-only, no extra Python dependencies." +changelog: "1.0.0 — Initial release: analyze by file/hash/URL, analysis result, IOCs, metadata and sub-analyses." +category: enrichment + +config_schema: + properties: + api_key: + type: string + description: "Intezer API key (from your Intezer account)" + x-soar-sensitive: true + required: + - api_key + +commands: + - id: analyze_by_hash + name: intezer-analyze-by-hash + description: "Submit a file hash (SHA256, SHA1 or MD5) for analysis. Returns an analysis_id; poll with intezer-get-file-analysis." + inputs_schema: + properties: + hash: { type: string, description: "File hash" } + required: [hash] + outputs_schema: { properties: {} } + - id: analyze_by_file + name: intezer-analyze-by-file + description: "Submit a file (base64) for analysis. Returns an analysis_id." + inputs_schema: + properties: + file_name: { type: string, description: "File name" } + content_base64: { type: string, description: "File content, base64-encoded" } + required: [file_name, content_base64] + outputs_schema: { properties: {} } + - id: analyze_url + name: intezer-analyze-url + description: "Submit a URL for analysis. Returns an analysis_id (use intezer-get-url-analysis)." + inputs_schema: + properties: + url: { type: string, description: "URL to analyze" } + required: [url] + outputs_schema: { properties: {} } + - id: get_file_analysis + name: intezer-get-file-analysis + description: "Get the result/verdict of a file analysis by ID." + risk: read + inputs_schema: + properties: + analysis_id: { type: string, description: "Analysis ID" } + required: [analysis_id] + outputs_schema: { properties: {} } + - id: get_url_analysis + name: intezer-get-url-analysis + description: "Get the result/verdict of a URL analysis by ID." + risk: read + inputs_schema: + properties: + analysis_id: { type: string, description: "Analysis ID" } + required: [analysis_id] + outputs_schema: { properties: {} } + - id: get_analysis_iocs + name: intezer-get-analysis-iocs + description: "Get the IOCs extracted from a file analysis." + risk: read + inputs_schema: + properties: + analysis_id: { type: string, description: "Analysis ID" } + required: [analysis_id] + outputs_schema: { properties: {} } + - id: get_analysis_metadata + name: intezer-get-analysis-metadata + description: "Get the metadata of a file analysis." + risk: read + inputs_schema: + properties: + analysis_id: { type: string, description: "Analysis ID" } + required: [analysis_id] + outputs_schema: { properties: {} } + - id: get_sub_analyses + name: intezer-get-sub-analyses + description: "List the sub-analyses of a file analysis (per-component genetic breakdown)." + risk: read + inputs_schema: + properties: + analysis_id: { type: string, description: "Analysis ID" } + required: [analysis_id] + outputs_schema: { properties: {} } + + - id: test_connection + name: intezer-test-connection + description: "Verify the API key by obtaining an access token (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/intezer/scripts/analyze_by_file.py b/integrations/intezer/scripts/analyze_by_file.py new file mode 100644 index 0000000..bafa453 --- /dev/null +++ b/integrations/intezer/scripts/analyze_by_file.py @@ -0,0 +1,71 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error, uuid + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + file_name = args.get("file_name") + content_base64 = args.get("content_base64") + if not file_name: + raise Exception("file_name is required") + if not content_base64: + raise Exception("content_base64 is required") + + token = _token() + boundary = "----riposte" + uuid.uuid4().hex + body = ("--" + boundary + "\r\n" + + 'Content-Disposition: form-data; name="file"; filename="' + file_name + '"\r\n' + + "Content-Type: application/octet-stream\r\n\r\n").encode("utf-8") + \ + base64.b64decode(content_base64) + \ + ("\r\n--" + boundary + "--\r\n").encode("utf-8") + headers = { + "Accept": "application/json", + "Authorization": "Bearer " + token, + "Content-Type": "multipart/form-data; boundary=" + boundary, + } + req = urllib.request.Request(API + "/analyze", data=body, headers=headers, method="POST") + with urllib.request.urlopen(req, timeout=120) as r: + raw = r.read() + result = json.loads(raw) if raw else {} + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/analyze_by_hash.py b/integrations/intezer/scripts/analyze_by_hash.py new file mode 100644 index 0000000..15869a0 --- /dev/null +++ b/integrations/intezer/scripts/analyze_by_hash.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + hash_ = args.get("hash") + if not hash_: + raise Exception("hash is required") + result = request("POST", "/analyze-by-hash", body={"hash": hash_}) + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/analyze_url.py b/integrations/intezer/scripts/analyze_url.py new file mode 100644 index 0000000..a02b61c --- /dev/null +++ b/integrations/intezer/scripts/analyze_url.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + url = args.get("url") + if not url: + raise Exception("url is required") + result = request("POST", "/url", body={"url": url}) + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/get_analysis_iocs.py b/integrations/intezer/scripts/get_analysis_iocs.py new file mode 100644 index 0000000..ac55bd3 --- /dev/null +++ b/integrations/intezer/scripts/get_analysis_iocs.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + analysis_id = args.get("analysis_id") + if not analysis_id: + raise Exception("analysis_id is required") + result = request("GET", "/analyses/" + q(analysis_id) + "/iocs") + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/get_analysis_metadata.py b/integrations/intezer/scripts/get_analysis_metadata.py new file mode 100644 index 0000000..3edcde1 --- /dev/null +++ b/integrations/intezer/scripts/get_analysis_metadata.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + analysis_id = args.get("analysis_id") + if not analysis_id: + raise Exception("analysis_id is required") + result = request("GET", "/analyses/" + q(analysis_id) + "/metadata") + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/get_file_analysis.py b/integrations/intezer/scripts/get_file_analysis.py new file mode 100644 index 0000000..a3621f5 --- /dev/null +++ b/integrations/intezer/scripts/get_file_analysis.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + analysis_id = args.get("analysis_id") + if not analysis_id: + raise Exception("analysis_id is required") + result = request("GET", "/analyses/" + q(analysis_id)) + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/get_sub_analyses.py b/integrations/intezer/scripts/get_sub_analyses.py new file mode 100644 index 0000000..6aac50e --- /dev/null +++ b/integrations/intezer/scripts/get_sub_analyses.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + analysis_id = args.get("analysis_id") + if not analysis_id: + raise Exception("analysis_id is required") + result = request("GET", "/analyses/" + q(analysis_id) + "/sub-analyses") + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/get_url_analysis.py b/integrations/intezer/scripts/get_url_analysis.py new file mode 100644 index 0000000..3584bd3 --- /dev/null +++ b/integrations/intezer/scripts/get_url_analysis.py @@ -0,0 +1,52 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + args = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + analysis_id = args.get("analysis_id") + if not analysis_id: + raise Exception("analysis_id is required") + result = request("GET", "/url/" + q(analysis_id)) + print(json.dumps(result)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/intezer/scripts/test_connection.py b/integrations/intezer/scripts/test_connection.py new file mode 100644 index 0000000..34a8abf --- /dev/null +++ b/integrations/intezer/scripts/test_connection.py @@ -0,0 +1,48 @@ +import base64, json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://analyze.intezer.com/api/v2-0" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _token(): + data = json.dumps({"api_key": str(_cfg().get("api_key") or "")}).encode("utf-8") + req = urllib.request.Request(API + "/get-access-token", data=data, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("result"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["result"] + + +def request(method, path, body=None, token=None): + url = API + path + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json", "Authorization": "Bearer " + (token or _token())} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=90) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + _token() + print(json.dumps({"ok": True})) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1)