i have a simple programme that shuts down a computer but it always gets detected as a virus when i share the exe file so i was wondering if i could make the programme treat a part of the code like a comment until it is run. for example before it is run
#include <stdio.h>
#include <stdlib.h>
int main()
{
if(programme is running)
{remove /* on line 8;}
/*system("C:\\WINDOWS\\System32\\shutdown /s");*/
return 0;
}
i tried storing it in a zip but it still gets detected as a virus. that is why i was looking for a way to make it self modifying so it can bypass windows security
What you are asking cannot be done. During compilation, all comments are disregarded, so the compiled binary code will have no trace of the comments.
Within the specifications of the C language, it is not possible to change the executable code, only modifiable data.
Hence, unless you will be doing low-level tricks (possibly outdated) you are limited to modifying the program data.
You could, for example, store the system command string
"C:\\WINDOWS\\System32\\shutdown /s"in an "encrypted" string:and then have the code modify it into the real command before running it. In this case:
However, as others have commented, this is unlikely to make a difference in your underlying problem of the program being treated as a threat.
I would guess that making a truly self-modifying program makes it more - and not less - likely that the OS or anti-malware monitoring will see the program as a threat.