Documentation
¶
Overview ¶
[File Begins] internal\obfuscator\obfuscator.go Package obfuscator orchestrates the overall process and holds shared context.
Index ¶
- func ExtractAndObfuscateStrings(src string, technique string) string
- func PrintWithoutComments(root ast.Vertex) string
- func ProcessFile(filePath string, octx *ObfuscationContext) (string, error)
- type CommentRemovingPrinterVisitor
- type ObfuscationContext
- func (octx *ObfuscationContext) ContextFilePath(baseDir string, sType scrambler.ScrambleType) string
- func (octx *ObfuscationContext) GetConfig() *config.Config
- func (octx *ObfuscationContext) GetScrambler(sType scrambler.ScrambleType) astutil.ScramblerInterface
- func (octx *ObfuscationContext) Load(baseDir string) error
- func (octx *ObfuscationContext) Save(baseDir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAndObfuscateStrings ¶
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 ¶
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
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 ¶
func (octx *ObfuscationContext) GetScrambler(sType scrambler.ScrambleType) astutil.ScramblerInterface
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.