I am trying to run a program compiled from C code from an unknown source. I want to make sure that the program does not harm my system in anyway. Like for instance, the program might have soemthing like system("rm -rf /")
in the source, which is un-detectable, unless the code is thoroughly examined.
I thought of the following 2 ways
- Run it inside a VM like VMWare
- Build a windows exe on linux and run on wine
Both are not very elegant solutions and I cannot automate them. and also, in case of 1, it can harm the VM.
Any help would be appreciated.
I want to run the program in what we can call a "sandbox".
The wikipedia page for chroot may be a good start. It describes chroot and also provides links to a few, more thorough alternatives.
Create an user that has write access only to non-critical directories. Run the program as that user. If you are also interested in privacy, consider also restricting its read rights.
In addition of other answers, using
strace
orltrace
may help you to understand what the program is doing.