Skip to content

Print Stack Canary โ€‹

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

Enlarge printed stack โ€‹

Imagine a situation where a program vulnerable to stack overflow can execute a puts function pointing to part of the stack overflow. The attacker knows that the first byte of the canary is a null byte (\x00) and the rest of the canary are random bytes. Then, the attacker may create an overflow that overwrites the stack until just the first byte of the canary.

Then, the attacker calls the puts functionality on the middle of the payload which will print all the canary (except from the first null byte).

With this info the attacker can craft and send a new attack knowing the canary (in the same program session).

Obviously, this tactic is very restricted as the attacker needs to be able to print the content of his payload to exfiltrate the canary and then be able to create a new payload (in the same program session) and send the real buffer overflow.

CTF examples:

Arbitrary Read โ€‹

With an arbitrary read like the one provided by format strings it might be possible to leak the canary. Check this example: https://ir0nstone.gitbook.io/notes/types/stack/canaries and you can read about abusing format strings to read arbitrary memory addresses in:

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks: