So, to simplify my life I want to be able to append from 1 to 7 additional characters on the end of some jpg images my program is processing*. These are dummy padding (fillers, etc - probably all 0x00) just to make the file size a multiple of 8 bytes for block encryption.
所以,为了简化我的生活,我希望能够在我的程序处理*的一些jpg图像的末尾附加1到7个附加字符。这些是虚拟填充(填充等,可能全部为0x00),只是为了使文件大小为8字节的倍数进行块加密。
Having tried this out with a few programs, it appears they are fine with the additional characters, which occur after the FF D9 that specifies the end of the image - so it appears that the file format is well defined enough that the 'corruption' I'm adding at the end shouldn't matter.
用几个程序尝试了这个,看起来它们很好用附加字符,这是在指定图像结束的FF D9之后发生的 - 所以看起来文件格式定义得足够好'腐败'我最后添加应该无关紧要。
I can always post process the files later if needed, but my preference is to do the simplest thing possible - which is to let them remain (I'm decrypting other file types and they won't mind, so having a special case is annoying).
我可以随时根据需要对文件进行后期处理,但我最喜欢做的是尽可能最简单的事情 - 这就是让它们保留(我正在解密其他文件类型而他们不会介意,因此有一个特殊情况令人讨厌)。
I figure with all the talk of Steganography hullaballo years ago, someone has some input here...
我在几年前与Steganography hullaballo谈论所有的话,有人在这里有一些意见......
(encryption processing by 8 byte blocks, I don't want to save pre-encrypted file size, so append 0x00 to input data, and leave them there after decoding)
(通过8字节块进行加密处理,我不想保存预先加密的文件大小,所以将0x00附加到输入数据,并在解码后保留它们)
4 个解决方案
#1
20
No, you can add bits to the end of a jpg file, without making it unusable. The heading of the jpg file tells how to read it, so the program reading it will stop at the end of the jpg data.
不,您可以在jpg文件的末尾添加位,而不会使其无法使用。 jpg文件的标题告诉如何读取它,因此读取它的程序将在jpg数据的末尾停止。
In fact, people have hidden zip files inside jpg files by appending the zip data to the end of the jpg data. Because of the way these formats are structured, the resulting file is valid in either format.
事实上,人们通过将zip数据附加到jpg数据的末尾,在jpg文件中隐藏了zip文件。由于这些格式的结构方式,生成的文件在任一格式中都有效。
#2
7
You can .. but the results may be unpredictable.
你可以......但结果可能无法预测。
Even though there is enough information in the format to tell the client to ignore the extra data it is likely not a case the programmer tested for.
即使格式中有足够的信息告诉客户忽略额外的数据,但程序员可能不会这样做。
A paranoid program might look at the size, notice the discrepancy and decide it won't process your file because clearly it doesn't fully understand it. This is particularly likely when reading data from the web when random bytes in a file could be considered a security risk.
一个偏执的程序可能会查看大小,注意差异并决定它不会处理您的文件,因为很明显它并不完全理解它。当从文件中读取数据时,文件中的随机字节可能被视为安全风险时,这种情况尤其可能。
#3
3
You can embed your data in the XMP tag within a JPEG (or EXIF or IPTC fields for that matter). XMP is XML so you have a fair bit of flexibility there to do you own custom stuff.
您可以将数据嵌入JPEG(或EXIF或IPTC字段)中的XMP标记中。 XMP是XML,所以你有一些灵活性可以让你拥有自定义的东西。
It's probably not the simplest thing possible but putting your data here will maintain the integrity of the JPEG and require no "post processing".
这可能不是最简单的事情,但是将数据放在这里将保持JPEG的完整性,并且不需要“后期处理”。
You data will then show up in other imaging software such as PhotoShop, which may not be ideal.
然后,您的数据将显示在其他成像软件中,例如PhotoShop,这可能并不理想。
#4
1
As others have stated, you have no control how programs process image files and therefore some programs may find the images valid others may not.
正如其他人所说,你无法控制程序如何处理图像文件,因此某些程序可能会发现其他程序可能没有的图像。
However, there is a bigger issue here. Judging by your question, I'm deducing you're practicing "security through obscurity." It's widely considered a very bad practice. Use Google to find a plethora of articles about the topic.
但是,这里有一个更大的问题。从你的问题来看,我推断你正在通过默默无闻来实践“安全”。它被广泛认为是一种非常糟糕的做法。使用Google查找有关该主题的大量文章。
#1
20
No, you can add bits to the end of a jpg file, without making it unusable. The heading of the jpg file tells how to read it, so the program reading it will stop at the end of the jpg data.
不,您可以在jpg文件的末尾添加位,而不会使其无法使用。 jpg文件的标题告诉如何读取它,因此读取它的程序将在jpg数据的末尾停止。
In fact, people have hidden zip files inside jpg files by appending the zip data to the end of the jpg data. Because of the way these formats are structured, the resulting file is valid in either format.
事实上,人们通过将zip数据附加到jpg数据的末尾,在jpg文件中隐藏了zip文件。由于这些格式的结构方式,生成的文件在任一格式中都有效。
#2
7
You can .. but the results may be unpredictable.
你可以......但结果可能无法预测。
Even though there is enough information in the format to tell the client to ignore the extra data it is likely not a case the programmer tested for.
即使格式中有足够的信息告诉客户忽略额外的数据,但程序员可能不会这样做。
A paranoid program might look at the size, notice the discrepancy and decide it won't process your file because clearly it doesn't fully understand it. This is particularly likely when reading data from the web when random bytes in a file could be considered a security risk.
一个偏执的程序可能会查看大小,注意差异并决定它不会处理您的文件,因为很明显它并不完全理解它。当从文件中读取数据时,文件中的随机字节可能被视为安全风险时,这种情况尤其可能。
#3
3
You can embed your data in the XMP tag within a JPEG (or EXIF or IPTC fields for that matter). XMP is XML so you have a fair bit of flexibility there to do you own custom stuff.
您可以将数据嵌入JPEG(或EXIF或IPTC字段)中的XMP标记中。 XMP是XML,所以你有一些灵活性可以让你拥有自定义的东西。
It's probably not the simplest thing possible but putting your data here will maintain the integrity of the JPEG and require no "post processing".
这可能不是最简单的事情,但是将数据放在这里将保持JPEG的完整性,并且不需要“后期处理”。
You data will then show up in other imaging software such as PhotoShop, which may not be ideal.
然后,您的数据将显示在其他成像软件中,例如PhotoShop,这可能并不理想。
#4
1
As others have stated, you have no control how programs process image files and therefore some programs may find the images valid others may not.
正如其他人所说,你无法控制程序如何处理图像文件,因此某些程序可能会发现其他程序可能没有的图像。
However, there is a bigger issue here. Judging by your question, I'm deducing you're practicing "security through obscurity." It's widely considered a very bad practice. Use Google to find a plethora of articles about the topic.
但是,这里有一个更大的问题。从你的问题来看,我推断你正在通过默默无闻来实践“安全”。它被广泛认为是一种非常糟糕的做法。使用Google查找有关该主题的大量文章。