我想知道,如今使用最新版本的sh,bash,ksh等,是否可以通过执行此(非常简单的)脚本来获得命令注入?
#!/bin/sh
echo "What is the name of the program you are looking for?"
read program
locate $program
尽管事实上如果有人拥有外壳,他们已经可以执行代码,但我只是想知道变量是否可以包含恶意代码,例如PHP:
parameter=parameter;ls
在这个问题上,shellshock(env变量)也可以忽略。
对的,这是可能的。但这并不像您提到的那么简单。参见下面的一些示例。
它不起作用:
$ read -p "Type some text:" var1
Type some text:Example;hostname
$ echo $var1
Example;hostname
$ $var1
Example;hostname: command not found
但是,如果使用这种方式,是的,它将起作用:
$ read -p "Type some text:" var1
Type some text:hostname
$ echo $var1
hostname
$ $var1
SSBLZMVM1
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句