设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 4651|回复: 5
收起左侧

[PHP/ASP/JSP] PHPnow-1.5.6| Servkit 默认页 index.php 防恶意MySQL连接请求漏洞补丁源码修改方法

[复制链接]
发表于 2019-1-31 10:56:54 | 显示全部楼层 |阅读模式
查找以下代码:

  1. <form method="post" action="<?=_SERVER('PHP_SELF')?>">
  2. <table width="100%" class="info">
  3.   <tr>
  4.     <th colspan="4">MySQL 连接测试</th>
  5.   </tr>

  6.   <tr>
  7.     <td>MySQL 服务器</td>
  8.     <td><input type="text" name="mysqlHost" value="localhost" /></td>
  9.     <td>MySQL 数据库名</td>
  10.     <td><input type="text" name="mysqlDb" value="test" /></td>
  11.   </tr>

  12.   <tr>
  13.     <td>MySQL 用户名</td>
  14.     <td><input type="text" name="mysqlUser" value="root" /></td>
  15.     <td>MySQL 用户密码</td>
  16.     <td><input type="text" name="mysqlPassword" /></td>
  17.   </tr>

  18.   <tr>
  19.     <td colspan="4" align="right"><input type="submit" value="连接" name="act" /> &</td>
  20.   </tr>
  21. </table>
  22. </form>

  23. <?php if(isset($_POST['act'])) {?>
  24. <br />

  25. <table width="100%" class="info">
  26.   <tr>
  27.     <th colspan="4">MySQL 测试结果</th>
  28.   </tr>

  29. <?php
  30. $link = @mysql_connect($_POST['mysqlHost'], $_POST['mysqlUser'], $_POST['mysqlPassword']);
  31. $errno = mysql_errno();
  32. if ($link) $str1 = '<span style="color: #008000; font-weight: bold;">OK</span> ('.mysql_get_server_info($link).')';
  33. else $str1 = '<span style="color: #ff0000; font-weight: bold;">Failed</span><br />'.mysql_error();
  34. ?>
  35.   <tr>
  36.     <td colspan="2">服务器 <?=$_POST['mysqlHost']?></td>
  37.     <td colspan="2"><?=$str1?></td>
  38.   </tr>

  39.   <tr>
  40.     <td colspan="2">数据库 <?=$_POST['mysqlDb']?></td>
  41.     <td colspan="2"><?=(@mysql_select_db($_POST['mysqlDb'],$link))?'<span style="color: #008000; font-weight: bold;">OK</span>':'<span style="color: #ff0000; font-weight: bold;">Failed</span>'?></td>
  42.   </tr>
  43. </table>
  44. <?}?>
复制代码


修改为以下代码:


  1. <form method="post" action="<?=_SERVER('PHP_SELF')?>">

  2. <?php
  3. function isLockMySQL(){
  4.         return @file_get_contents("MySQLConnectError.lock") >= 30 ? 1 : 0;
  5. }

  6. function AddMySQLError(){
  7.         file_put_contents("MySQLConnectError.lock",abs(@file_get_contents("MySQLConnectError.lock"))+1);
  8.         return "";
  9. }


  10. if(isLockMySQL()){ ?>
  11. <table width="100%" class="info">
  12.   <tr>
  13.     <th>MySQL 连接测试</th>
  14.   </tr>
  15. <tr>
  16. <td><center>MySQL连接失败次数过多,已被PHPnow拒绝,请删除根目录MySQLConnectError.lock 文件</center></td>
  17. </tr>
  18. </table>
  19. </form>
  20. <?php } else { ?>


  21. <table width="100%" class="info">
  22.   <tr>
  23.     <th colspan="4">MySQL 连接测试</th>
  24.   </tr>

  25.   <tr>
  26.     <td>MySQL 服务器</td>
  27.     <td><input type="text" name="mysqlHost" value="localhost" /></td>
  28.     <td>MySQL 数据库名</td>
  29.     <td><input type="text" name="mysqlDb" value="test" /></td>
  30.   </tr>

  31.   <tr>
  32.     <td>MySQL 用户名</td>
  33.     <td><input type="text" name="mysqlUser" value="root" /></td>
  34.     <td>MySQL 用户密码</td>
  35.     <td><input type="text" name="mysqlPassword" /></td>
  36.   </tr>

  37.   <tr>
  38.     <td colspan="4" align="right"><input type="submit" value="连接" name="act" /> &</td>
  39.   </tr>
  40. </table>
  41. </form>



  42. <?php if(isset($_POST['act'])) {?>
  43. <br />

  44. <table width="100%" class="info">
  45.   <tr>
  46.     <th colspan="4">MySQL 测试结果</th>
  47.   </tr>

  48. <?php
  49. $link = @mysql_connect($_POST['mysqlHost'], $_POST['mysqlUser'], $_POST['mysqlPassword']);
  50. $errno = mysql_errno();
  51. if ($link) $str1 = '<span style="color: #008000; font-weight: bold;">OK</span> ('.mysql_get_server_info($link).')';
  52. else $str1 = '<span style="color: #ff0000; font-weight: bold;">Failed</span><br />'.mysql_error().AddMySQLError();
  53. ?>
  54.   <tr>

  55.     <td colspan="2">服务器 <?=$_POST['mysqlHost']?></td>
  56.     <td colspan="2"><?=$str1?></td>
  57.   </tr>

  58.   <tr>
  59.     <td colspan="2">数据库 <?=$_POST['mysqlDb']?></td>
  60.     <td colspan="2"><?=(@mysql_select_db($_POST['mysqlDb'],$link))?'<span style="color: #008000; font-weight: bold;">OK</span>':'<span style="color: #ff0000; font-weight: bold;">Failed</span>'?></td>
  61.   </tr>
  62. </table>
  63. <?}}?>

复制代码

修改以后,MySQL登录失败超30次将被拒绝连接,必须删除指定lock文件后解除。

发表于 2019-1-31 16:38:11 | 显示全部楼层
昨天说要删今天出了个补丁
发表于 2019-2-4 00:19:59 | 显示全部楼层
这名字和经营范围完全文不对题
发表于 2019-2-6 12:39:32 | 显示全部楼层
这个名字想了很9 发表于 2019-2-4 00:19
这名字和经营范围完全文不对题

现在改了
发表于 2019-4-11 23:38:19 来自手机 | 显示全部楼层
520 发表于 2019-2-6 12:39
现在改了

改的什么鬼名字
您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-20 05:17 , Processed in 0.457026 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表