feat(harfanglab): HarfangLab EDR integration (71 analyst commands)
Endpoint management & isolation, policy assignment, IOC & whitelist (threat intelligence), security-event triage, telemetry hunting (processes, network, DNS, authentications, event logs, binaries), hash threat hunting, and forensic collection jobs (pipes, prefetch, run keys, scheduled tasks, drivers, services, processes, network, sessions, WMI, IOC scan, artifacts, RAM dump) plus their result-retrieval commands. Script-based (urllib, INTEGRATION_SECRETS/INPUTS contract; Authorization: Token header). Platform-specific XSOAR mirroring/fetch commands intentionally excluded.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
source_name = inputs.get("source_name")
|
||||
ioc_value = inputs.get("ioc_value")
|
||||
ioc_type = inputs.get("ioc_type")
|
||||
ioc_status = inputs.get("ioc_status")
|
||||
|
||||
sources = request("GET", base + "/api/data/threat_intelligence/IOCSource/" + qs({"search": source_name}), headers)
|
||||
sid = None
|
||||
for s in sources.get("results", []):
|
||||
if s.get("name") == source_name:
|
||||
sid = s.get("id")
|
||||
|
||||
existing = request("GET", base + "/api/data/threat_intelligence/IOCRule/" + qs({"source_id": sid, "search": ioc_value}), headers)
|
||||
if existing.get("count", 0) > 0:
|
||||
print(json.dumps({"message": "IOC " + str(ioc_value) + " already exists in source " + str(source_name)}))
|
||||
return
|
||||
|
||||
testing_status = "in_progress" if ioc_status == "testing" else None
|
||||
body = {
|
||||
"type": ioc_type,
|
||||
"value": ioc_value,
|
||||
"comment": inputs.get("ioc_comment", ""),
|
||||
"source_id": sid,
|
||||
"hl_status": ioc_status,
|
||||
"hl_local_testing_status": testing_status,
|
||||
}
|
||||
out = request("POST", base + "/api/data/threat_intelligence/IOCRule/", headers, body)
|
||||
print(json.dumps(out))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
method = str(inputs.get("api_method", "GET")).upper()
|
||||
endpoint = inputs.get("api_endpoint", "/api/version")
|
||||
params = {}
|
||||
raw = inputs.get("parameters")
|
||||
if raw:
|
||||
for tok in str(raw).split("&"):
|
||||
kv = tok.split("=", 1)
|
||||
if len(kv) == 2:
|
||||
params[kv[0]] = kv[1]
|
||||
body = None
|
||||
if inputs.get("data"):
|
||||
body = json.loads(inputs.get("data"))
|
||||
url = base + endpoint + qs(params)
|
||||
print(json.dumps(request(method, url, headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,59 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
policy = inputs.get("policy")
|
||||
agentid = inputs.get("agentid")
|
||||
res = request("GET", base + "/api/data/endpoint/Policy/" + qs({"search": policy}), headers)
|
||||
pid = None
|
||||
for p in res.get("results", []):
|
||||
if p.get("name") == policy:
|
||||
pid = p.get("id")
|
||||
break
|
||||
if pid is not None:
|
||||
out = request("POST", base + "/api/data/endpoint/Policy/" + str(pid) + "/add_agents/", headers, {"agent_ids": [agentid]})
|
||||
print(json.dumps({"message": "Policy " + str(policy) + " assigned to agent " + str(agentid), "result": out}))
|
||||
else:
|
||||
print(json.dumps({"error": "Unknown policy " + str(policy)}))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
eid = inputs.get("security_event_id")
|
||||
status = str(inputs.get("status", "")).lower()
|
||||
m = {
|
||||
"new": "new",
|
||||
"investigating": "investigating",
|
||||
"false positive": "false_positive",
|
||||
"closed": "closed",
|
||||
}
|
||||
new_status = m.get(status, status)
|
||||
ids = eid if isinstance(eid, list) else [eid]
|
||||
body = {"ids": ids, "new_status": new_status}
|
||||
url = base + "/api/data/alert/alert/Alert/tag/"
|
||||
result = request("POST", url, headers, body)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/endpoint/Agent/" + str(inputs.get("agent_id")) + "/deisolate/"
|
||||
result = request("POST", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,61 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
source_name = inputs.get("source_name")
|
||||
ioc_value = inputs.get("ioc_value")
|
||||
|
||||
sources = request("GET", base + "/api/data/threat_intelligence/IOCSource/" + qs({"search": source_name}), headers)
|
||||
sid = None
|
||||
for s in sources.get("results", []):
|
||||
if s.get("name") == source_name:
|
||||
sid = s.get("id")
|
||||
|
||||
existing = request("GET", base + "/api/data/threat_intelligence/IOCRule/" + qs({"source_id": sid, "search": ioc_value}), headers)
|
||||
if existing.get("count", 0) > 0:
|
||||
ioc_id = str(existing["results"][0]["id"])
|
||||
request("DELETE", base + "/api/data/threat_intelligence/IOCRule/" + ioc_id + "/", headers)
|
||||
print(json.dumps({"message": "IOC " + str(ioc_value) + " removed from source " + str(source_name)}))
|
||||
else:
|
||||
print(json.dumps({"message": "IOC " + str(ioc_value) + " does not exist in source " + str(source_name)}))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/endpoint/Agent/" + qs({"hostname": inputs.get("hostname"), "limit": 10000, "offset": 0})
|
||||
result = request("GET", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/endpoint/Agent/" + str(inputs.get("agent_id")) + "/"
|
||||
result = request("GET", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/search/Search/explorer_with_list/" + qs({"values": inputs.get("hash"), "type": "hash"})
|
||||
result = request("GET", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/telemetry/Processes/" + qs({"hashes.sha256": inputs.get("hash")})
|
||||
result = request("GET", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/investigation/hunting/Process/" + qs({"binaryinfo.binaryinfo.sha256": inputs.get("hash")})
|
||||
result = request("GET", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/endpoint/Agent/" + str(inputs.get("agent_id")) + "/isolate/"
|
||||
result = request("POST", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "collectRAWEvidences", "params": {"hives": True, "evt": True, "mft": True, "prefetch": True, "usn": True, "logs": True, "fs": True}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "downloadFile", "params": {"filename": inputs.get("filename")}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "collectRAWEvidences", "params": {"hives": False, "evt": True, "mft": False, "prefetch": False, "usn": False, "logs": False, "fs": False}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "collectRAWEvidences", "params": {"hives": False, "evt": False, "mft": False, "prefetch": False, "usn": False, "logs": False, "fs": True}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "collectRAWEvidences", "params": {"hives": True, "evt": False, "mft": False, "prefetch": False, "usn": False, "logs": False, "fs": False}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "collectRAWEvidences", "params": {"hives": False, "evt": False, "mft": False, "prefetch": False, "usn": False, "logs": True, "fs": False}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "collectRAWEvidences", "params": {"hives": False, "evt": False, "mft": True, "prefetch": False, "usn": False, "logs": False, "fs": False}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"targets": {"agents": [inputs.get("agent_id")]},
|
||||
"actions": [{"value": "memoryDumper", "params": {}}],
|
||||
}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getLoadedDriverList", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
out = []
|
||||
for jid in csv(inputs.get("ids")):
|
||||
out.append(request("GET", base + "/api/data/Job/" + jid, headers))
|
||||
print(json.dumps(out))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,66 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
size = None
|
||||
if inputs.get("filesize"):
|
||||
size = int(inputs.get("filesize"))
|
||||
elif inputs.get("hash_filesize"):
|
||||
size = int(inputs.get("hash_filesize"))
|
||||
values = []
|
||||
if inputs.get("filename"):
|
||||
values.append({"global": False, "size": size, "type": "filename", "value": inputs.get("filename")})
|
||||
if inputs.get("filepath"):
|
||||
values.append({"global": False, "type": "filepath", "value": inputs.get("filepath")})
|
||||
if inputs.get("hash"):
|
||||
values.append({"global": False, "size": size, "type": "hash", "value": inputs.get("hash")})
|
||||
if inputs.get("registry"):
|
||||
values.append({"global": False, "type": "registry", "value": inputs.get("registry")})
|
||||
if inputs.get("filepath_regex"):
|
||||
values.append({"global": False, "type": "regex", "value": inputs.get("filepath_regex")})
|
||||
if values and inputs.get("search_in_path"):
|
||||
values.append({"global": True, "type": "path", "value": inputs.get("search_in_path")})
|
||||
PARAMS = {"values": values}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "IOCScan", "params": PARAMS}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getProcessList", "params": {"getConnectionsList": True, "getHandlesList": False, "getSignaturesInfo": True}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getNetworkShare", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "persistanceScanner", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getPipeList", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getPrefetch", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getProcessList", "params": {"getConnectionsList": False, "getHandlesList": False, "getSignaturesInfo": True}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getHives", "params": {"bSystemHives": True, "bUsersHives": True, "bWantSlowPlugins": False}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getScheduledTasks", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getHives", "params": {"bSystemHives": True, "bUsersHives": True, "bWantSlowPlugins": False}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getSessions", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getStartupFileList", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {"targets": {"agents": [inputs.get("agent_id")]}, "actions": [{"value": "getWMI", "params": {}}]}
|
||||
print(json.dumps(request("POST", base + "/api/data/Job/", headers, body)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/artefact/Artefact/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Driver/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/ioc/IOC/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Process/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/NetworkShare/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/PersistanceFile/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Pipe/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Prefetch/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Process/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/RunKey/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/ScheduledTaskXML/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Service/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Session/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Startup/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,47 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
url = base + "/api/data/investigation/hunting/Wmi/" + qs({"limit": 10000, "job_id": inputs.get("job_id")})
|
||||
print(json.dumps(request("GET", url, headers)))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,58 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"source_address": inputs.get("source_address"),
|
||||
"success": inputs.get("success"),
|
||||
"source_username": inputs.get("source_username"),
|
||||
"target_username": inputs.get("target_username"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
result = request("GET", base + "/api/data/telemetry/authentication/AuthenticationLinux/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,58 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"source_address": inputs.get("source_address"),
|
||||
"success": inputs.get("success"),
|
||||
"source_username": inputs.get("source_username"),
|
||||
"target_username": inputs.get("target_username"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
result = request("GET", base + "/api/data/telemetry/authentication/AuthenticationMacos/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,70 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
hostname = inputs.get("hostname")
|
||||
fd = inputs.get("from_date")
|
||||
td = inputs.get("to_date")
|
||||
limit = int(inputs.get("limit") or 3)
|
||||
counts = {}
|
||||
for (system, path, extra) in [
|
||||
("windows", "/api/data/telemetry/authentication/AuthenticationWindows/", {"windows.logon_type": 2}),
|
||||
("linux", "/api/data/telemetry/authentication/AuthenticationLinux/", {}),
|
||||
("macos", "/api/data/telemetry/authentication/AuthenticationMacos/", {}),
|
||||
]:
|
||||
params = {
|
||||
"agent.hostname": hostname,
|
||||
"@event_create_date__gte": fd,
|
||||
"@event_create_date__lte": td,
|
||||
}
|
||||
params.update(extra)
|
||||
data = request("GET", base + path + qs(params), headers)
|
||||
for a in data.get("results", []):
|
||||
u = a.get("target_username")
|
||||
if u:
|
||||
counts[(system, u)] = counts.get((system, u), 0) + 1
|
||||
ranked = sorted(counts.items(), key=lambda kv: kv[1], reverse=True)
|
||||
out = [{"Username": u, "System": s, "Authentication attempts": c} for (s, u), c in ranked[:limit]]
|
||||
print(json.dumps(out))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"source_address": inputs.get("source_address"),
|
||||
"success": inputs.get("success"),
|
||||
"source_username": inputs.get("source_username"),
|
||||
"target_username": inputs.get("target_username"),
|
||||
"windows.logon_title": inputs.get("logon_title"),
|
||||
"windows.logon_type": inputs.get("logon_type"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
result = request("GET", base + "/api/data/telemetry/authentication/AuthenticationWindows/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,59 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
def hash_param(h):
|
||||
n = len(h or "")
|
||||
t = "sha256" if n == 64 else "sha1" if n == 40 else "md5" if n == 32 else None
|
||||
return {("hashes." + t): h} if t else {}
|
||||
|
||||
params = {
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
params.update(hash_param(inputs.get("hash")))
|
||||
result = request("GET", base + "/api/data/telemetry/Binary/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,56 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"requested_name": inputs.get("requested_name"),
|
||||
"query_type": inputs.get("query_type"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
result = request("GET", base + "/api/data/telemetry/DNSResolution/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,55 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"event_id": inputs.get("event_id"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
result = request("GET", base + "/api/data/telemetry/FullEventLog/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,58 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"saddr": inputs.get("source_address"),
|
||||
"sport": inputs.get("source_port"),
|
||||
"daddr": inputs.get("destination_address"),
|
||||
"dport": inputs.get("destination_port"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
result = request("GET", base + "/api/data/telemetry/Network/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,49 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
# === per-command logic ===
|
||||
url = base + "/api/data/telemetry/Processes/" + str(inputs.get("process_uuid")) + "/graph/"
|
||||
result = request("GET", url, headers)
|
||||
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)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
def hash_param(h):
|
||||
n = len(h or "")
|
||||
t = "sha256" if n == 64 else "sha1" if n == 40 else "md5" if n == 32 else None
|
||||
return {("hashes." + t): h} if t else {}
|
||||
|
||||
params = {
|
||||
"agent.hostname": inputs.get("hostname"),
|
||||
"@event_create_date__gte": inputs.get("from_date"),
|
||||
"@event_create_date__lte": inputs.get("to_date"),
|
||||
"limit": int(inputs.get("limit") or 100),
|
||||
}
|
||||
params.update(hash_param(inputs.get("hash")))
|
||||
result = request("GET", base + "/api/data/telemetry/Processes/" + qs(params), headers)
|
||||
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)
|
||||
@@ -0,0 +1,58 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
body = {
|
||||
"comment": inputs.get("comment"),
|
||||
"sigma_rule_id": inputs.get("sigma_rule_id", ""),
|
||||
"target": inputs.get("target", "all"),
|
||||
"criteria": [{
|
||||
"case_insensitive": inputs.get("case_insensitive", True),
|
||||
"field": inputs.get("field"),
|
||||
"operator": inputs.get("operator", "eq"),
|
||||
"value": inputs.get("value"),
|
||||
}],
|
||||
}
|
||||
result = request("POST", base + "/api/data/threat_intelligence/WhitelistRule/", headers, body)
|
||||
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)
|
||||
@@ -0,0 +1,56 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
wid = str(inputs.get("id"))
|
||||
url = base + "/api/data/threat_intelligence/WhitelistRule/" + wid + "/"
|
||||
data = request("GET", url, headers)
|
||||
data.setdefault("criteria", []).append({
|
||||
"case_insensitive": inputs.get("case_insensitive", True),
|
||||
"field": inputs.get("field"),
|
||||
"operator": inputs.get("operator", "eq"),
|
||||
"value": inputs.get("value"),
|
||||
})
|
||||
out = request("PUT", url, headers, data)
|
||||
print(json.dumps(out))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,48 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
wid = str(inputs.get("id"))
|
||||
request("DELETE", base + "/api/data/threat_intelligence/WhitelistRule/" + wid + "/", headers)
|
||||
print(json.dumps({"message": "Whitelist " + wid + " deleted"}))
|
||||
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,53 @@
|
||||
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def request(method, url, headers, body=None):
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
raw = resp.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def qs(params):
|
||||
clean = {}
|
||||
for k, v in params.items():
|
||||
if v is None or v == "" or v == []:
|
||||
continue
|
||||
if isinstance(v, bool):
|
||||
v = "true" if v else "false"
|
||||
clean[k] = v
|
||||
return ("?" + urllib.parse.urlencode(clean)) if clean else ""
|
||||
|
||||
|
||||
def csv(v):
|
||||
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
||||
|
||||
|
||||
def main():
|
||||
secrets = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
base = secrets.get("url", "").rstrip("/")
|
||||
headers = {
|
||||
"Authorization": "Token " + secrets.get("api_token", ""),
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
result = request("GET", base + "/api/data/threat_intelligence/WhitelistRule/" + qs({
|
||||
"offset": 0,
|
||||
"limit": 100,
|
||||
"search": inputs.get("keyword"),
|
||||
"ordering": "-last_update",
|
||||
"provided_by_hlab": inputs.get("provided_by_hlab", False),
|
||||
}), headers)
|
||||
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)
|
||||
Reference in New Issue
Block a user