binemu

package module
v0.0.0-...-fed3a35 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

binemu

This is a fork of lunixbochs/usercorn. This repository is more an experimental branch that wants to focus on completely emulate the binary with a virutal kernel that does not interact with the host kernel.

Goals of this project

  • run ctf binaries
  • run binaries in a completely isolated environment
  • have full control over the environment the program is being executed

Non-goals of this project

  • implement all syscalls

Build

make deps
make protos
make

Run

To run the binary in a simple "unbunuish" filesystem:

./binemu --config_path=bins/ubuntu64/ubuntu.textproto PATH_TO_BIN [ARGS...]

Documentation

Index

Constants

View Source
const (
	BASE         = 0x100000
	UC_MEM_ALIGN = 0x1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecConfig

type ExecConfig struct {
	Env  []string
	Args []string
}

ExecConfig describes the arguments and environment that should be passed to the executable.

type Task

type Task struct {
	*cpu.Cpu

	Bsz int
	// contains filtered or unexported fields
}

func NewTask

func NewTask(c *cpu.Cpu, arch *models.Arch, os *models.OS, order binary.ByteOrder) *Task

func (*Task) Arch

func (t *Task) Arch() *models.Arch

func (*Task) Bits

func (t *Task) Bits() uint

func (*Task) ByteOrder

func (t *Task) ByteOrder() binary.ByteOrder

func (*Task) HookMapAdd

func (t *Task) HookMapAdd(mapCb models.MapCb, unmap models.UnmapCb, prot models.ProtCb) *models.MapHook

func (*Task) HookMapDel

func (t *Task) HookMapDel(hook *models.MapHook)

func (*Task) Malloc

func (t *Task) Malloc(size uint64, desc string) (uint64, error)

func (*Task) Mappings

func (t *Task) Mappings() cpu.Pages

func (*Task) MemMap

func (t *Task) MemMap(addr, size uint64, prot int) error

func (*Task) MemProt

func (t *Task) MemProt(addr, size uint64, prot int) error

func (*Task) MemReadInto

func (t *Task) MemReadInto(p []byte, addr uint64) error

func (*Task) MemReserve

func (t *Task) MemReserve(addr, size uint64, fixed bool) (*cpu.Page, error)

func (*Task) MemUnmap

func (t *Task) MemUnmap(addr, size uint64) error

func (*Task) Mmap

func (t *Task) Mmap(addr, size uint64, prot int, fixed bool, desc string, file *cpu.FileDesc) (uint64, error)

func (*Task) OS

func (t *Task) OS() string

func (*Task) PackAddr

func (t *Task) PackAddr(buf []byte, n uint64) ([]byte, error)

func (*Task) Pop

func (t *Task) Pop() (uint64, error)

func (*Task) PopBytes

func (t *Task) PopBytes(p []byte) error

func (*Task) Push

func (t *Task) Push(n uint64) (uint64, error)

func (*Task) PushBytes

func (t *Task) PushBytes(p []byte) (uint64, error)

func (*Task) RegDump

func (t *Task) RegDump() ([]models.RegVal, error)

func (*Task) RegRead

func (t *Task) RegRead(enum int) (uint64, error)

func (*Task) RegReadBatch

func (t *Task) RegReadBatch(regs []int) ([]uint64, error)

func (*Task) RegWrite

func (t *Task) RegWrite(enum int, val uint64) error

func (*Task) UnpackAddr

func (t *Task) UnpackAddr(buf []byte) uint64

type Usercorn

type Usercorn struct {
	*Task

	StackBase uint64
	StackSize uint64
	// contains filtered or unexported fields
}

func NewUsercornWrapper

func NewUsercornWrapper(exe string, t *Task, fs *ramfs.Filesystem, l loader.Loader, os *models.OS, c *ExecConfig) *Usercorn

NewUsercornWrapper is just a hacky woraround that usercorn has privat fields. TODO(felberj) remove

func (*Usercorn) Base

func (u *Usercorn) Base() uint64

func (*Usercorn) BinEntry

func (u *Usercorn) BinEntry() uint64

func (*Usercorn) Brk

func (u *Usercorn) Brk(addr uint64) (uint64, error)

func (*Usercorn) Close

func (u *Usercorn) Close() error

func (*Usercorn) Entry

func (u *Usercorn) Entry() uint64

func (*Usercorn) Exe

func (u *Usercorn) Exe() string

func (*Usercorn) Exit

func (u *Usercorn) Exit(err error)

func (*Usercorn) Fs

func (u *Usercorn) Fs() *ramfs.Filesystem

Fs returns the filesystem

func (*Usercorn) GetCPU

func (u *Usercorn) GetCPU() *cpu.Cpu

GetCPU returns the CPU

func (*Usercorn) LoadBinary

func (u *Usercorn) LoadBinary(f *os.File) error

LoadBinary is just a hacky workaround to load the binary into memory.

func (*Usercorn) Loader

func (u *Usercorn) Loader() loader.Loader

func (*Usercorn) MapStack

func (u *Usercorn) MapStack(base, size uint64, guard bool) error

func (*Usercorn) Restart

func (u *Usercorn) Restart(fn func(models.Usercorn, error) error)

func (*Usercorn) Run

func (u *Usercorn) Run() error

func (*Usercorn) SetEntry

func (u *Usercorn) SetEntry(entry uint64)

func (*Usercorn) SetExit

func (u *Usercorn) SetExit(exit uint64)

func (*Usercorn) Start

func (u *Usercorn) Start(pc, end uint64) error

func (*Usercorn) StrucAt

func (u *Usercorn) StrucAt(addr uint64) *models.StrucStream

func (*Usercorn) Syscall

func (u *Usercorn) Syscall(num int, name string, getArgs models.SysGetArgs) (uint64, error)

func (*Usercorn) Trampoline

func (u *Usercorn) Trampoline(fun func() error) error

Directories

Path Synopsis
arm
x86
cmd
binemu command
cpu
kernel
linux
Package linux provides a kernel that wants to separate the running process from the host system.
Package linux provides a kernel that wants to separate the running process from the host system.

Jump to

Keyboard shortcuts

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