(exe, output)
| 162 | |
| 163 | |
| 164 | def 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 | |
| 191 | def signfile(exe, sigfile, output): |
no test coverage detected