import
pefile,os,time
def
patch_ProtectionPlusDLL(ProtectionPlusDLL_path):
if
os.path.exists(ProtectionPlusDLL_path)
and
os.path.isdir(ProtectionPlusDLL_path):
ProtectionPlusDLL_path
=
os.path.join(ProtectionPlusDLL_path,
'ProtectionPlusDLL.dll'
)
if
not
(os.path.exists(ProtectionPlusDLL_path)
and
os.path.isfile(ProtectionPlusDLL_path)):
print
(f
'{ProtectionPlusDLL_path} is not exists or is invalid file'
)
ProtectionPlusDLL_path
=
os.path.abspath(ProtectionPlusDLL_path)
pe
=
pefile.PE(ProtectionPlusDLL_path)
bak
=
ProtectionPlusDLL_path
+
time.strftime(
".%Y%m%d_%H%M%S.BAK"
)
if
not
os.path.exists(bak):
pe.write(bak)
print
(f
'backup to {bak}'
)
for
sym
in
pe.DIRECTORY_ENTRY_EXPORT.symbols:
if
sym.name
=
=
b
'IsActivatedSoftwareKey'
:
pe.set_bytes_at_rva(sym.address,b
'\xB0\x01\xC3'
)
elif
sym.name
in
[b
'CheckStatusAsyncSoftwareKey'
,b
'GetExpirationDateSoftwareKey'
,b
'GetUsageStatus'
,
b
'PromptAndActivateSoftwareKey'
,b
'PromptAndDeactivateSoftwareKey'
,b
'SetCheckStatusCallbackSoftwareKey'
]:
pe.set_bytes_at_rva(sym.address,b
'\xB0\x00\xC3'
)
pe.close()
pe.write(ProtectionPlusDLL_path)