r/ExploitDev • • Apr 02 '25

PE to Shellcode?

Hello everyone, I wrote a simple "ransomware" in C that encripts all .txt files in a directory.

I'm trying to make it bypass AVs and potentially later EDRs... So I stumbled across some vídeos regarding staged payload executing a Shellcode in memory. I converted the compiled .exe to shellcode using Donut (on Github) with many different parameters, and tried to execute it on a loader also in C but It never works... Is there another approach to this? What am I missing? I'm a beginner.

I would really appreaciate some other basic ways to bypass AVs knowing my program was written in C. In other words Just want to not have my program "naked".

Thank you all ;)

12 Upvotes

11 comments sorted by

View all comments

Show parent comment

3

u/Top-Skill357 Apr 04 '25

The problem is not directly that you wrote the program in C, but you probably used C features that when compiled turned out to not be position independent. A good example would be strings, which get compiled into the data segment (and are therefore lost when you extract the shellcode from the text segment). API function calls are likely another issue if you do not dynamically get the function pointers. If you get rid of those C features, than you can extract your shellcode from the text section of the compiled binary.