Documentation ¶
Index ¶
Constants ¶
const ( // GOOS labels LINUX = "linux" DARWIN = "darwin" WIN = "windows" // GOARCH Architecture labels I386 = "386" AMD64 = "amd64" ARM = "arm" ARM64 = "arm64" PPC = "ppc" PPC64LE = "ppc64le" S390 = "s390x" RISCV = "riscv" )
const ( MachO32Magic uint32 = 0xfeedface // 32 bit, big endian MachO64Magic uint32 = 0xfeedfacf // 64 bit, big endian MachO32LIMagic uint32 = 0xcefaedfe // 32 bit, little endian MachO64LIMagic uint32 = 0xcffaedfe // 64 bit, little endian MachOFat uint32 = 0xcafebabe // Universal Binary )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binary ¶
type Binary struct {
// contains filtered or unexported fields
}
Binary is the base type of the package. It abstracts a binary executable
func NewWithOptions ¶
NewWithOptions creates a new binary with the specified options
func (*Binary) ContainsStrings ¶ added in v0.10.0
ContainsStrings searches the printable strings un a binary file
func (*Binary) SetImplementation ¶
func (b *Binary) SetImplementation(impl binaryImplementation)
SetImplementation sets the implementation to handle this sort of executable
type ELFBinary ¶
ELFBinary abstracts a binary in ELF format
func NewELFBinary ¶
NewELFBinary opens a file and returns an ELF binary if it is one
type ELFHeader ¶
type ELFHeader struct { WordFlag uint8 // Flag: 32 or 64 bit binary OSABI uint8 // Binary Interface ABIVersion uint8 // ABI Version EType uint16 // Executable Type: Executable, relocatable, etc EMachine uint16 // Machine architecture // contains filtered or unexported fields }
ELFHeader abstracts the data we need from the elf header
func GetELFHeader ¶
GetELFHeader returns the header if the binary is and EF binary
func (*ELFHeader) MachineType ¶
MachineType returns a string with the architecture moniker
func (*ELFHeader) WordLength ¶
WordLength returns either 32 or 64 for 32bit or 64 bit architectures
type LinkMode ¶ added in v0.15.0
type LinkMode string
LinkMode is the enum for all available linking modes.
type MachOBinary ¶
type MachOBinary struct { Header *MachOHeader Options *Options }
MachOBinary is an abstraction for a Mach-O executable
func NewMachOBinary ¶
func NewMachOBinary(filePath string, opts *Options) (*MachOBinary, error)
NewMachOBinary returns a Mach-O binary if the specified file is one
func (*MachOBinary) Arch ¶
func (macho *MachOBinary) Arch() string
Arch returns a string with the GOARCH label of the file
func (*MachOBinary) LinkMode ¶ added in v0.15.0
func (macho *MachOBinary) LinkMode() (LinkMode, error)
LinkMode returns the linking mode of the binary.
func (*MachOBinary) OS ¶
func (macho *MachOBinary) OS() string
OS returns a string with the GOOS label of the binary file
type MachOHeader ¶
MachOHeader is a structure to capture the data we need from the binary header
func GetMachOHeader ¶
func GetMachOHeader(path string) (*MachOHeader, error)
GetMachOHeader returns a struct with the executable header information
func (*MachOHeader) MachineType ¶
func (machoh *MachOHeader) MachineType() string
MachineType returns the architecture as a GOARCH label
func (*MachOHeader) String ¶
func (machoh *MachOHeader) String() string
String returns the header information as a string
func (*MachOHeader) WordLength ¶
func (machoh *MachOHeader) WordLength() int
WordLength returns an integer indicating if this is a 32 or 64bit binary
type PEBinary ¶
PEBinary is a struct that abstracts a Windows Portable Executable
func NewPEBinary ¶
NewPEBinary Returns a binary implementation for a Windows executable
type PEFileHeader ¶
type PEFileHeader struct { Machine uint16 NumberOfSections uint16 TimeDateStamp uint32 PointerToSymbolTable uint32 NumberOfSymbols uint32 SizeOfOptionalHeader uint16 Characteristics uint16 }
PEFileHeader captures the header information of the executable
type PEHeader ¶
PEHeader captures the header information of the executable
func GetPEHeader ¶
GetPEHeader returns a portable executable header from the specified file
func (*PEHeader) MachineType ¶
MachineType returns the moniker of the binary architecture
func (*PEHeader) WordLength ¶
WordLength Returns an integer indicating if it's a 64 or 32 bit binary
type PEOptionalHeader ¶
type PEOptionalHeader struct {
Magic uint16
}
PEOptionalHeader we only care about the magic number to determine the binary wordsize