معرف التجربة: 003
Steganography Tool
CONCEPT
LSB (Least Significant Bit) image steganography in Go. Embeds a length-prefixed payload into the red channel of PNG pixels.
الهدف
Implement a covert channel by modifying the least significant bits of image pixel data, then verify extraction round-trips cleanly.
القيود
Payload size limited to (width × height) / 8 bytes. Not robust against JPEG re-encoding or image resizing.
Go Cryptography Image Processing
src/main.go
package mainimport ("encoding/binary""fmt""image""image/color""image/png""os")func embed(img *image.NRGBA, payload []byte) error {header := make([]byte, 4)binary.BigEndian.PutUint32(header, uint32(len(payload)))bits := append(header, payload...)idx := 0for y := img.Bounds().Min.Y; y < img.Bounds().Max.Y; y++ {for x := img.Bounds().Min.X; x < img.Bounds().Max.X; x++ {if idx >= len(bits)*8 {return nil}c := img.NRGBAAt(x, y)bytePos, bitPos := idx/8, uint(7-idx%8)bit := (bits[bytePos] >> bitPos) & 1c.R = (c.R & 0xFE) | bitimg.SetNRGBA(x, y, color.NRGBA{R: c.R, G: c.G, B: c.B, A: c.A})idx++}}return fmt.Errorf("image too small for payload")}func main() {f, _ := os.Open("cover.png")defer f.Close()src, _ := png.Decode(f)dst := image.NewNRGBA(src.Bounds())for y := dst.Bounds().Min.Y; y < dst.Bounds().Max.Y; y++ {for x := dst.Bounds().Min.X; x < dst.Bounds().Max.X; x++ {dst.Set(x, y, src.At(x, y))}}_ = embed(dst, []byte("CLASSIFIED_PAYLOAD"))out, _ := os.Create("stego.png")defer out.Close()png.Encode(out, dst)fmt.Println("Done — payload embedded into stego.png")}
وضع القراءة فقطUTF-8