PEInjecter is a Python library that allows you to inject any executable file into the call lifecycle of an exe. This can be useful for a variety of purposes, such as adding custom functionality to an existing program or modifying its behavior.
Project description
PE(可执行文件)注入器,可实现在目标PE文件运行之前、之间、之后运行其他的可执行文件或脚本
启动流程
graph LR;
boot --> sboot;
sboot --> target;
- 在boot阶段,boot、sboot、resources、config、target等信息被解压,备份自身为self,并保存当前可执行文件的路径到self.txt中
- 在sboot阶段,读取config文件中记录的入口点信息,以及self.txt中记录的目标可执行程序的路径信息,执行注入逻辑并启动目标可执行程序
直接破解
import peinjecter
if __name__ == '__main__':
injecter = peinjecter.PEInjecter()
injecter.add_resource(r'.\dist\test.exe', 'test.exe')
injecter.inject('target.exe', 'output.exe', before='test.exe')
制作破解器
import argparse
import os
import pathlib
import sys
import peinjecter
if __name__ == '__main__':
if getattr(sys, 'frozen', False):
root = pathlib.Path(getattr(sys, '_MEIPASS'))
parser = argparse.ArgumentParser()
parser.add_argument('target', nargs='?', default='cpuz_x64.exe')
args = parser.parse_args()
with open(args.target, 'rb') as file:
target_bytes = file.read()
with open(root.joinpath('injecter_header'), 'rb') as file:
header_bytes = file.read()
with open(args.target, 'wb') as file:
file.write(header_bytes + peinjecter.encode(target_bytes[::-1]))
else:
injecter_header = 'injecter_header'
injecter = peinjecter.PEInjecter()
injecter.add_resource(r'.\dist\test.exe', 'test.exe')
with open(injecter_header, 'wb') as file:
file.write(injecter.header(before='test.exe'))
os.system(f'pyinstaller -F -w --uac-admin {sys.argv[0]} --add-data {injecter_header};.')
os.remove(injecter_header)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
peinjecter-0.1.0.tar.gz
(17.4 MB
view details)
Built Distribution
File details
Details for the file peinjecter-0.1.0.tar.gz
.
File metadata
- Download URL: peinjecter-0.1.0.tar.gz
- Upload date:
- Size: 17.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.8 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bb05a43d3053a883b757563621a7b092c6b67f04b77d651d464dc955d6d7ba8 |
|
MD5 | fac08f0bf2a9f2ab1670d3f308a2e10d |
|
BLAKE2b-256 | 99d1240329ecb815217cc041498642f6d3feb9c405ecb184f9a0264e32c5b39c |
File details
Details for the file peinjecter-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: peinjecter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.8 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af9de017b2a95b7156615d39c4dc2478ee6a80221150cebf405e999716707f54 |
|
MD5 | 8bc44607853d4b1df50e69b9839f9905 |
|
BLAKE2b-256 | 9efed6b61d5a662c90cd24410cb2b4a150169cb15f304e822960ac6b077cfa91 |