News for hackers. Stuff that matters.
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by userbinator on Sunday August 30, 2020 @02:06AM (#24321684)
Not so much "obfuscated C" as it is "embedding a binary into a C program". You can still do something similar with modern compilers:

    char code[] = { /* put your bytes here */ };
    ((void(*)())code)();
I believe it is technically UB, but it does exactly what you'd think it does, and if compilers started doing funny things with it, you wouldn't be able to write things like JITs at all. A tiny demonstration of this can be found at the bottom of C4x86: https://github.com/EarlGray/c4/blob/master/c4x86.c
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by lifthrasiir on Sunday August 30, 2020 @07:02AM (#24322617)
> Not so much "obfuscated C" as it is "embedding a binary into a C program".

The meaning of "obfuscated C" as the contest requires was not well-defined at that time and had to be amended for a very long time. There are at least 5 more entries that abused and subsequently changed the rules at that time [1] [2] [3] [4] [5]. ([6] is an exception; this kind of abuse of the rules is allowed and now common.)

> [...] if compilers started doing funny things with it, you wouldn't be able to write things like JITs at all.

Well, see [7].

[1] https://www.ioccc.org/1987/biggar/hint.html

[2] https://www.ioccc.org/1988/spinellis.hint

[3] https://www.ioccc.org/1989/jar.1.hint

[4] https://www.ioccc.org/1993/lmfjyh.hint

[5] https://www.ioccc.org/1994/smr.hint

[6] https://www.ioccc.org/1995/spinellis.hint

[7] https://www.ioccc.org/2011/richards/hint.html

Re:Exploring mullender.c – A deep dive into the first IOCCC ... by StavrosK on Sunday August 30, 2020 @11:53AM (#24323632)
The IOCCC can use a UX improvement where they have, for each entry, pages with an introduction, the hints page, how the thing works, the actual code and what happens when you run it (including output).

As it stands, it's very interesting to read but most examples are hard to run and I always end up going away unfulfilled.

Re:Exploring mullender.c – A deep dive into the first IOCCC ... by LainIwakura on Sunday August 30, 2020 @12:02PM (#24323691)
This is why I do these write ups, I want to document the most obtuse pieces of code I can and explain the logic in a clear way =) I'll be writing more so be on the look out!
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by StavrosK on Sunday August 30, 2020 @12:04PM (#24323702)
Your writeup was extremely interesting and helpful, thank you!
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by szc on Sunday August 30, 2020 @11:17PM (#24328218)
I have been working to improve the usability for this years winning entries. For some entries it doesn't work well to "inline" the C code.
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by monocasa on Sunday August 30, 2020 @02:48AM (#24321815)
I think something like this gets disallowed these days as .rodata and .data gets mapped NX.
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by ache7 on Sunday August 30, 2020 @04:55AM (#24322243)
Using compiler hints, data can be placed directly in the code section.

Works on x86/x86_64 Linux:

char main[] __attribute__ ((section(".text"))) = "\xe8\x0d\0\0\0Hello world!\n"

#ifdef __x86_64__

"\x31\xc0\x8d\x50\x0d\xff\xc0\x89\xc7\x5e\x0f\x05\x31\xff\x8d\x47\x3c\x0f\x05";

#else

"\x31\xdb\x8d\x53\x0d\x59\x8d\x43\x04\x43\xcd\x80\x31\xdb\x8d\x43\x01\xcd\x80";

#endif

Re:Exploring mullender.c – A deep dive into the first IOCCC ... by hinoki on Sunday August 30, 2020 @04:59AM (#24322259)
I wonder if there have been any entries that use return oriented programming? I wasn’t able to find one...
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by andreareina on Sunday August 30, 2020 @03:04AM (#24321871)
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by 0xTJ on Sunday August 30, 2020 @09:15AM (#24322971)
Calling that "technically UB" is putting it lightly.
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by im3w1l on Sunday August 30, 2020 @11:10AM (#24323392)
What would be blessed way of doing it? Inline assembly jumping to it?
Re:Exploring mullender.c – A deep dive into the first IOCCC ... by segfaultbuserr on Sunday August 30, 2020 @07:50PM (#24327054)
In other words, this type of behavior can be summarized as: Instead of waiting for other people to exploit your program in C, why not to execute some shellcode and pwn yourself while you're at it... /joke