(exe, sigfile, output)
| 189 | |
| 190 | |
| 191 | def signfile(exe, sigfile, output): |
| 192 | flItms = gather_file_info_win(exe) |
| 193 | |
| 194 | cert = open(sigfile, 'rb').read() |
| 195 | |
| 196 | if not output: |
| 197 | output = output = str(exe) + "_signed" |
| 198 | |
| 199 | shutil.copy2(exe, output) |
| 200 | |
| 201 | print("Output file: {0}".format(output)) |
| 202 | |
| 203 | with open(exe, 'rb') as g: |
| 204 | with open(output, 'wb') as f: |
| 205 | f.write(g.read()) |
| 206 | f.seek(0) |
| 207 | f.seek(flItms['CertTableLOC'], 0) |
| 208 | f.write(struct.pack("<I", len(open(exe, 'rb').read()))) |
| 209 | f.write(struct.pack("<I", len(cert))) |
| 210 | f.seek(0, io.SEEK_END) |
| 211 | f.write(cert) |
| 212 | print("Signature appended. \nFIN.") |
| 213 | |
| 214 | |
| 215 | if __name__ == "__main__": |
no test coverage detected