Skip to content

Commit 34dde32

Browse files
committed
and another one
1 parent b8bd062 commit 34dde32

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ jobs:
4141
- name: Build EXE with PyInstaller
4242
run: pyinstaller packaging/windows.spec --noconfirm
4343

44+
- name: Strip Rich PE header to avoid false AV detections
45+
run: |
46+
python -c "
47+
import struct, pathlib
48+
exe = pathlib.Path('dist/TgWsProxy.exe')
49+
data = bytearray(exe.read_bytes())
50+
rich = data.find(b'Rich')
51+
if rich == -1:
52+
raise SystemExit('Rich header not found')
53+
ck = struct.unpack_from('<I', data, rich + 4)[0]
54+
dans = struct.pack('<I', 0x536E6144 ^ ck)
55+
ds = data.find(dans)
56+
if ds == -1:
57+
raise SystemExit('DanS marker not found')
58+
data[ds:rich + 8] = b'\x00' * (rich + 8 - ds)
59+
exe.write_bytes(data)
60+
print(f'Stripped Rich header: offset {ds}..{rich+8}')
61+
"
62+
4463
- name: Rename artifact
4564
run: mv dist/TgWsProxy.exe dist/TgWsProxy_windows.exe
4665

@@ -74,6 +93,25 @@ jobs:
7493
- name: Build EXE with PyInstaller
7594
run: pyinstaller packaging/windows.spec --noconfirm
7695

96+
- name: Strip Rich PE header to avoid false AV detections
97+
run: |
98+
python -c "
99+
import struct, pathlib
100+
exe = pathlib.Path('dist/TgWsProxy.exe')
101+
data = bytearray(exe.read_bytes())
102+
rich = data.find(b'Rich')
103+
if rich == -1:
104+
raise SystemExit('Rich header not found')
105+
ck = struct.unpack_from('<I', data, rich + 4)[0]
106+
dans = struct.pack('<I', 0x536E6144 ^ ck)
107+
ds = data.find(dans)
108+
if ds == -1:
109+
raise SystemExit('DanS marker not found')
110+
data[ds:rich + 8] = b'\x00' * (rich + 8 - ds)
111+
exe.write_bytes(data)
112+
print(f'Stripped Rich header: offset {ds}..{rich+8}')
113+
"
114+
77115
- name: Rename artifact
78116
run: mv dist/TgWsProxy.exe dist/TgWsProxy_windows_7_${{ matrix.suffix }}.exe
79117

0 commit comments

Comments
 (0)