MCPcopy Create free account
hub / github.com/echQoQ/RustSL / truncate

Function truncate

sign/sigthief.py:164–188  ·  view source on GitHub ↗
(exe, output)

Source from the content-addressed store, hash-verified

162
163
164def truncate(exe, output):
165 flItms = gather_file_info_win(exe)
166
167 if flItms['CertLOC'] == 0 or flItms['CertSize'] == 0:
168 # not signed
169 print("Inputfile Not signed!")
170 sys.exit(-1)
171 else:
172 print( "Inputfile is signed!")
173
174 if not output:
175 output = str(exe) + "_nosig"
176
177 print("Output file: {0}".format(output))
178
179 shutil.copy2(exe, output)
180
181 with open(output, "r+b") as binary:
182 print('Overwriting certificate table pointer and truncating binary')
183 binary.seek(-flItms['CertSize'], io.SEEK_END)
184 binary.truncate()
185 binary.seek(flItms['CertTableLOC'], 0)
186 binary.write(b"\x00\x00\x00\x00\x00\x00\x00\x00")
187
188 print("Signature removed. \nFIN.")
189
190
191def signfile(exe, sigfile, output):

Callers 1

sigthief.pyFile · 0.85

Calls 1

gather_file_info_winFunction · 0.85

Tested by

no test coverage detected