3 ms·
I don't mean to ruin it for gef3233 here, but seeing that it's missing the magic header required for PDFs, I'd be surprised if there are PDF viewers that would
by jolmg 8y ago
I don't mean to ruin it for gef3233 here, but seeing that it's missing the magic header required for PDFs, I'd be surprised if there are PDF viewers that would try to interpret this. I would even consider trying to interpret this "PDF" without checking for the magic number to be a bug.
Looking at the PDF spec[1], it says:
> The first line of a PDF file shall be a header consisting of the 5 characters %PDF– followed by a version number of the form 1.N, where N is a digit between 0 and 7.
where a line is:
> Each line shall be terminated by an end-of-line (EOL) marker, which may be a CARRIAGE RETURN (0Dh), a LINE FEED (0Ah), or both
On binary data:
> If a PDF file contains binary data, as most do (see 7.2, "Lexical Conventions"), the header line shall be immediately followed by a comment line containing at least four binary characters—that is, characters whose codes are 128 or greater
I'm sorry, but I don't think the file qualifies as a PDF if it doesn't meet these requirements. Still, it's pretty cool if this is PDF-like.
`gunzip`, `tar`, `jpg`, etc. fail when I give them things that don't have the magic header they expect. It's a good convention to use magic numbers to not misinterpret files.
[1] https://www.adobe.com/content/dam/acom/en/devnet/pdf/PDF32000_2008.pdf https://www.adobe.com/content/dam/acom/en/devnet/pdf/PDF3200...
- jolmg 8y agoSo what happens if you try to execute "%PDF-1.<number-between-0-and-7>\n%<4-bytes-above-128>\n" as x86 real-mode machine code anyway? Can't this be modified to simply undo whatever the PDF magic header would do if it was present?