• 修改Emlog验证码机制,有效防止恶意识别/解决恶意评论灌水


     Emlog被恶意评论灌水解决方法,关于Emlog验证码机制问题,用emlog程序都知道,它已经不存在更新了,所以emlog评论验证码代码年久失修了,可以无视验证码评论,因此咱也不说是谁的刷灌水机了。
    验证码绕过漏洞原理:
    1、利用NULL和空字符串比较的结果是TRUE从而绕过验证码检查逻辑
    2、正常留言输入验证码进行BurpSuite抓包
    3、将PHPSESSID修改成随意一个值,目的是让其$_SESSION不存在,再将imgcode修改成空。
    4、发送数据包,可见没有提示失败(302跳转了),说明评论成功。
    5、载入一个字典,即可刷评论。
    6、可利用代理IP多线程即可实现无拦截评论恶意灌水轰炸
    处理方案一:
    1.开启session并且将是否为空的行为进行判断
    2.违规词拦截(emlog用户免费提供emlog违规词拦截魔改插件和极猫云WAF防护)
    3.添加第三方滑块验证
    修复方案二:修改Emlog验证码机制
    1、打开程序路径/include/lib/checkcode.php文件,把下面代码全部替换到checkcode.php里面即可

    1. /**
    2. * Emlog验证码防干扰
    3. * https://www.58soho.cn/jianzhan/10558.html
    4. */
    5. session_start();
    6. $randCode = '';
    7. $chars = 'abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPRSTUVWXYZ23456789';
    8. for ( $i = 0; $i < 5; $i++ ){
    9. $randCode .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
    10. }
    11. $_SESSION['code'] = strtoupper($randCode);
    12. $img = imagecreate(75,25) or die("创建图像资源失败,请刷新页面");
    13. $bgColor = isset($_GET['mode']) && $_GET['mode'] == 't' ? imagecolorallocate($img,245,245,245) : imagecolorallocate($img,255,255,255);
    14. $pixColor = imagecolorallocate($img,mt_rand(88, 245), mt_rand(55, 240), mt_rand(99, 200));
    15. //画字符、大小
    16. for($i = 0; $i < 5; $i++){
    17. $x = $i * 13 + mt_rand(3, 7) - 2;
    18. $y = mt_rand(0, 3);
    19. $text_color = imagecolorallocate($img, mt_rand(100, 250), mt_rand(80, 180), mt_rand(90, 220));
    20. imagechar($img, 5, $x + 5, $y + 3, $randCode[$i], $text_color);
    21. }
    22. //画干扰点
    23. for($j = 0; $j < 240; $j++){
    24. $x = mt_rand(0,500);
    25. $y = mt_rand(0,100);
    26. imagesetpixel($img,$x,$y,$pixColor);
    27. }
    28. //4条横斜线
    29. for ($i=0; $i < 5; $i++) {
    30. $lineColor = imagecolorallocate($img, rand(50, 150), rand(50, 150), rand(50, 150));
    31. $lineX1 = 0;
    32. $lineX2 = 90;
    33. $lineY1 = ($i + 1) * 8;
    34. $lineY2 = ($i + 1) * 15;
    35. imageline($img, $lineX1, $lineY1, $lineX2, $lineY2, $lineColor);
    36. }
    37. //4条竖斜线
    38. for ($i=0; $i < 5; $i++) {
    39. $lineColor = imagecolorallocate($img, rand(50, 150), rand(50, 150), rand(50, 150));
    40. $lineY1 = 0;
    41. $lineY2 = 90;
    42. $lineX1 = ($i + 1) * 8;
    43. $lineX2 = ($i + 1) * 15;
    44. imageline($img, $lineX1, $lineY1, $lineX2, $lineY2, $lineColor);
    45. }
    46. header('Content-Type: image/png');
    47. imagepng($img);
    48. imagedestroy($img);
  • 相关阅读:
    【Python微信机器人】第一篇:在windows11上编译python
    二十三种设计模式全面解析-组合模式与迭代器模式的结合应用:构建灵活可扩展的对象结构
    临沂ISO食品安全管理体系认证
    【Unity每日一记】如何在Unity里面添加视频,做媒体屏幕
    git stash 暂存当前修改
    澳元兑美元预测:美元可能因美国经济衰退担忧而进一步下跌(MogaFX)
    JAVA 单例模式
    面试官:Go 如何实现可重入锁
    AI推介-大语言模型LLMs论文速览(arXiv方向):2024.03.01-2024.03.05
    开发工具:推荐一款非常好用的SSH客户端WindTerm
  • 原文地址:https://blog.csdn.net/m0_66047725/article/details/127839749