完成reg导入
This commit is contained in:
parent
d96152e87b
commit
a83a627a11
2
Makefile
2
Makefile
|
@ -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\env
|
||||||
mkdir tmp\pkg\PEinjector\src
|
mkdir tmp\pkg\PEinjector\src
|
||||||
mkdir tmp\pkg\PEinjector\tool
|
mkdir tmp\pkg\PEinjector\tool
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
# | 6 |path,icon,name| make shortcut on Desktop |
|
# | 6 |path,icon,name| make shortcut on Desktop |
|
||||||
# +----+--------------+--------------------------+
|
# +----+--------------+--------------------------+
|
||||||
# | 7 | path | add <path> to %PATH% |
|
# | 7 | path | add <path> to %PATH% |
|
||||||
|
# +----+--------------+--------------------------+
|
||||||
|
# | 8 | regpath | add file to reg |
|
||||||
# '----+--------------+--------------------------'
|
# '----+--------------+--------------------------'
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,4 +169,10 @@ def do_action(actions_list):
|
||||||
except:
|
except:
|
||||||
actionlogs = actionlogs + \
|
actionlogs = actionlogs + \
|
||||||
f" add path \"{i[1]}\" failed: {repr(exp)}\r\n"
|
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
|
return actionlogs
|
||||||
|
|
|
@ -267,6 +267,12 @@ def load_package(pkg_name):
|
||||||
i = pkg_path + \
|
i = pkg_path + \
|
||||||
"/"+i
|
"/"+i
|
||||||
actions["onload"].append((7, 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():
|
def load():
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import winreg
|
import winreg
|
||||||
import log
|
import log
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def add_path(path):
|
def add_path(path):
|
||||||
|
@ -17,3 +18,8 @@ def add_path(path):
|
||||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
|
||||||
r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, winreg.KEY_WRITE) as key:
|
r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, winreg.KEY_WRITE) as key:
|
||||||
winreg.SetValueEx(key, "Path", 0, winreg.REG_EXPAND_SZ, new_path)
|
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
|
||||||
|
|
Loading…
Reference in New Issue