ctrlflow

package
v0.0.0-...-f84c444 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Obfuscate

func Obfuscate(fset *token.FileSet, ssaPkg *ssa.Package, files []*ast.File, obfRand *mathrand.Rand, mode Mode, sharedTempDir string) (newFileName string, newFile *ast.File, affectedFiles []*ast.File, err error)

Obfuscate obfuscates control flow of all functions with directive using control flattening. All obfuscated functions are removed from the original file and moved to the new one. Obfuscation can be customized by passing parameters from the directive, example:

//garble:controlflow flatten_passes=1 junk_jumps=0 block_splits=0 func someMethod() {}

flatten_passes - controls number of passes of control flow flattening. Have exponential complexity and more than 3 passes are not recommended in most cases. junk_jumps - controls how many junk jumps are added. It does not affect final binary by itself, but together with flattening linearly increases complexity. block_splits - controls number of times largest block must be splitted. Together with flattening improves obfuscation of long blocks without branches.

Types

type Mode

type Mode int

Mode controls how control-flow obfuscation is applied across a package.

const (
	ModeOff Mode = iota
	// ModeAnnotated obfuscates only functions decorated with //garble:controlflow.
	ModeAnnotated
	// ModeAuto obfuscates all eligible functions unless explicitly skipped.
	ModeAuto
	// ModeAll obfuscates every function, including trivial ones.
	ModeAll
)

func ParseMode

func ParseMode(value string) (Mode, error)

ParseMode converts a string value into a Mode.

func (Mode) Enabled

func (m Mode) Enabled() bool

Enabled reports whether the mode enables any control-flow obfuscation.

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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