Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
C code that can be “compiled” by sha384 (weijr-eng.blogspot.com)
14 points by tjwei on Sept 15, 2014 | hide | past | favorite | 2 comments


"sha384 was chosen because it is possible to fit an ELF binary into sha384 digest"

Except none of the sources have a sha384 that ends up being an ELF binary.

In the first example, the important thing is that the sha384 digest starts with 0a23, so "\n#" so that this essentially "compiles" to an empty shell script.

In the second example, the digest starts with 2e202a0a, which is ". * \n", so it only really works because the source, 0.c, is the first file in the directory, and is both a sourceable shell script and a C source file. Remove it, and the trick doesn't work anymore.

In the final one, the trick is similar, but the digest starts with "sh * \n" instead.

EDIT: asterisks are inconveniently turned into italic formatting. Consider all asterisks in this post as not followed by a whitespace.


Thank you, I was wondering how this could possibly work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: