aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examples/command-injection')
-rw-r--r--examples/command-injection/command-injection.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/command-injection/command-injection.c b/examples/command-injection/command-injection.c
new file mode 100644
index 0000000..914b32e
--- /dev/null
+++ b/examples/command-injection/command-injection.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+ char cmd[strlen(argv[1]) + 6];
+ strcpy(cmd, "echo ");
+ strcat(cmd, argv[1]);
+ system(cmd);
+
+ return 0;
+}