mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
add exe integrity selfcheck
This commit is contained in:
parent
6deaf5c268
commit
cedaf4809f
|
@ -96,4 +96,9 @@ $APPDATA/python/python$pyv/scripts/pyinstaller \
|
|||
|
||||
# ./upx.exe --best --ultra-brute --lzma -k dist/copyparty.exe
|
||||
|
||||
printf $(sha512sum ~/Downloads/dist/copyparty.exe | head -c 18 | sed -r 's/(..)/\\x\1/g') |
|
||||
base64 | head -c12 >> dist/copyparty.exe
|
||||
|
||||
dist/copyparty.exe --version
|
||||
|
||||
curl -fkT dist/copyparty.exe -b cppwd=wark https://192.168.123.1:3923/copyparty$m.exe
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# coding: utf-8
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
@ -46,6 +48,30 @@ def confirm(rv):
|
|||
sys.exit(rv or 1)
|
||||
|
||||
|
||||
def ckck():
|
||||
hs = hashlib.sha512()
|
||||
with open(sys.executable, "rb") as f:
|
||||
f.seek(-12, 2)
|
||||
rem = f.tell()
|
||||
esum = f.read().decode("ascii", "replace")
|
||||
f.seek(0)
|
||||
while rem:
|
||||
buf = f.read(min(rem, 64 * 1024))
|
||||
rem -= len(buf)
|
||||
hs.update(buf)
|
||||
if not buf:
|
||||
t = "unexpected eof @ {} with {} left"
|
||||
raise Exception(t.format(f.tell(), rem))
|
||||
|
||||
fsum = base64.b64encode(hs.digest()[:9]).decode("utf-8")
|
||||
if fsum != esum:
|
||||
t = "exe integrity check error; [{}] != [{}]"
|
||||
raise Exception(t.format(esum, fsum))
|
||||
|
||||
|
||||
ckck()
|
||||
|
||||
|
||||
def meicln(mod):
|
||||
pdir, mine = os.path.split(mod)
|
||||
dirs = os.listdir(pdir)
|
||||
|
|
Loading…
Reference in a new issue