Earlier quoted context omitted.
Presumably it needs a loop around it, so it's not Turing-complete by itself?
No need to use a loop around it, printf can take care of that pesky detail for you! To quote [0] (my emphasis): > To achieve full Turing-complete computation, we need a way to loop a format string. This is possible by overwriting the pointer inside printf() that tracks which character in the format string is currently being executed. The attacker is unlucky in that at the time the “%n” format specifier is used, this…
Best of show – abuse of libc
71–80 of 84 posts
Re: Best of show – abuse of libc
#72> 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.
Are there any scanners out there that will detect user input ending up as the format string of a printf? Perhaps a scanner than I can run against all of github, and then rank results by the number of times that code is exposed on a high value server connected to the internet...?
I don’t think it’s worth the effort to extend that to look for tainted strings, not because it wouldn’t be useful, but because it would be hard to do (as an extreme example: is data read from a file user input? It could be a file containing internationalization info)
The (relatively) few programs that construct format strings on the fly will have to add pragmas to disable these warnings.
Re: Best of show – abuse of libc
#73A winner from 1993 is very interesting too: https://www.ioccc.org/years.html#1993_dgibson It implements Conway's Game of Life by creating a DSL using the C preprocessor and printf. The output is a program (several initial boards are supplied to bootstrap) which is the input program to be compiled and run to create the next generation. This is the program for a second generation: LIFE L _ _ _ _ _ L _ _ O _ _ L _ _ _ O…
Re: Best of show – abuse of libc
#74Re: Best of show – abuse of libc
#75Earlier quoted context omitted.
Is it possible that it's a joke based on the material of the OP? Maybe we're trapped in some sort of International Obfuscated Internet Thread Contest... Edit: ok, I'm guessing it's a joke about Turing completeness. Loops, you know.
It’s a joke about the recursion introduced here: https://news.ycombinator.com/item?id=25691615 .
Re: Best of show – abuse of libc
#76Earlier quoted context omitted.
Someone should inform The Open Group about this violation of POSIX ;) Another fun fact: glibc does this too, if you compile with -D_FORTIFY_SOURCE=2. However, since Linux lacks the nice vm_region APIs the code opens up /proc/self/maps :/
dyld on Darwin has an API to ask if any pointer is to a read-only section of a binary. It’s useful because you can e.g. skip strcpys and other allocations.
Re: Best of show – abuse of libc
#77How did printf end up here in the first place? Decades of feature additions, or were these features a part of an early spec?
%n was defined in C89, the first C standard: http://port70.net/~nsz/c/c89/c89-draft.html#4.9.6.1 Looking at old source code, the earliest implementation I found is 4.3BSD Tahoe (1988). See https://www.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Tahoe/usr/... Second oldest I found was Tenth Edition [Research] Unix (1989). See ocvt_n at https://www.tuhs.org/cgi-bin/utree.pl?file=V10/libc/stdio/vf... I couldn't find support i…
Re: Best of show – abuse of libc
#78Earlier quoted context omitted.
%n was defined in C89, the first C standard: http://port70.net/~nsz/c/c89/c89-draft.html#4.9.6.1 Looking at old source code, the earliest implementation I found is 4.3BSD Tahoe (1988). See https://www.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Tahoe/usr/... Second oldest I found was Tenth Edition [Research] Unix (1989). See ocvt_n at https://www.tuhs.org/cgi-bin/utree.pl?file=V10/libc/stdio/vf... I couldn't find support i…
I'm pretty sure the compilers from Microsoft and Borland supported %n earlier than that. The earliest one I have easy access to that supports it is Microsoft C 4.0 from 1986.
Re: Best of show – abuse of libc
#79Earlier quoted context omitted.
GNU's printf is Turing complete[0]... so "yes." [0] Mentioned (but not directly linked) by TFA: https://www.usenix.org/conference/usenixsecurity15/technical...
I've always wanted a Turing-complete printing function.
Re: Best of show – abuse of libc
#80Earlier 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?