既然大家都放出来好多了,我就放个截图好啦…
为了兼容性,可是煞费苦心…诶..
没有网络安全,就没有国家安全
总是记不住这几条语句。。。
其实根本原因还是平时用的不是很多,所以写到这里,以方便查阅和测试使用。
开启xp_cmdshell存储过程 --允许配置高级选项 EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO --开启xp_cmdshell服务 EXEC sp_configure 'xp_cmdshell', 1 RECONFIGURE GO --使用 xp_cmdshell master..xp_cmdshell 'copy d:\db_backup\test.bak m:' 关闭xp_cmdshell存储过程 -- 允许配置高级选项 EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO -- 禁用xp_cmdshell EXEC sp_configure 'xp_cmdshell', 0 GO RECONFIGURE GO
译作命令执行
该题目非常简单,即在输入框本应该输入IP或者域名执行ping,但是由于没有做足够的限制,导致用户可以任意构造该命令。
代码如下所示:
<?php if( isset( $_POST[ 'submit' ] ) ) { $target = $_REQUEST[ 'ip' ]; // Determine OS and execute the ping command. if (stristr(php_uname('s'), 'Windows NT')) { $cmd = shell_exec( 'ping ' . $target ); echo '<pre>'.$cmd.'</pre>'; } else { $cmd = shell_exec( 'ping -c 3 ' . $target ); echo '<pre>'.$cmd.'</pre>'; } } ?>
$cmd = shell_exec( ‘ping -c 3 ‘ . $target );
此处的代码未对$_REQUEST[ ‘ip’ ];做任何的处理,并赋值给$target,导致$target可被用户任意控制,因此可以进行构造,执行任意系统命令。