Loading... [Athena](https://github.com/leesinz/Athena)是Github上的一个开源项目,是一个用于监控各个漏洞源和安全厂商的漏洞通告,并进行实时推送的Python项目,愿能帮助安全团队及时获取高风险漏洞信息,提供快速响应能力。 Athena会聚合所有漏洞源漏洞信息,存入数据库(目前只支持MySQL数据库),并对指定等级威胁的漏洞进行实时推送,推送渠道支持钉钉机器人、企微机器人等等。 ## 已覆盖漏洞源 * afrog * [Exploit-DB](https://www.exploit-db.com/) * [github](https://github.com/) * [metasploit](https://www.metasploit.com/) * [packetstormsecurity](https://packetstorm.news/) * ~~POC(目前作者已经删库了,但是可以改镜像库使用)~~ * [seebug](https://www.seebug.org/) * [vulhub](https://vulhub.org/zh) * [微步漏洞情报](https://x.threatbook.com/v5/vulIntelligence) * [阿里云高危漏洞库](https://avd.aliyun.com/) * [OSCS漏洞情报库](https://www.oscs1024.com/cm) * [奇安信漏洞通告](https://ti.qianxin.com/vulnerability/notice-list) ## 运行逻辑 > 目前除了支持采集,实时推送之外,还对每日所有漏洞信息进行汇总邮件定时推送,以及flask+datatables+echarts实现完整前后端数据展示  ## 如何运行 > 采集脚本需要 **python 3.8+** 以上的环境才能运行,GitHub上是Ubuntu系统为例,所以这里使用CentOS系统手动安装运行 #### 下载安装 Python ```bash ## 下载 Python 3.8.20 源码包 [root@localhost ~]# wget https://www.python.org/ftp/python/3.8.20/Python-3.8.20.tgz ## 解压至文件夹 [root@localhost ~]# tar zxf Python-3.8.20.tgz ## 在编译安装之前,我们需要安装点依赖,例如:gcc、zlib、openssl等等 [root@localhost ~]# yum -y install gcc [root@localhost ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel ## Python 3.7版本之后需要 libffi-devel、zlib [root@localhost ~]# yum -y install libffi-devel zlib* ## 开始编译安装 [root@localhost ~]# mkdir -p /usr/local/python3 [root@localhost ~]# cd Python-3.8.20 [root@localhost ~]# ./configure --with-ssl --prefix=/usr/local/python3 [root@localhost ~]# make [root@localhost ~]# make install ## 建立 Python3 和 pip3 的软链 [root@localhost ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3 [root@localhost ~]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 ## 验证安装结果 [root@localhost ~]# python3 --version Python 3.8.20 [root@localhost ~]# pip3 --version pip 23.0.1 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8) ``` #### 安装MySQL数据库 > 注:CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载 ```bash [root@localhost ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm [root@localhost ~]# yum install mysql-community-server [root@localhost ~]# systemctl start mysqld [root@localhost ~]# systemctl enable mysqld ## 登录验证,并设置用户密码和创建数据库 [root@localhost ~]# mysql -u root mysql> set password for 'root'@'localhost' = password('123456'); mysql> create database athena; ``` #### 安装项目依赖 ```bash [root@localhost ~]# git clone https://github.com/leesinz/Athena.git [root@localhost ~]# cd Athena [root@localhost ~]# pip3 install -r requirements.txt ``` ###### 关于`Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually`报错 ```bash ## 步骤一:安装MySQL数据库开发包 yum install -y mysql-devel ## 步骤二:设置环境变量,编辑/etc/profile文件 export MYSQLCLIENT_CFLAGS="-I/usr/include/mysql" export MYSQLCLIENT_LDFLAGS="-L/usr/lib64/mysql" ## 步骤三:重新加载/etc/profile文件 source/etc/profile ``` ###### 关于OpenSSL版本过低问题 我们可以通过降低urllib3 的版本解决这个问题,`pip3 install urllib3==1.26.15` #### 自定义配置 `vim config.yaml` ```yaml #https://github.com/settings/tokens github: token: "" #collectors默认为空,表示爬取所有漏洞源信息,如需指定特定源,可修改此项.可选项为['POC','Afrog','PacketStorm','Github','Seebug','OSCS','Ali','QAX','ThreatBook','Vulhub','MSF','ExploitDB'] collectors: [] #指定需要实时推送的漏洞等级,默认全部推送,如果只想推送高危和严重漏洞,置为["high", "critical"]即可 severity_filter: ["", "low", "medium", "high", "critical"] #数据库配置 mysql: host: 127.0.0.1 port: 3306 database: "athena" username: "root" password: "123456" #实时推送选项,如需开启,则将enable置为true,并配置相关token notify: #https://developer.work.weixin.qq.com/document/path/91770 wxwork: enable: false key: #https://open.dingtalk.com/document/robots/custom-robot-access dingtalk: enable: false access_token: secret: #https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#9fe10f9b feishu: enable: false webhook: secret: #邮箱配置,在每天6点会推送前一天的漏洞汇总,注意password为授权码 email: smtp_server: smtp_port: username: password: from: to: - - ``` #### 运行程序 `python3 main.py` ```bash [root@localhost ~ ]# python3 main.py _ _ _ / \ | |_ | |__ ___ _ __ __ _ / _ \ | __|| '_ \ / _ \| '_ \ / _` | / ___ \ | |_ | | | || __/| | | || (_| | /_/ \_\ \__||_| |_| \___||_| |_| \__,_| * Serving Flask app 'flaskr.app' * Debug mode: off deployment. Use a production WSGI server instead. * Running on all addresses (0.0.0.0) * Running on http://127.0.0.1:5000 * Running on http://192.168.144.130:5000 Press CTRL+C to quit Collecting data from ExploitDB Collecting data from MSF Collecting data from Vulhub Collecting data from POC Collecting data from Afrog Collecting data from PacketStorm Collecting data from Github Collecting data from OSCS Collecting data from Ali Collecting data from QAX Collecting data from ThreatBook Collecting vulnerabilities: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 11/11 [00:27<00:00, 2.54s/it] Filtering vulnerabilities Selected severity vulnerabilities found: 0 ``` ###### 关于采集GitHub的API时出现401问题 需要再`config.yaml`文件中配置[Github API Token](https://github.com/settings/tokens) ###### 关于采集过程中出现403问题 修改`collectors`文件夹下对应的采集脚本,添加头部请求信息 ```python import requests headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'Referer': 'https://www.example.com/' } response = requests.get('https://api.example.com/data', headers=headers) ``` ###### 关于POC库被删除,采集是报404问题 这个只能换成镜像库了,这里的话我推荐换成adysec的[POC镜像库](https://github.com/adysec/POC/),将`collectors/collector_poc.py`文件里的`wy876`为`adysec`,一共有两处地方,建议全局替换 ###### 关于采集阿里漏洞源时可能会出现405问题 如果是使用公有云的服务器采集阿里的漏洞源时,可能会出现405,不允许采集,这种情况只能采用代理的方式采集了,可以在`collectors/collector_ali.py`文件中添加代理信息 ```python # 使用代理IP池(注意选择高匿代理) proxies = { 'http': 'http://10.10.1.10:3128', 'https': 'http://10.10.1.10:1080', } requests.get('https://target.com', proxies=proxies) ``` ###### 关于日志记录问题 后台运行时无法准确看出是否有正常采集,这你推荐在`processing/filter.py`添加日志输出记录 ```python ... current_time = datetime.datetime.now() with open('/data/athena/athena.log', 'a') as f: print(f"{current_time}\tSelected severity vulnerabilities found: {selected_severity_num}", file=f) print(f"{current_time}\tSelected severity vulnerabilities found: {selected_severity_num}") ... ``` ###### 关于采集出错后跳出循环问题 增加`try...except...`防止`while`循环跳出 ```python ... try: vulnerabilities = gather_data() filter_high_risk_vuls(vulnerabilities) except Exception as e: with open('/data/athena/athena.log', 'a') as f: print(f"{current_time}\tError: {e}", file=f) ... ``` > 自己懒得修改的话也可以用我的,我已经将修改好的代码上传至Github,`https://github.com/genius-kim/Athena`,欢迎自取!!! #### 实时漏洞预警 > **注意:** 默认推送所有severity漏洞,如需更改请修改config.yaml中的severity_filter。  #### 数据可视化 在V2.0中,实现了数据的可视化,默认端口为5000。 > 在该项目中,后端由flask实现,在main.py中,通过run_flask_app来运行应用: ```python def run_flask_app(): app.run(debug=False) ``` 默认配置下,仅能本机访问,即`host = '127.0.0.1'`,若想进行远程访问,有如下几种方法: * 推荐通过nps等隧道工具实现,较为安全,但是需要配置隧道工具 * 修改`app.run(debug=False)`为`app.run(debug=False,host='0.0.0.0')`,修改后直接对所有主机开放,简单粗暴,但是存在一定安全风险,如有意外作者概不负责! * 保持host为127.0.0.1,自定义路由 前端展示共有3处路由:首页('/'或'/index'),漏洞总览('/vuls')和每日漏洞详情('/daily/[date]') ##### /index 首页有两部分,第一部分是漏洞的统计结果,有四张图表,分别统计了所有漏洞中,`CVE的占比`,`各种Severity漏洞的占比`,`各漏洞源漏洞的占比`以及`近7天来的漏洞数量变化趋势`,第二部分为最新的十条漏洞数据,为了更加美观,在图表中没有采取换行的方式,如有超长字段,会隐藏一部分,鼠标悬停即可查看完整内容,同样,单击右侧link即可跳转至漏洞POC或详情页。  ##### /vuls 该路由展示了全量的漏洞数据,右上方可选每页展示的漏洞条数,通过最下方页码即可跳转,搜索框中为模糊搜索,支持全字段,例如搜索name,cve,source,severity,date等等:  ##### /daily/date 通过输入%Y-%m-%d形式的日期,可查询指定日期的漏洞情况,以2025-07-01为例:`/daily/2025-07-01`,展示了当前日期CVE漏洞占比,各Severity和Source的漏洞占比,以及当天更新的所有漏洞信息。  最后修改:2025 年 07 月 02 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 1 -