Live data from Hacker News

Best of show – abuse of libc

ioccc.org

41–50 of 84 posts

Re: Best of show – abuse of libc

#41
post #39

Up next: a C compiler that compiles to printf statements :-P

There is somewhere a compiler that outputs to all sorts of crazy languages including awk, sed, printf, etc.. but I can't find it right now. Hopefully someone knows what I'm talking about. I feel like it did LLVM IR to a bunch of languages or something like that.. but my memory is faulty.

You are looking for ELVM: https://github.com/shinh/elvm/ (I have seen many others, but in terms of activity it seems the most maintained one.)

Re: Best of show – abuse of libc

#42

Earlier quoted context omitted.

Theres a great example of what you can do with this, submitted and discussed on HN here: https://news.ycombinator.com/item?id=25690319

> Format specifiers can take extra “arguments”. - "%hhn": store the number of bytes written mod 256 to the char pointer ... Oh boy. I'll put that down for my "thing I don't think I wanted to know" of the day.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

Re: Best of show – abuse of libc

#43
post #42

Earlier quoted context omitted.

> Format specifiers can take extra “arguments”. - "%hhn": store the number of bytes written mod 256 to the char pointer ... Oh boy. I'll put that down for my "thing I don't think I wanted to know" of the day.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

So I can port doom to gnu printf?

Re: Best of show – abuse of libc

#45
post #20
post #2

General thread here: https://news.ycombinator.com/item?id=25651942

Personally I find it amusing that the 0-signal comment "Thanks for all dang" is upvoted while the opposite 0-signal comment "Thanks for nothing dang" is downvoted. I mean, I think dang is chill, but neither of these really contributes to the discussion any more than the other, so shouldn't they have the same score? Upvotes really are a popularity contest these days.

The negative comment is from a hellbanned account (which is, frankly, unsurprising). It's not even possible to downvote it, as far as I can tell, due to being DOA.

Re: Best of show – abuse of libc

#46

Earlier quoted context omitted.

GNU's printf specifier language is Turing complete, I believe.

Presumably it needs a loop around it, so it's not Turing-complete by itself?

Not portable, but if you can get the address of the stack you can force printf to overwrite the return address, obviating the loop.

Re: Best of show – abuse of libc

#48
post #42

Earlier quoted context omitted.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

So I can port doom to gnu printf?

GNU's printf is Turing complete[0]... so "yes."

[0] Mentioned (but not directly linked) by TFA:

https://www.usenix.org/conference/usenixsecurity15/technical...

Re: Best of show – abuse of libc

#50
post #42

Earlier quoted context omitted.

> Format specifiers can take extra “arguments”. - "%hhn": store the number of bytes written mod 256 to the char pointer ... Oh boy. I'll put that down for my "thing I don't think I wanted to know" of the day.

There is some innocent beauty in the twistedness of printf - especially with GNU extensions.

GNU's printf specifier language is Turing complete, I believe.
Post reply on HN