搜索
查看: 390|回复: 0

[CVE-2014-5284]OSSEC存在利用tmp目录的文件覆盖/etc/hosts.deny安全漏洞

[复制链接]

1839

主题

2255

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
11913
发表于 2014-9-17 18:31:30 | 显示全部楼层 |阅读模式
链接:https://github.com/ossec/ossec-hids/releases/tag/2.8.1
影响版本:所有版本  OSSEC 0.5 (released 11/2005) - 2.8
细节:
脚本文件host-deny.sh有代码片段如下:
  1. 111 # Deleting from hosts.deny
  2. 112 elif [ "x${ACTION}" = "xdelete"  ]; then
  3. 113 lock;
  4. 114 if [ "X$UNAME" = "XFreeBSD"  ]; then
  5. 115 cat /etc/hosts.allow | grep -v "ALL : ${IP} : deny$"> /tmp/hosts.deny.$
  6. 116 mv /tmp/hosts.deny.$ /etc/hosts.allow
  7. 117 else
  8. 118 cat /etc/hosts.deny | grep -v "ALL:${IP}$"> /tmp/hosts.deny.$
  9. 119 cat /tmp/hosts.deny.$ > /etc/hosts.deny
  10. 120 rm /tmp/hosts.deny.$
  11. 121 fi
复制代码

第115行~118行  可以看到 将tmp目录下的文件直接移动到了/etc/hosts.allow

利用思路:
通过竞争关系,覆盖/etc/hosts.deny,如下:
1) 创建 /tmp/hosts.deny.$$ 文件
2) 等待管理员覆盖这个文件
3) 在该文件移动到 /etc/hosts.deny前 写入数据
通过 Inotify进程实时监控文件完成

利用演示代码:
  1. # [user@host ~]$ ./ossec2root.pl
  2. # Creating /tmp/hosts.deny.300 through /tmp/hosts.deny.65536 ...done
  3. # Monitoring /tmp ...
  4. #
  5. # (ssh root@host a few times with an incorrect password)
  6. # (10 minutes pass???)
  7. #
  8. # [user@host ~]$ cat /etc/hosts.deny
  9. # cat /etc/hosts.deny
  10. # sshd : ALL : twist id | wall
  11. #
复制代码

最新版 2.8.1 已经修复
过段时间可能会取消签到功能了
您需要登录后才可以回帖 登录 | Join BUC

本版积分规则

Powered by Discuz!

© 2012-2015 Baiker Union of China.

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