Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
steganography — 零依赖的 Go 库,用于图像中的 LSB 隐写:将任意文件编码到 PNG 载体中并解码隐藏消息,并带有消息大小预检查。 | Kitploit
工具/GitHubGitHub/auyer/steganography
通用工具加密/解密工具数据泄露隐写术隐私保护实用工具与框架
GitHubauyer/steganography

steganography

零依赖的 Go 库,用于图像中的 LSB 隐写:将任意文件编码到 PNG 载体中并解码隐藏消息,并带有消息大小预检查。

查看仓库
3534755个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

隐写术库

GoDoc Go Report Card LICENSE MIT Actions CI codecov Mentioned in Awesome Go

隐写术是一个用纯 Go 编写的库,可在图像上实现简单的 LSB 隐写术。它既能对图像进行编码,也能进行解码。它可以存储任意格式的文件。 本库受 Stego by EthanWelsh 启发,后者是一个具有相同用途的命令行工具。

安装

go get -u github.com/auyer/steganography

演示

原始图像编码后的图像
原始文件编码后的文件

第二张图像包含 Wikipedia 上关于剑龙描述的第一段内容,该内容也作为示例提供在 examples/message.txt 中。


入门

package main
import (
    "bufio"
    "image/png"
    "io/ioutil"

    "github.com/auyer/steganography"
)

编码

写入模式用于接收一条消息,并使用 LSB 隐写术将其嵌入图像文件中,从而生成一个包含你消息的秘密图像文件。

请注意,一个字节所需的最小图像尺寸为 24 像素。每增加一个字节,就需要额外 3 个像素。

inFile, _ := os.Open("input_file.png") // opening file
reader := bufio.NewReader(inFile)   // buffer reader 
img, _ := png.Decode(reader)   // decoding to golang's image.Image

w := new(bytes.Buffer)   // buffer that will recieve the results
err := steganography.Encode(w, img, []byte("message")) // Encode the message into the image
if err != nil {
    log.Printf("Error Encoding file %v", err)
    return
}
outFile, _ := os.Create("out_file.png") // create file
w.WriteTo(outFile) // write buffer to it
outFile.Close()

注意:为简洁起见,所有错误检查均已移除,但实际使用时应包含它们。

消息大小

长度模式可用于对载体图像进行预先检查,以推断其可存储的文件大小。

sizeOfMessage := steganography.GetMessageSizeFromImage(img) // retrieves the size of the encoded message

解码

读取模式用于读取已使用 LSB 隐写术编码的图像,并从该图像中提取隐藏的消息。

inFile, _ := os.Open(encodedInputFile) // opening file
defer inFile.Close()

reader := bufio.NewReader(inFile) // buffer reader 
img, _ := png.Decode(reader) // decoding to golang's image.Image

sizeOfMessage := steganography.GetMessageSizeFromImage(img) // retrieving message size to decode in the next line

msg := steganography.Decode(sizeOfMessage, img) // decoding the message from the file
fmt.Println(string(msg))

注意:为简洁起见,所有错误检查均已移除,但实际使用时应包含它们。

完整示例

完整示例请参见 examples/stego.go 文件。它是一个基于本仓库原始分支的命令行应用,但经过修改以使用隐写术库。


致谢

  • 剑龙图片由 Matt Martyniuk 创作 - 原创作品,CC BY-SA 3.0,https://commons.wikimedia.org/w/index.php?curid=42215661
下载工具