w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Executing shell commands from a C program

/bin/echo is a C program, usually.

/bin/echo ls | sh

VoilĂ ! A C program just wrote to the standard input of a running shell, and a command was executed. This is demonstrably possible.

man popen is now your friend. (Any more is really beyond SuperUser's scope, as is discussion of other things such as system() and the need for quoting.)

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.