FlareOn5 -- FLEGGO

image

记录一下如何用 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)

image

posted @ 2025-12-12 21:36  矛盾空间  阅读(4)  评论(0)    收藏  举报