完成reg导入

This commit is contained in:
cxykevin 2024-02-10 17:32:07 +08:00
parent d96152e87b
commit a83a627a11
4 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,4 @@
dist\PEinjector.7z: src\main.py src\log.py src\config.py src\loader.py src\utils.py root\VentoyAutoRun.bat
dist\PEinjector.7z: src\main.py src\log.py src\action.py src\hook.pyw src\makelnk.py src\regwrite.py src\config.py src\loader.py src\utils.py root\VentoyAutoRun.bat
mkdir tmp\pkg\PEinjector\env
mkdir tmp\pkg\PEinjector\src
mkdir tmp\pkg\PEinjector\tool

View File

@ -21,6 +21,8 @@
# | 6 |path,icon,name| make shortcut on Desktop |
# +----+--------------+--------------------------+
# | 7 | path | add <path> to %PATH% |
# +----+--------------+--------------------------+
# | 8 | regpath | add file to reg |
# '----+--------------+--------------------------'
@ -167,4 +169,10 @@ def do_action(actions_list):
except:
actionlogs = actionlogs + \
f" add path \"{i[1]}\" failed: {repr(exp)}\r\n"
elif i[0] == 8:
try:
regwrite.add_reg(i[1])
except:
actionlogs = actionlogs + \
f" add reg \"{i[1]}\" failed: {repr(exp)}\r\n"
return actionlogs

View File

@ -267,6 +267,12 @@ def load_package(pkg_name):
i = pkg_path + \
"/"+i
actions["onload"].append((7, i))
if "reg" in file_json:
for i in file_json["reg"]:
if len(i) < 2 or i[1] != ':':
i = pkg_path + \
"/"+i
actions["onload"].append((8, i))
def load():

View File

@ -4,6 +4,7 @@
import winreg
import log
import os
def add_path(path):
@ -17,3 +18,8 @@ def add_path(path):
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, winreg.KEY_WRITE) as key:
winreg.SetValueEx(key, "Path", 0, winreg.REG_EXPAND_SZ, new_path)
def add_reg(regpath):
log.info(f"add reg \"{regpath}\"")
assert os.system(f"reg import \"{regpath.replace("/", "\\")}\"") == 0