FlareOn5 -- FLEGGO

记录一下如何用 pywin32 加载 exe 的资源。
import win32api
import win32con
import os
import subprocess
def load_resource(filename):
password = ''
hModule = win32api.LoadLibraryEx(filename, 0, win32con.LOAD_LIBRARY_AS_DATAFILE)
res = win32api.LoadResource(hModule, 'BRICK', 101)
win32api.FreeLibrary(hModule)
for i in range(0, len(res), 2):
if res[i] == 0 and res[i+1] == 0:
break
password += chr(res[i] + res[i+1] * 0x100)
return password
for file in os.listdir('.'):
if file.endswith('.exe'):
password = load_resource(file)
process = subprocess.Popen(
file,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
)
process.stdin.write((password+'\n').encode())
process.stdin.flush()
stdout, stderr = process.communicate()
print(stdout)


浙公网安备 33010602011771号