obfuscator

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

[File Begins] internal\obfuscator\obfuscator.go Package obfuscator orchestrates the overall process and holds shared context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAndObfuscateStrings

func ExtractAndObfuscateStrings(src string, technique string) string

ExtractAndObfuscateStrings is a public wrapper for extractAndObfuscateStrings. It uses regex to find and obfuscate strings in the source code. This is a simpler approach than AST parsing and is useful for testing.

func PrintWithoutComments

func PrintWithoutComments(root ast.Vertex) string

PrintWithoutComments takes an AST node and outputs it without any comments

func ProcessFile

func ProcessFile(filePath string, octx *ObfuscationContext) (string, error)

ProcessFile reads, parses, obfuscates, and returns the content of a single PHP file. It uses the provided ObfuscationContext for configuration and shared state. Informational messages are suppressed; only errors are returned.

Types

type CommentRemovingPrinterVisitor

type CommentRemovingPrinterVisitor struct {
	visitor.Null
	// contains filtered or unexported fields
}

CommentRemovingPrinterVisitor is a custom visitor that implements a basic printer that doesn't print comments, only the essential code.

func NewCommentRemovingPrinterVisitor

func NewCommentRemovingPrinterVisitor(w io.Writer) *CommentRemovingPrinterVisitor

NewCommentRemovingPrinterVisitor creates a new printer that won't print comments

func (*CommentRemovingPrinterVisitor) EnterNode

func (v *CommentRemovingPrinterVisitor) EnterNode(n ast.Vertex) bool

EnterNode handles the node when entering it

func (*CommentRemovingPrinterVisitor) LeaveNode

LeaveNode handles the node when leaving it

type ObfuscationContext

type ObfuscationContext struct {
	Config     *config.Config
	Scramblers map[scrambler.ScrambleType]*scrambler.Scrambler
	Silent     bool // Inherited from config for convenience
}

ObfuscationContext holds the shared state needed across multiple files/passes, primarily the name scramblers.

func NewObfuscationContext

func NewObfuscationContext(cfg *config.Config) (*ObfuscationContext, error)

NewObfuscationContext creates a new context and initializes scramblers based on config.

func (*ObfuscationContext) ContextFilePath

func (octx *ObfuscationContext) ContextFilePath(baseDir string, sType scrambler.ScrambleType) string

ContextFilePath returns the expected path for a scrambler's context file.

func (*ObfuscationContext) GetConfig

func (octx *ObfuscationContext) GetConfig() *config.Config

GetConfig returns the configuration from the context.

func (*ObfuscationContext) GetScrambler

GetScrambler returns the scrambler for the given type, satisfying the astutil.Context interface.

func (*ObfuscationContext) Load

func (octx *ObfuscationContext) Load(baseDir string) error

Load loads the state for all scramblers from the specified base directory. It returns an error if any individual scrambler fails to load (and context is invalid).

func (*ObfuscationContext) Save

func (octx *ObfuscationContext) Save(baseDir string) error

Save saves the state for all scramblers to the specified base directory.

Jump to

Keyboard shortcuts

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