System call injection

With the follow commands you can execute an external program on the system (server).

  • shell_exec
  • proc_open
  • system
  • exec
  • passthru
  • popen
  • “ (back tick operator)

This form sends a domain name and prints the result back from the linux program whois.

<input type=”text” name=”domain” value=”” />
<input type=”submit” value=”whois” />

    if ($_GET[‘domain’]) {
        system(“whois “.$_GET[‘domain’]);

send to the whois program

whois output

The problem of this script is that the user input touches directly the system without any validation. An attacker can end the whois command with a semicolon (;) and add any command he wants.

send “;uname -a” to the system and print system informations

whois injected

Using system calls which can be manipulate could be very dangerous. Never trust the user, always Filter Input.
If you must use system calls, use “escapeshellarg” and “escapeshellcmd” to escape strings.

1 comment so far

  1. animal facts on

    The main thing i’m enjoying while reading your blog is the way you write, you are a really charismatic person and your posts are wonderful, keep it up!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: