injector

package
v0.0.0-...-ee075e7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0, Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SigRIFF = "RIFF"
	SigWAVE = "WAVE"
	SigGIF  = "GIF"
)

File Signatures

View Source
const (
	ChunkICMT = "ICMT"
	ChunkINFO = "INFO"
	ChunkLIST = "LIST"

	ChunkIEND = "IEND"
	ChunkTEXT = "tEXt"

	JpegMarkerCOM = 0xFFFE

	GifExtIntroducer = 0x21
	GifLabelComment  = 0xFE
	GifTrailer       = 0x3B
)

Chunk Types & Markers

Variables

View Source
var (
	SigPNG  = []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}
	SigJPEG = []byte{0xFF, 0xD8} // SOI
)

Functions

func GenerateGhostTextPNG

func GenerateGhostTextPNG(text string, width, height int) ([]byte, error)

GenerateGhostTextPNG creates a PNG where the text is written in pure color (e.g., Red or White) but the Alpha channel is set to 0. This implements Vector B: The Premultiplication Exploit.

func InjectAlphaStego

func InjectAlphaStego(img *image.NRGBA, secretText string)

InjectAlphaStego modifies the Least Significant Bits (LSB) of the Alpha channel to encode a secret string. This implements Vector C: Alpha-Steganography. Note: This function modifies the image in-place.

func InjectByExtension

func InjectByExtension(filename string, data []byte, payload string, strategies map[string]string) ([]byte, error)

InjectByExtension dispatches the injection based on file extension and configuration.

func InjectDOCX

func InjectDOCX(data []byte, payload string) ([]byte, error)

InjectDOCX injects a hidden paragraph using godocx library.

func InjectGIF

func InjectGIF(data []byte, payload string) ([]byte, error)

InjectGIF injects a Comment Extension block before the Trailer.

func InjectGIFJS

func InjectGIFJS(gifData []byte, jsPayload string) ([]byte, error)

InjectGIFJS appends a JavaScript payload to the end of a GIF file. This creates a "GIFAR" style polyglot where the file is a valid image, but can be executed as a script in some contexts (e.g. <script src="...") or detected by scanners looking for JS.

func InjectICS

func InjectICS(content []byte, payload string) ([]byte, error)

InjectICS injects a payload into the DESCRIPTION field of an ICS calendar file.

func InjectJPEG

func InjectJPEG(data []byte, payload string) ([]byte, error)

InjectJPEG injects a COM (Comment) segment after SOI.

func InjectJS

func InjectJS(data []byte, payload string) ([]byte, error)

InjectJS injects a variable declaration at the top or bottom.

func InjectJSON

func InjectJSON(data []byte, payload string) ([]byte, error)

InjectJSON injects a key "_llm_instruction" with the payload.

func InjectMP3

func InjectMP3(data []byte, payload string) ([]byte, error)

InjectMP3 injects a payload into the ID3v2 USLT (Lyrics) frame. It enforces the Round-Trip Rule by parsing, modifying, and verifying.

func InjectPDF

func InjectPDF(data []byte, payload string) ([]byte, error)

InjectPDF injects an invisible watermark into a PDF. Satisfies Round-Trip Rule: pdfcpu handles parsing and XREF rebuilding.

func InjectPDFHTML

func InjectPDFHTML(pdfData []byte, htmlPayload string) ([]byte, error)

InjectPDFHTML appends an HTML payload to the end of a PDF file. The file remains a valid PDF (readers stop at %%EOF), but contains HTML that might be parsed by naive scrapers or LLMs reading the file as text.

func InjectPNG

func InjectPNG(data []byte, payload string) ([]byte, error)

InjectPNG injects a tEXt chunk with the payload. Satisfies Round-Trip Rule: We construct a valid chunk with CRC.

func InjectPNGAlphaStego

func InjectPNGAlphaStego(data []byte, payload string) ([]byte, error)

InjectPNGAlphaStego is the adapter function for the dispatcher. It decodes a PNG, injects the payload into the alpha channel LSB, and re-encodes.

func InjectRobots

func InjectRobots(data []byte, payload string) ([]byte, error)

InjectRobots injects a Disallow rule or comment.

func InjectSRT

func InjectSRT(content []byte, payload string) ([]byte, error)

InjectSRT injects a 1ms subtitle block at the beginning.

func InjectSVGFont

func InjectSVGFont(content []byte, payload string) ([]byte, error)

InjectSVGFont injects a payload into the <desc> or <metadata> tag of an SVG font.

func InjectTTF

func InjectTTF(data []byte, payload string) ([]byte, error)

InjectTTF injects a payload into the Name Table (ID 10 or 13).

func InjectWAV

func InjectWAV(data []byte, payload string) ([]byte, error)

InjectWAV injects a payload into a new 'ICMT' (Comment) chunk within a 'LIST' 'INFO' chunk. This requires low-level RIFF parsing to ensure we update the main chunk size.

func InjectWOFF2

func InjectWOFF2(data []byte, payload string) ([]byte, error)

InjectWOFF2 injects a payload into the WOFF2 Extended Metadata Block.

func InjectXLSX

func InjectXLSX(data []byte, payload string) ([]byte, error)

InjectXLSX injects a VeryHidden sheet containing the payload.

func InjectXML

func InjectXML(data []byte, payload string) ([]byte, error)

InjectXML injects a comment into the XML.

func RevealAlphaStego

func RevealAlphaStego(img *image.NRGBA) string

RevealAlphaStego extracts the secret string from the Alpha channel LSBs. It reads until it finds a null terminator (0x00) or runs out of pixels.

func ValidateSVG

func ValidateSVG(content []byte) error

ValidateSVG ensures the SVG is valid XML.

Types

type InjectorFunc

type InjectorFunc func(data []byte, payload string) ([]byte, error)

InjectorFunc defines the signature for injection functions.

func GetInjector

func GetInjector(filename string, strategies map[string]string) InjectorFunc

GetInjector returns the appropriate injection function for the given filename/extension. It checks the strategies map for specific overrides (e.g. "polyglot").

type ResolverFunc

type ResolverFunc func(filename, strategy string) InjectorFunc

ResolverFunc defines the logic to select an InjectorFunc based on context.

Jump to

Keyboard shortcuts

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