Does Java have buffer overflows?

Since Java Strings are based on char arrays and Java automatically checks array bounds, buffer overflows are only possible in unusual scenarios: If you call native code via JNI In the JVM itself (usually written in C++) The interpreter or JIT compiler does not work correctly (Java bytecode mandated bounds checks)

Buffer overflow works in gdb but not without it

Exploit development can lead to serious headaches if you don’t adequately account for factors that introduce non-determinism into the debugging process. In particular, the stack addresses in the debugger may not match the addresses during normal execution. This artifact occurs because the operating system loader places both environment variables and program arguments before the beginning … Read more

How to turn off gcc compiler optimization to enable buffer overflow

That’s a good problem. In order to solve that problem you will also have to disable ASLR otherwise the address of g() will be unpredictable. Disable ASLR: sudo bash -c ‘echo 0 > /proc/sys/kernel/randomize_va_space’ Disable canaries: gcc overflow.c -o overflow -fno-stack-protector After canaries and ASLR are disabled it should be a straight forward attack like … Read more