Documentation ¶
Index ¶
- Constants
- Variables
- func SetTagCertTag(signedData *signedData, tag []byte) ([]byte, error)
- type Binary
- type IMAGE_DATA_DIRECTORY
- type IMAGE_DOS_HEADER
- type IMAGE_FILE_HEADER
- type IMAGE_OPTIONAL_HEADER32
- type IMAGE_OPTIONAL_HEADER64
- type ImageFileMachine
- type MSIBinary
- type MSIDirEntry
- type MSIHeader
- type PE32Binary
- type SectorFormat
Constants ¶
const ( IMAGE_DOS_SIGNATURE = 0x5A4D IMAGE_DOS_HEADER_SIZE = 64 IMAGE_FILE_HEADER_SIZE = 20 IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 14 )
Variables ¶
var (
ErrTruncated = errors.New("truncated file")
)
var (
IMAGE_NT_HEADER_SIGNATURE = []byte{'P', 'E', 0, 0}
)
Functions ¶
func SetTagCertTag ¶
SetTagCertTag modifies signedData, adding the tagging cert with the given tag. It returns the asn1 serialization of the modified signedData.
Types ¶
type Binary ¶
type Binary interface { GetTagCert() (cert *x509.Certificate, index int, err error) GetTag() (tag []byte, err error) SetTag(writer io.Writer, tag []byte) (err error) }
Binary represents a taggable binary of any format.
type IMAGE_DATA_DIRECTORY ¶
type IMAGE_DOS_HEADER ¶
type IMAGE_DOS_HEADER struct { Magic uint16 `struc:"uint16,little"` // Magic number Cblp uint16 `struc:"uint16,little"` // Byte on last page of file Cp uint16 `struc:"uint16,little"` // Pages in file Crlc uint16 `struc:"uint16,little"` // Relocations Cparhdr uint16 `struc:"uint16,little"` // Size of header in paragraphs Minalloc uint16 `struc:"uint16,little"` // Minimum extra paragraphs needed Maxalloc uint16 `struc:"uint16,little"` // Maximum extra paragraphs needed Ss uint16 `struc:"uint16,little"` // Initial (relative) SS value Sp uint16 `struc:"uint16,little"` // Initial SP value Csum uint16 `struc:"uint16,little"` // Checksum Ip uint16 `struc:"uint16,little"` // Initial IP value Cs uint16 `struc:"uint16,little"` // Initial (relative) CS value Lfarlc uint16 `struc:"uint16,little"` // File address of relocation table Ovno uint16 `struc:"uint16,little"` // Overlay number Res [4]uint16 `struc:"[4]uint16"` // Reserved words Oemid uint16 `struc:"uint16,little"` // OEM identifier (for e_oeminfo) Oeminfo uint16 `struc:"uint16,little"` // OEM information; e_oemid specific Res2 [10]uint16 `struc:"[10]uint16"` // Reserved words Lfanew int32 `struc:"int32,little"` // File address of new exe header }
type IMAGE_FILE_HEADER ¶
type IMAGE_FILE_HEADER struct { Machine ImageFileMachine `struc:"uint16,little"` NumberOfSections uint16 `struc:"uint16,little"` TimeDateStamp uint32 `struc:"uint32,little"` PointerForSymbolTable uint32 `struc:"uint32,little"` NumberOfSymbols uint32 `struc:"uint32,little"` SizeOfOptionalHeader uint16 `struc:"uint16,little"` Characteristics uint16 `struc:"uint16,little"` }
IMAGE_FILE_HEADER represents the IMAGE_FILE_HEADER structure from http://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx.
type IMAGE_OPTIONAL_HEADER32 ¶
type IMAGE_OPTIONAL_HEADER32 struct { Magic uint16 `struc:"uint16,little"` // Magic number MajorLinkerVersion byte `struc:"byte"` // Major linker version MinorLinkerVersion byte `struc:"byte"` // Minor linker version SizeOfCode uint32 `struc:"uint32,little"` // Size of code SizeOfInitializedData uint32 `struc:"uint32,little"` // Size of initialized data SizeOfUninitializedData uint32 `struc:"uint32,little"` // Size of uninitialized data AddressOfEntryPoint uint32 `struc:"uint32,little"` // Address of entry point BaseOfCode uint32 `struc:"uint32,little"` // Base address of code BaseOfData uint32 `struc:"uint32,little"` // Base address of data ImageBase uint32 `struc:"uint32,little"` // Image base address SectionAlignment uint32 `struc:"uint32,little"` // Section alignment FileAlignment uint32 `struc:"uint32,little"` // File alignment MajorOperatingSystemVersion uint16 `struc:"uint16,little"` // Major operating system version MinorOperatingSystemVersion uint16 `struc:"uint16,little"` // Minor operating system version MajorImageVersion uint16 `struc:"uint16,little"` // Major image version MinorImageVersion uint16 `struc:"uint16,little"` // Minor image version MajorSubsystemVersion uint16 `struc:"uint16,little"` // Major subsystem version MinorSubsystemVersion uint16 `struc:"uint16,little"` // Minor subsystem version Win32VersionValue uint32 `struc:"uint32,little"` // Win32 version value SizeOfImage uint32 `struc:"uint32,little"` // Size of image SizeOfHeaders uint32 `struc:"uint32,little"` // Size of headers CheckSum uint32 `struc:"uint32,little"` // Checksum Subsystem uint16 `struc:"uint16,little"` // Subsystem DllCharacteristics uint16 `struc:"uint16,little"` // DLL characteristics SizeOfStackReserve uint32 `struc:"uint32,little"` // Size of stack to reserve SizeOfStackCommit uint32 `struc:"uint32,little"` // Size of stack to commit SizeOfHeapReserve uint32 `struc:"uint32,little"` // Size of heap to reserve SizeOfHeapCommit uint32 `struc:"uint32,little"` // Size of heap to commit LoaderFlags uint32 `struc:"uint32,little"` // Loader flags NumberOfRvaAndSizes uint32 `struc:"uint32,little"` // Number of data-directory entries }
IMAGE_OPTIONAL_HEADER32 represents the IMAGE_OPTIONAL_HEADER structure from http://msdn.microsoft.com/en-us/library/windows/desktop/ms680339(v=vs.85).aspx.
type IMAGE_OPTIONAL_HEADER64 ¶
type IMAGE_OPTIONAL_HEADER64 struct { Magic uint16 `struc:"uint16,little"` // Magic number MajorLinkerVersion byte `struc:"byte"` // Major linker version MinorLinkerVersion byte `struc:"byte"` // Minor linker version SizeOfCode uint32 `struc:"uint32,little"` // Size of code SizeOfInitializedData uint32 `struc:"uint32,little"` // Size of initialized data SizeOfUninitializedData uint32 `struc:"uint32,little"` // Size of uninitialized data AddressOfEntryPoint uint32 `struc:"uint32,little"` // Address of entry point BaseOfCode uint32 `struc:"uint32,little"` // Base address of code ImageBase uint64 `struc:"uint64,little"` // Image base address SectionAlignment uint32 `struc:"uint32,little"` // Section alignment FileAlignment uint32 `struc:"uint32,little"` // File alignment MajorOperatingSystemVersion uint16 `struc:"uint16,little"` // Major operating system version MinorOperatingSystemVersion uint16 `struc:"uint16,little"` // Minor operating system version MajorImageVersion uint16 `struc:"uint16,little"` // Major image version MinorImageVersion uint16 `struc:"uint16,little"` // Minor image version MajorSubsystemVersion uint16 `struc:"uint16,little"` // Major subsystem version MinorSubsystemVersion uint16 `struc:"uint16,little"` // Minor subsystem version Win32VersionValue uint32 `struc:"uint32,little"` // Win32 version value SizeOfImage uint32 `struc:"uint32,little"` // Size of image SizeOfHeaders uint32 `struc:"uint32,little"` // Size of headers CheckSum uint32 `struc:"uint32,little"` // Checksum Subsystem uint16 `struc:"uint16,little"` // Subsystem DllCharacteristics uint16 `struc:"uint16,little"` // DLL characteristics SizeOfStackReserve uint64 `struc:"uint64,little"` // Size of stack to reserve SizeOfStackCommit uint64 `struc:"uint64,little"` // Size of stack to commit SizeOfHeapReserve uint64 `struc:"uint64,little"` // Size of heap to reserve SizeOfHeapCommit uint64 `struc:"uint64,little"` // Size of heap to commit LoaderFlags uint32 `struc:"uint32,little"` // Loader flags NumberOfRvaAndSizes uint32 `struc:"uint32,little"` // Number of data-directory entries }
type ImageFileMachine ¶
type ImageFileMachine = uint16
const ( IMAGE_FILE_MACHINE_I386 ImageFileMachine = 0x014c IMAGE_FILE_MACHINE_IA64 ImageFileMachine = 0x0200 IMAGE_FILE_MACHINE_AMD64 ImageFileMachine = 0x8664 )
type MSIBinary ¶
type MSIBinary struct {
// contains filtered or unexported fields
}
MSIBinary represents an MSI binary. |headerBytes| and |contents| are non-overlapping slices of the same backing array.
func NewMSIBinary ¶
NewMSIBinary returns a Binary that contains details of the MSI binary given in |contents|. |contents| is modified; the region occupied by the cert section is zeroed out.
func (*MSIBinary) GetTagCert ¶
func (bin *MSIBinary) GetTagCert() (cert *x509.Certificate, index int, err error)
type MSIDirEntry ¶
type MSIDirEntry struct { Name [64]byte NumNameBytes uint16 ObjectType uint8 ColorFlag uint8 Left uint32 Right uint32 Child uint32 Clsid [16]byte StateFlags uint32 CreateTime uint64 ModifyTime uint64 StreamFirstSector uint32 StreamSize uint64 }
MSIDirEntry represents a parsed MSI directory entry for a stream.
type MSIHeader ¶
type MSIHeader struct { Magic [8]byte Clsid [16]byte MinorVersion uint16 DllVersion uint16 ByteOrder uint16 SectorShift uint16 MiniSectorShift uint16 Reserved [6]byte NumDirSectors uint32 NumFatSectors uint32 FirstDirSector uint32 TransactionSignatureNumber uint32 MiniStreamCutoffSize uint32 FirstMiniFatSector uint32 NumMiniFatSectors uint32 FirstDifatSector uint32 NumDifatSectors uint32 }
MSIHeader represents a parsed MSI header.
type PE32Binary ¶
type PE32Binary struct {
// contains filtered or unexported fields
}
PE32Binary represents a PE binary.
func NewPE32Binary ¶
func NewPE32Binary(reader io.ReadSeeker) (*PE32Binary, error)
NewPE32Binary returns a Binary that contains details of the PE32 binary given in contents.
func (*PE32Binary) GetTag ¶
func (bin *PE32Binary) GetTag() (tag []byte, err error)
func (*PE32Binary) GetTagCert ¶
func (bin *PE32Binary) GetTagCert() (cert *x509.Certificate, index int, err error)
func (*PE32Binary) SetTag ¶
func (bin *PE32Binary) SetTag(writer io.Writer, tag []byte) (err error)
SetTag returns a PE binary based on bin, but where the superfluous certificate contains the given tag data. The (parsed) bin.signedData is modified; but bin.asn1Bytes, which contains the raw original bytes, is not.
type SectorFormat ¶
type SectorFormat struct { Size offT // the size of a sector in bytes; 512 for dll v3 and 4096 for v4. Ints int // the number of int32s in a sector. }
SectorFormat represents parameters of an MSI file sector.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
exetag-tool
Program exetag-tool manipulates "tags" in Authenticode-signed Windows binaries.
|
Program exetag-tool manipulates "tags" in Authenticode-signed Windows binaries. |