linux – 是否可以在shell脚本中使用命令注入而不使用eval?
发布时间:2020-12-14 02:14:06 所属栏目:Linux 来源:网络整理
导读:我想知道,现在使用最新版本的sh,bash,ksh等可以通过执行这个(非常简单的)脚本来获取命令注入吗? #!/bin/shecho "What is the name of the program you are looking for?"read programlocate $program 尽管如果他们有shell当然可以执行代码,我只是想知道变量
我想知道,现在使用最新版本的sh,bash,ksh等可以通过执行这个(非常简单的)脚本来获取命令注入吗?
#!/bin/sh echo "What is the name of the program you are looking for?" read program locate $program 尽管如果他们有shell当然可以执行代码,我只是想知道变量是否可以包含恶意代码,例如在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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |