Ci

image.png

1. Python - Command Injection via Sub process

   import subprocess

   command = input("Enter the command to run: ")
   subprocess.call(command, shell=True)

2. PHP - Command Injection in System Functions

   <?php
   $file = $_GET['file'];
   system("cat " . $file);
   ?>

3. Java - Command Injection with Runtime.exec()

  import java.io.*;

  public class CommandInjection {
      public static void main(String[] args) throws IOException {
          String userInput = args[0];
          Runtime.getRuntime().exec("ping " + userInput);
      }
  }

4. Bash - Command Injection via Variable Substitution

   #!/bin/bash
   echo "Enter your name:"
   read name
   eval "echo Hello, $name"

5. Node.js - Command Injection with child_process.exec

   const { exec } = require('child_process');

   const userInput = process.argv[2];
   exec(`ls ${userInput}`, (error, stdout, stderr) => {
       if (error) {
           console.error(`Error: ${error.message}`);
           return;
       }
       console.log(`Output: ${stdout}`);
   });

6. C - Command Injection in System Calls