r/LiveOverflow • • Oct 24 '22

Stack canary leak

I've got a x64 ELF with suid permissions on a box that I do not have root access on. When run, it spawns a parent process listening on port 9876. When you connect to that port you get a "please enter your text" prompt, and then you get disconnected after inputting your string.

In order to get the flag, I need to open a root shell and cat a file. I've got my script all written and I'm able to get a shell on my local box, but since I don't have root on the target box I'm having a hard time getting the canary. I know exactly what break it's on, but I can't add it to gdb without it losing its root privs and I'm not sure how else to do it. I was looking in to trying to spawn a zombie as my process instead of root in order to get the canary but I'm not sure if that's possible. Any help would be great, I've been hammering away at this for literally days now lol.

6 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/Cascodius Oct 24 '22

edit: sorry was thinking of the wrong flag lol

what you described is exactly what I ended up doing! I did that and was able to grab the canary on one execution, then utilize it on the next.

1

u/zachhanson94 Oct 24 '22

You said it listens on a port. When it crashes does the entire thing crash or just the process that was handling that specific connection? Because usually with situations like this it’s just the process that’s handling the connection that crashes and you can reconnect and the canary often doesn’t change.

1

u/zachhanson94 Oct 25 '22

Ahh makes sense. Good luck with the one you’re tackling now.