File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,17 @@ def sign
3232 raise "input and output files must be different!"
3333 end
3434
35+ # Below we access an instance of the IMAGE_DATA_DIRECTORY struct.
36+ # This instance is called IMAGE_DIRECTORY_ENTRY_SECURITY and it contains information about the digital signature
37+ # see: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680305(v=vs.85).aspx
38+
39+ # write the offset (address) of the digital signature to the security header (VirtualAddress field)
3540 @image [ pe_header . security_offset , 4 ] = raw_bytes ( @image . size + @padding )
3641
42+ # write the size of the digital signature to the security header (Size field)
3743 @image [ pe_header . security_offset + 4 , 4 ] = raw_bytes ( FAKE_SIG . size )
44+
45+ # append the "digital signature" to the end of the executable, complete with padding
3846 @image << padding_string << FAKE_SIG
3947
4048 File . binwrite ( @output , @image )
You can’t perform that action at this time.
0 commit comments