当前位置: 首页 > news >正文

杭州滨江建行网站网站设计说明范文

杭州滨江建行网站,网站设计说明范文,重庆品牌营销型网站建设,小程序需不需要服务器在攻击中,命令注入是比较常见的方式,今天我们细说在软件开发中如何避免命令执行漏洞 我们通过DVWA中不同的安全等级来细说命令执行漏洞 1、先调整DVWA的安全等级为Lower,调整等级在DVWA Security页面调整 2、在Command Injection页面输入127.0.0.1&…

在攻击中,命令注入是比较常见的方式,今天我们细说在软件开发中如何避免命令执行漏洞

我们通过DVWA中不同的安全等级来细说命令执行漏洞

1、先调整DVWA的安全等级为Lower,调整等级在DVWA Security页面调整

2、在Command Injection页面输入127.0.0.1&whoami 点击提交

这里返回是ping Ip的响应时间和当前登录系统的用户,说明后面的whoami命令已经执行了,这样就是存在命令执行漏洞,我们看看这个地方源码是怎么写的,

我们点击View Source,获取源代码,进行代码分析

代码分析:

<?phpif( isset( $_POST[ 'Submit' ]  ) ) {// Get input$target = $_REQUEST[ 'ip' ];// Determine OS and execute the ping command.if( stristr( php_uname( 's' ), 'Windows NT' ) ) {// Windows$cmd = shell_exec( 'ping  ' . $target );}else {// *nix$cmd = shell_exec( 'ping  -c 4 ' . $target );//shell_exec通过shell环境执行命令,并且将完整的输出以字符串的方式返回}// Feedback for the end userecho "<pre>{$cmd}</pre>";
}?>

3、在DVWA Security页面将安全等级调整为Medium ,我们在执行命令

执行127.0.0.1&&whoami出现信息不返回的情况

执行127.0.0.1&whoami信息还是可以返回,说明命令执行漏洞还在

代码分析:

<?phpif( isset( $_POST[ 'Submit' ]  ) ) {// Get input$target = $_REQUEST[ 'ip' ];// Set blacklist$substitutions = array('&&' => '',';'  => '',//这里只是将 && 和;这2种字符进行了删除);// Remove any of the characters in the array (blacklist).$target = str_replace( array_keys( $substitutions ), $substitutions, $target );// Determine OS and execute the ping command.if( stristr( php_uname( 's' ), 'Windows NT' ) ) {// Windows$cmd = shell_exec( 'ping  ' . $target );//shell_exec通过shell环境执行命令,并且将完整的输出以字符串的方式返回}else {// *nix$cmd = shell_exec( 'ping  -c 4 ' . $target );}// Feedback for the end userecho "<pre>{$cmd}</pre>";
}?>

4、在DVWA Security页面将安全等级调整为High  ,我们在执行命令

执行127.0.0.1&whoami出现信息不返回的情况,说明&符合的漏洞已经修复

执行127.0.0.1|whoami信息还是可以返回,说明命令执行漏洞还在

代码分析:

<?phpif( isset( $_POST[ 'Submit' ]  ) ) {// Get input$target = trim($_REQUEST[ 'ip' ]);// Set blacklist$substitutions = array('&'  => '',';'  => '','| ' => '','-'  => '','$'  => '','('  => '',')'  => '','`'  => '','||' => '',//这里只是将上面9中字符进行拦截和删除。删除命令中的"| " 不是"|",多一个空格);// Remove any of the characters in the array (blacklist).$target = str_replace( array_keys( $substitutions ), $substitutions, $target );// Determine OS and execute the ping command.if( stristr( php_uname( 's' ), 'Windows NT' ) ) {// Windows$cmd = shell_exec( 'ping  ' . $target );//shell_exec通过shell环境执行命令,并且将完整的输出以字符串的方式返回}else {// *nix$cmd = shell_exec( 'ping  -c 4 ' . $target );}// Feedback for the end userecho "<pre>{$cmd}</pre>";
}?>

5、在DVWA Security页面将安全等级调整为Impossible ,我们在执行命令

执行127.0.0.1|whoami将会被拦截。

代码分析:

<?phpif( isset( $_POST[ 'Submit' ]  ) ) {// Check Anti-CSRF tokencheckToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'index.php' );// Get input$target = $_REQUEST[ 'ip' ];$target = stripslashes( $target );//去除用户输入的\,防止转移// Split the IP into 4 octects$octet = explode( ".", $target );//把用户输入的数据根据.进行分开,比如127.0.0.1会分开成127 0 0 1// Check IF each octet is an integerif( ( is_numeric( $octet[0] ) ) && ( is_numeric( $octet[1] ) ) && ( is_numeric( $octet[2] ) ) && ( is_numeric( $octet[3] ) ) && ( sizeof( $octet ) == 4 ) ) {//分别判断分开的4个部分是不是数字,如果有不是数字的直接不允许访问// If all 4 octets are int's put the IP back together.$target = $octet[0] . '.' . $octet[1] . '.' . $octet[2] . '.' . $octet[3];//把验证完是数字的4部分在用.拼接起来// Determine OS and execute the ping command.if( stristr( php_uname( 's' ), 'Windows NT' ) ) {// Windows$cmd = shell_exec( 'ping  ' . $target );}else {// *nix$cmd = shell_exec( 'ping  -c 4 ' . $target );}// Feedback for the end userecho "<pre>{$cmd}</pre>";}else {// Ops. Let the user name theres a mistakeecho '<pre>ERROR: You have entered an invalid IP.</pre>';}
}// Generate Anti-CSRF token
generateSessionToken();?>

http://www.yayakq.cn/news/543430/

相关文章:

  • 网页设计欣赏熊出没seo技术导航
  • 国外网站引流如何做成都最新热门事件
  • 网站设为主页功能怎么做漳州城乡和建设局网站
  • 东莞加盟网站建设户户通行业网站
  • 建设网站那个好怎么判断网站的好坏
  • 浙江做铁塔的公司网站重庆做网站及公众号公司
  • 从美洲开始做皇帝免费阅读网站广州企业vi设计公司
  • 那个网站做室内比较好的电影推荐网站开发
  • 网站运营需要服务器吗创建网页步骤
  • 算命网站开发电话襄阳建设网站
  • 浙江第一水电建设集团网站金昌做网站
  • 建国外网站wordpress技巧:开启wordpress多站点功能
  • 做电影电视剧网站推广自己搭建公司网站
  • 北海网站开发哪个cms好用
  • 许昌建设网站哪家好设计官网中文版
  • 广州网站制作公司优化户县规划建设和住房保障局网站
  • 有做二手厨房设备的网站吗企业网站建设移动
  • 东莞seo网站优化免费的cms视频网站
  • 做化工哪个网站好百度关键词搜索次数
  • 网站建设分为哪些内容做导购型网站
  • 茂名整站优化求一个做门窗技术的网站
  • 网站建设夬金手指花总p6项目管理软件
  • 网站建设车成本手机上制作ppt的软件
  • 招聘网站开发的公司中华建设杂志社网站
  • 建设常规的网站报价是多少钱网站后台如何更改
  • SEO网站链接模型网站自动优化
  • 网站设计的专业流程国外创意型网站设计
  • 贵阳市网站建设o2o与网站建设
  • 有做网站代理运营的吗电子商务购物网站建设实验报告
  • 建设很多网站能赚到钱wordpress背景图