OSEP-Code-Snippets icon indicating copy to clipboard operation
OSEP-Code-Snippets copied to clipboard

Linux SimpleShellcodeLoader.c Segfault

Open beelow2010 opened this issue 2 years ago • 3 comments

Hi there,

while studying for OSEP I stumbled across your SimpleShellcodeLoader for Linux and gave it a shot. Unfortunately running it causes a Segfault on my end and this page explains why I guess. The compiler flag -execstack didnt work on my client (current Kali build). In the second part of his blog he shows how to fix those issues, but the code will differ from your "simpler" version (basically easy copy paste, I tested it and it works really good). Just wanted to provide the info in case someone else gets stuck here :)

beelow2010 avatar Jul 19 '22 21:07 beelow2010

Hi @beelow2010, thanks for submitting this issue!

Odd that the -z execstack option did not work for you, IIRC it was explicitly mentioned to be used in the course materials. Since altering the snippet would diverge from the way it is discussed in the course I will refrain from doing that. I will however keep this issue open for reference :)

chvancooten avatar Jul 25 '22 09:07 chvancooten

Hello again, you're welcome :)

It is correct that it's mentioned in the course and also in the blog port that I linked it states that it is supposed to work but for some reason it didn't on my end with a fresh Kali Install. But as you said, maybe the reference will help some people that run into the same issue - so thanks for your response! :)

beelow2010 avatar Jul 25 '22 09:07 beelow2010

Posting this blog since it helped me understand why I was receiving a segfault. I moved the unsigned char buf[] variable down into the main function and it worked fine for me. Don't forget to compile with -z execstack

theGuildHall avatar Aug 04 '22 14:08 theGuildHall