News for hackers. Stuff that matters.
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by DHowett on Friday September 27, 2013 @04:24AM (#6455909)

    They serve no purpose, except proving that file formats not starting at offset
    0 are a bad idea.
Au contraire–they are a wonderful idea. If, say, a polyglot pdf+executable could gain code execution enough to execute itself as a binary, it could just as easily execute far more dangerous code while being far less likely to tip off an automated scanner. So it goes for many of the other stackable formats.

The benefits seem to far outweigh the drawbacks. As an example, look at the concept behind ext[234]fs migration in btrfs (which is not fixed to block 0 in a volume)–Take an ext4 filesystem, generate new inodes pointing at the original b-trees, and away you go! You get a filesystem that is valid ext4 (retaining the old data), and valid btrfs (which, being copy-on-write, doesn't destroy the old data.)

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by Someone on Friday September 27, 2013 @12:13PM (#6457706)
Also, these aren't all "file formats not starting at offset 0". For example, PDF files must start with %PDF. The problem is that several tools are happy with a PDF prefixed by noise. That probably is because PDF, originally, was a text format (just as PostScript still is). Compression of content was added later, but the structure still is pure ASCII (for example, the table of contents at the end of a file has file offsets in ASCII, and you can find the start of the table of contents as an ASCII string, too).
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by est on Friday September 27, 2013 @04:53AM (#6456004)
> file formats not starting at offset 0 are a bad idea.

Meanwhile, we realy need to develop network protocols with obfuscated handshake to counter monitor and censorship.

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @04:09AM (#6455879)
I also did the same with PE or ELF instead of Mach-O.

I recommend also checking my latest slides @ https://corkami.googlecode.com/files/44CON2013-Messing%20wit... where the 'inception' slides contain the PDF slides and the actual PDF viewer Sumatra, and an alternate PDF to be viewed under Chrome ;)

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by _b8r0 on Friday September 27, 2013 @03:38AM (#6455787)
BTW, if you're interested, Ange also built a really awesome pair of posters on the Windows PE binary format for you to print out:

https://code.google.com/p/corkami/wiki/PE101

https://code.google.com/p/corkami/wiki/PE102

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by _b8r0 on Friday September 27, 2013 @03:36AM (#6455779)
Ange was at 44CON[1] this month and did a great talk about Windows PE binary formats. He also ran a workshop on the PE binary format. Awesome guy to talk to, just make sure you don't have any fez's lying around ;)

[1] - http://www.44con.com/

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by Ygg2 on Friday September 27, 2013 @05:34AM (#6456120)
I'm intriguied by his fez obsession. Does he toss/eat/steal/stomp them?
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @05:56AM (#6456181)
Fezzes are cool.
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by laumars on Friday September 27, 2013 @09:13AM (#6456799)
Was that an intended Doctor Who reference or am I just showing my nerdiness now?

reference: http://www.youtube.com/watch?v=bvWYw0CnuSI

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by sanderjd on Friday September 27, 2013 @11:21AM (#6457433)
Ha, don't worry, I read it that way too.
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by Ygg2 on Friday September 27, 2013 @07:13AM (#6456377)
Agreed, but what do you do with them (I assume that you are Ange from GP)? I assume steal or "borrow for undetermined time".
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @07:43AM (#6456436)
GP?

I have only one fez.

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by Ygg2 on Friday September 27, 2013 @09:32AM (#6456884)
Grandparent post from your previous comment.

I though you were the Fez variant of Cookie monster minus the eating of Fezzes?

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by _b8r0 on Saturday September 28, 2013 @06:19PM (#6463345)
This is one more than you had before 44CON, no?
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by est on Friday September 27, 2013 @03:40AM (#6455792)
ELF and PE hybrid

http://stackoverflow.com/a/2083161/41948

Now someone could just add Mach-O to it...

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @04:07AM (#6455875)
it's not a PE, it's a (headerless) COM.

PE, ELF, and Mach-O all enforce a different signature at offset 0. Thus it's impossible to combine them - otherwise, I'd have done it already ;)

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by est on Friday September 27, 2013 @04:16AM (#6455893)
Getting around the offset 0 is always the hardest part in all hybrid format hacks.

I tried .vbs+.bat hybrid and .bat+.com hybrid.

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by yiedyie on Friday September 27, 2013 @04:14AM (#6455888)
COM doesn't have the MZ magic number.
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by mzs on Friday September 27, 2013 @11:57AM (#6457632)
How one of the comments suggests to have the COM write-out an EXE, you could do something similar on OS X. Applescripts can be entirely in a resource fork, have that write-out a macho-o and have the data fork be your previous polyglot.
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by TheZenPsycho on Friday September 27, 2013 @03:51AM (#6455831)
Is it possible to do the (somewhat) simpler (in concept, not process) task of making gif or png that is also a valid HTML file? It might be kind of tricky given they both have magic numbers at the head...but perhaps there is some way to trick a browser into ignoring the "garbagey" bits?
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ygra on Friday September 27, 2013 @04:32AM (#6455931)
You mean like this?

http://demoseen.com/windowpane/magister.png.html

(I'm not the creator, I just happen to share an IRC channel with them.) There is a description of how it works at http://daeken.com/superpacking-js-demos

Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by TheZenPsycho on Saturday September 28, 2013 @10:04PM (#6463814)
Thanks! yes that's what I mean
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @04:16AM (#6455894)
It's definitely possible with JavaScript in GIF and BMP, as I did in my PoCs @ https://corkami.googlecode.com/files/jspics.zip
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by TheZenPsycho on Saturday September 28, 2013 @10:05PM (#6463815)
Thanks! yes, these are very useful example.
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by yiedyie on Friday September 27, 2013 @06:40AM (#6456291)
I remember that the NE executable files had hardly any virus I always wondered why? Is it the format or the fact that they where not used that much (due to the short presence of Win3)?
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @06:52AM (#6456323)
I might be wrong, but IMO: short lifespan (16 bits), complex format while standard DOS executables could still run...
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by chrisdew on Friday September 27, 2013 @05:23AM (#6456083)
What's the font used in the top-right image (begins "db 'MZ'")?
Re:A simultaneous OS X binary, PDF file, jar file, and HTML ... by ange4771_ on Friday September 27, 2013 @05:29AM (#6456104)