I am interested in demoing printf
vulnerabilities via an NDK app. To be clear, I am aware that to log in the console we can use __android_log_print(ANDROID_LOG_DEBUG, "LOG_TAG", "Print : %d %s",someVal, someStr);
. I have tried it and I know it works. But I explicitly want to demo the vulnerabilities of printf()
, specifically to use the %n
specifier to write to a pointed location.
Is there a way to make printf()
work to this effect or is it possible to achieve this via __android_log_print()
? I attempted it with the android/log.h
header but it didn't work.
I can get the app to crash by running something along the lines of printf(%s%s%s%s%s%s%s%s%s%s)
. But again, I can't manipulate pointers.
For general knowledge purposes, why is it that printf()
doesn't work in the first place and how does __android_log_print()
prevent these exploits?