27 lines
1016 B
Python
27 lines
1016 B
Python
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
import argparse, base64, hashlib, json, lzma, marshal, os, plistlib, re, struct, subprocess, sys, zipfile, zlib
|
|
|
|
def xor(data, key):
|
|
return bytes(b ^ key[i % len(key)] for i, b in enumerate(data))
|
|
|
|
def find_after(data, marker):
|
|
off = data.index(marker) + len(marker)
|
|
ln = struct.unpack_from('<I', data, off)[0]
|
|
off += 4
|
|
return data[off:off+ln]
|
|
|
|
def walk_consts(co):
|
|
out=[]
|
|
for c in co.co_consts:
|
|
if isinstance(c, str): out.append(c)
|
|
elif hasattr(c, 'co_consts'): out += walk_consts(c)
|
|
return out
|
|
def main():
|
|
ap=argparse.ArgumentParser(); ap.add_argument('wheel', nargs='?', default='../public/wheelhouse_beacon-0.4.2-py3-none-any.whl'); args=ap.parse_args()
|
|
with zipfile.ZipFile(args.wheel) as z:
|
|
stage=lzma.decompress(z.read('wheelhouse_beacon/data/stage_gate.dat'))
|
|
co=marshal.loads(stage[16:])
|
|
print(next(v for v in walk_consts(co) if v.startswith('caplag{')))
|
|
if __name__=='__main__': main()
|