aen*_*ood 5 linux security bash shell code-injection
我想知道,现在使用最新版本的sh,bash,ksh等可以通过执行这个(非常简单的)脚本来获取命令注入吗?
#!/bin/sh
echo "What is the name of the program you are looking for?"
read program
locate $program
Run Code Online (Sandbox Code Playgroud)
尽管如果他们有shell当然可以执行代码,我只是想知道变量是否可以包含恶意代码,例如在PHP中:
parameter=parameter;ls
Run Code Online (Sandbox Code Playgroud)
此问题中也可以忽略shellshock(env变量).
对的,这是可能的。但事情并不像你说的那么简单。请参阅下面的一些示例。
它不会起作用:
$ read -p "Type some text:" var1
Type some text:Example;hostname
$ echo $var1
Example;hostname
$ $var1
Example;hostname: command not found
Run Code Online (Sandbox Code Playgroud)
但如果你像这样使用,是的,它会起作用:
$ read -p "Type some text:" var1
Type some text:hostname
$ echo $var1
hostname
$ $var1
SSBLZMVM1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5920 次 |
| 最近记录: |