models

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2017 License: MIT Imports: 24 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SAVE_MAGIC = "UCSV"

Functions

func Assemble

func Assemble(asm string, addr uint64, arch *Arch) ([]byte, error)

func Demangle

func Demangle(name string) string

func Disas

func Disas(mem []byte, addr uint64, arch *Arch, pad ...int) (string, error)

func HexDump

func HexDump(base uint64, mem []byte, bits int) []string

func Repr

func Repr(p []byte, strsize int) string

func Save

func Save(u Usercorn) ([]byte, error)

TODO: pack using all structs above instead of just header

Types

type Arch

type Arch struct {
	Bits    int
	Radare  string
	CS_ARCH int
	CS_MODE uint
	KS_ARCH ks.Architecture
	KS_MODE ks.Mode
	UC_ARCH int
	UC_MODE int
	PC      int
	SP      int
	OS      map[string]*OS
	Regs    regMap
	GdbXml  string

	DefaultRegs []string
	// contains filtered or unexported fields
}

func (*Arch) RegDump

func (a *Arch) RegDump(u uc.Unicorn) ([]RegVal, error)

func (*Arch) RegNames

func (a *Arch) RegNames() map[int]string

func (*Arch) RegisterOS

func (a *Arch) RegisterOS(os *OS)

func (*Arch) SmokeTest

func (a *Arch) SmokeTest(t *testing.T)

type Change

type Change struct {
	Old, New uint64
	Enum     int
	Name     string
}

func NewChange

func NewChange(name string, val, oldVal uint64) *Change

func (*Change) Changed

func (c *Change) Changed() bool

func (*Change) Mask

func (c *Change) Mask(bsz int) []ChangeMask

func (*Change) String

func (c *Change) String(bsz int, color bool) string

type ChangeMask

type ChangeMask struct {
	Old, New string
	Changed  bool
}

type Changes

type Changes struct {
	Bsz     int
	Changes []*Change
}

func (*Changes) Changed

func (cs *Changes) Changed() []*Change

func (*Changes) Count

func (cs *Changes) Count() int

func (*Changes) Find

func (cs *Changes) Find(enum int) *Change

func (*Changes) String

func (cs *Changes) String(indent string, color bool) string

type Config

type Config struct {
	Output io.WriteCloser

	Color           bool
	Demangle        bool
	ForceBase       uint64
	ForceInterpBase uint64
	LoadPrefix      string
	LoopCollapse    int
	NativeFallback  bool
	SavePost        string
	SavePre         string
	SkipInterp      bool
	Strsize         int
	TraceBlock      bool
	TraceExec       bool
	TraceMatch      []string
	TraceMatchDepth int
	TraceMem        bool
	TraceMemBatch   bool
	TraceReg        bool
	TraceSys        bool
	Verbose         bool

	PrefixArgs []string
}

func (*Config) Init

func (c *Config) Init() *Config

func (*Config) PrefixPath

func (c *Config) PrefixPath(path string, force bool) string

type ExitStatus

type ExitStatus int

func (ExitStatus) Error

func (e ExitStatus) Error() string

type Gate

type Gate struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Gate) Start

func (g *Gate) Start()

func (*Gate) Stop

func (g *Gate) Stop()

func (*Gate) StopLock

func (g *Gate) StopLock()

func (*Gate) UnlockStart

func (g *Gate) UnlockStart()

func (*Gate) UnlockStop

func (g *Gate) UnlockStop()

func (*Gate) UnlockStopRelock

func (g *Gate) UnlockStopRelock()

type Loader

type Loader interface {
	Arch() string
	Bits() int
	ByteOrder() binary.ByteOrder
	OS() string
	Entry() uint64
	Type() int
	Interp() string
	Header() (uint64, []byte, int)
	Symbols() ([]Symbol, error)
	Segments() ([]SegmentData, error)
	DataSegment() (uint64, uint64)
	DWARF() (*dwarf.Data, error)
}

type Loop

type Loop struct {
	Loop          []uint64
	Index, Filled int
}

func NewLoop

func NewLoop(length int) *Loop

func (*Loop) Inc

func (l *Loop) Inc()

func (*Loop) Next

func (l *Loop) Next() uint64

func (*Loop) Push

func (l *Loop) Push(n uint64)

func (*Loop) Ring

func (l *Loop) Ring(start int, dst []uint64) []uint64

type LoopDetect

type LoopDetect struct {
	History, Loop *Loop
	Loops, Len    int
}

func NewLoopDetect

func NewLoopDetect(length int) *LoopDetect

func (*LoopDetect) Detect

func (l *LoopDetect) Detect() *Loop

func (*LoopDetect) Reset

func (l *LoopDetect) Reset()

func (*LoopDetect) String

func (l *LoopDetect) String(u Usercorn, loop []uint64) string

func (*LoopDetect) Update

func (l *LoopDetect) Update(addr uint64) (bool, []uint64, int)

type MappedFile

type MappedFile struct {
	Name       string
	Off        int64
	Addr, Size uint64
	Symbols    []Symbol
	DWARF      *dwarf.Data
}

func (*MappedFile) Contains

func (m *MappedFile) Contains(addr uint64) bool

func (*MappedFile) FileLine

func (m *MappedFile) FileLine(addr uint64) string

func (*MappedFile) SymbolLookup

func (m *MappedFile) SymbolLookup(name string) *Symbol

TODO: Use a map for O(n) -> O(1) TODO: Do I want this to just return addr? Part of problem is adjusting for memory offset, and it's gross if the caller needs to do that manually.

func (*MappedFile) Symbolicate

func (m *MappedFile) Symbolicate(addr uint64) (result Symbol, distance uint64)

type MemLog

type MemLog struct {
	// contains filtered or unexported fields
}

func NewMemLog

func NewMemLog(order binary.ByteOrder) *MemLog

func (*MemLog) Adjacent

func (m *MemLog) Adjacent(addr uint64, p []byte, write bool) (delta *memDelta, dup bool)

func (*MemLog) Empty

func (m *MemLog) Empty() bool

func (*MemLog) Flush

func (m *MemLog) Flush(indent string, bits int) string

func (*MemLog) Freeze

func (m *MemLog) Freeze()

func (*MemLog) Reset

func (m *MemLog) Reset()

func (*MemLog) String

func (m *MemLog) String(indent string, bits int) string

func (*MemLog) Update

func (m *MemLog) Update(addr uint64, size int, value int64, write bool)

func (*MemLog) UpdateBytes

func (m *MemLog) UpdateBytes(addr uint64, p []byte, write bool)

type Mmap

type Mmap struct {
	Addr, Size uint64
	Prot       int
	File       *MappedFile
	Desc       string
}

func (*Mmap) Contains

func (m *Mmap) Contains(addr uint64) bool

func (*Mmap) String

func (m *Mmap) String() string

type MmapAddrSort

type MmapAddrSort []*Mmap

func (MmapAddrSort) Len

func (m MmapAddrSort) Len() int

func (MmapAddrSort) Less

func (m MmapAddrSort) Less(i, j int) bool

func (MmapAddrSort) Swap

func (m MmapAddrSort) Swap(i, j int)

type OS

type OS struct {
	Name      string
	Kernels   func(Usercorn) []interface{}
	Init      func(Usercorn, []string, []string) error
	Interrupt func(Usercorn, uint32)
}

func (*OS) String

func (o *OS) String() string

type Reg

type Reg struct {
	Enum    int
	Name    string
	Default bool
}

type RegVal

type RegVal struct {
	Reg
	Val uint64
}

type SaveBody

type SaveBody struct {
	RegCount uint64 `struc:"sizeof=Regs"`
	Regs     []SaveReg
	MemCount uint64 `struc:"sizeof=Mem"`
	Mem      []SaveMem
}

type SaveHeader

type SaveHeader struct {
	Magic            string `struc:"[4]byte"`
	Version          uint32
	UcMajor, UcMinor uint32
	UcArch, UcMode   uint32

	PC uint64

	BodySize   uint64 `struc:"sizeof=Compressed"`
	Compressed []byte
}

func (*SaveHeader) PackBody

func (s *SaveHeader) PackBody(b *SaveBody) error

func (*SaveHeader) UnpackBody

func (s *SaveHeader) UnpackBody() (*SaveBody, error)

type SaveMem

type SaveMem struct {
	Addr uint64
	Size uint64 `struc:"sizeof="Data"`
	Prot uint32
	Data []byte
}

type SaveReg

type SaveReg struct {
	Enum, Val uint64
}

type Segment

type Segment struct {
	Start, End uint64
	Prot       int
}

func (*Segment) Merge

func (s *Segment) Merge(o *Segment)

func (*Segment) Overlaps

func (s *Segment) Overlaps(o *Segment) bool

type SegmentData

type SegmentData struct {
	Off        uint64
	Addr, Size uint64
	Prot       int
	DataFunc   func() ([]byte, error)
}

func (*SegmentData) ContainsPhys

func (s *SegmentData) ContainsPhys(addr uint64) bool

func (*SegmentData) ContainsVirt

func (s *SegmentData) ContainsVirt(addr uint64) bool

func (*SegmentData) Data

func (s *SegmentData) Data() ([]byte, error)

type Stackframe

type Stackframe struct {
	PC, SP uint64
}

func (*Stackframe) Pretty

func (s *Stackframe) Pretty(u Usercorn) string

type Stacktrace

type Stacktrace struct {
	Stack []Stackframe
}

func (*Stacktrace) Empty

func (s *Stacktrace) Empty() bool

func (*Stacktrace) Freeze

func (s *Stacktrace) Freeze(pc, sp uint64) []Stackframe

func (*Stacktrace) Len

func (s *Stacktrace) Len() int

func (*Stacktrace) Peek

func (s *Stacktrace) Peek() Stackframe

func (*Stacktrace) Pop

func (s *Stacktrace) Pop() Stackframe

func (*Stacktrace) Push

func (s *Stacktrace) Push(pc, sp uint64)

func (*Stacktrace) Update

func (s *Stacktrace) Update(pc, sp uint64)

type StatusDiff

type StatusDiff struct {
	U Usercorn
	// contains filtered or unexported fields
}

func (*StatusDiff) Changes

func (s *StatusDiff) Changes(onlyChanged bool) *Changes

type StrucStream

type StrucStream struct {
	Stream  io.ReadWriter
	Options *struc.Options
}

func (*StrucStream) Pack

func (s *StrucStream) Pack(vals ...interface{}) error

func (*StrucStream) Unpack

func (s *StrucStream) Unpack(vals ...interface{}) error

type Symbol

type Symbol struct {
	Name       string
	Start, End uint64
	Dynamic    bool
}

func (Symbol) Contains

func (s Symbol) Contains(addr uint64) bool

type Uname

type Uname struct {
	Sysname  string
	Nodename string
	Release  string
	Version  string
	Machine  string
}

func (*Uname) Pad

func (u *Uname) Pad(length int)

type Usercorn

type Usercorn interface {
	uc.Unicorn
	Arch() *Arch
	OS() string
	Bits() uint
	ByteOrder() binary.ByteOrder
	Assemble(asm string, addr uint64) ([]byte, error)
	Disas(addr, size uint64) (string, error)
	Config() *Config
	Run(args, env []string) error
	Trampoline(func() error) error

	Gate() *Gate

	Printf(fmt string, args ...interface{})
	Println(s interface{})

	RegisterAddr(f *os.File, addr, size uint64, off int64)
	Symbolicate(addr uint64, includeFile bool) (string, error)

	Brk(addr uint64) (uint64, error)
	Mappings() []*Mmap
	MemReserve(addr, size uint64, force bool) (*Mmap, error)
	Mmap(addr, size uint64) (*Mmap, error)
	MmapWrite(addr uint64, p []byte) (uint64, error)
	Mem() memio.MemIO
	StrucAt(addr uint64) *StrucStream

	PackAddr(buf []byte, n uint64) ([]byte, error)
	UnpackAddr(buf []byte) uint64
	PopBytes(p []byte) error
	PushBytes(p []byte) (uint64, error)
	Pop() (uint64, error)
	Push(n uint64) (uint64, error)
	ReadRegs(reg []int) ([]uint64, error)
	RegDump() ([]RegVal, error)

	RunShellcodeMapped(mmap *Mmap, code []byte, setRegs map[int]uint64, regsClobbered []int) error
	RunShellcode(addr uint64, code []byte, setRegs map[int]uint64, regsClobbered []int) error

	Exe() string
	Loader() Loader
	InterpBase() uint64
	Base() uint64
	Entry() uint64
	BinEntry() uint64
	SetEntry(entry uint64)
	SetExit(exit uint64)

	// TODO: PrefixPath will be replaced by a full VFS subsystem
	PrefixPath(s string, force bool) string
	Syscall(num int, name string, getArgs func(n int) ([]uint64, error)) (uint64, error)

	Exit(err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL