Code Monkey home page Code Monkey logo

cve-daily-push's Introduction

CVE-Daily-Push

你只要有个qq邮箱、有个Github账号,就可以实现的零(经济)成本CVE每日推送

更新记录

Time Action Description
2024.03.07 feat 修改了接口请求重试的逻辑,之前的重试没有生效;优化了一点ui
2024.02.22 feat 增加了异常捕获和空值检查
2024.02.17 feat Merge pr from yaojieno1:smtp现在支持非ssl的server了
2024.02.17 fix 修复了cvssMetricV2下的bug
2024.01.14 feat 新增概览,优化了ui
2024.01.11 fix 修复没有详情导致的bug
2024.01.11 feat 新增对cvss评分规则的判断
增加请求最大重试次数
2024.01.08 feat 新增对没有任何更新的判断
2024.01.08 fix 修复api次数限制导致的bug
修复传参json格式字符串导致的bug
修复mail.yml的空格导致取值的bug

0x00 项目简介

实现:

  • Python
  • Github Actions

一句话概括

  • 通过Github Actions设置定时任务,每天自动运行一次python脚本爬取CVE新增、更新及其CVSS评分、详情等信息,并通过你自己的QQ邮箱发送邮件到任意你想发送到邮箱

为什么这么设计?

  • 没钱订阅服务...没钱买vps...
  • 看了下很多项目都是放在自己的vps上(简单的功能白嫖Github的不香吗),通过企微、钉钉、飞书等bot推送,还得搞个对应的账号贼麻烦,不如用现成的(总不至于没qq吧...)
  • 没有第一时间获得新增CVE的需求(如果在某个CVE一出现就推送,刚好撞上在开会、手头在忙、或者大半夜...很容易忽略,后面也会忘记翻出来看)
  • 工作后基本都会看邮箱,所以本项目定位就是在每天早上发一封邮件,概括昨日新增和更新的CVE信息(其实大多数扫一眼就够了)

邮件效果图:

0x01 准备

首先你需要三个东西(均免费获取):

  • QQ邮箱授权码
  • NIST API KEY
  • Github API Token(非必须,仅测试需要)

QQ邮箱授权码:

用于使用QQ邮箱的SMTP、IMAP等邮件服务

在qq邮箱=>设置=>账号处获得

最后记得勾选上”SMTP发信后保存到服务器“,这样你通过代码发送的邮件才可以在“已发送”中查看,不然查不到你发了什么

NIST API KEY:

用于请求NIST的API,方便获取漏洞详情,有API KEY的话,每30秒能发起50个请求,否则只能发起5个请求

https://nvd.nist.gov/developers/request-an-api-key

信息随便填,提交后在邮件中查看就行了

Github API Token:

用于手动触发workflows,不然可能不知道他管不管用,仅测试时需要

步骤:

  1. 点头像 => Settings => Developer settings => Personal access tokens => Fine-grained tokens 或直接打开https://github.com/settings/tokens?type=beta ,Generate new token

  2. Token name随便填,Expiration是到期时间,Repository access选Only select repositories,然后选择你workflow的那个仓库

  3. 根据官方文档,Permissions只需要以下两个

    官方文档描述:

    • GitHub Apps with both metadata:read and contents:read&write permissions.

    token

    然后Generate token就可以了

0x02 使用

  1. fork本项目

  2. 在仓库 => Settings => Security => Secret and variables => Actions,或者fork后打开https://github.com/{your_name}/CVE-Daily-Push/settings/secrets/actions,设置Repository secrets=>New repository secret

  3. 新建MAIL_CONFIG如下:

    {
      "smtp": {
        "domain": "smtp.qq.com",
        "port": 465,
        "ssl": 1
      },
      "sender": {
        "mail": "[email protected]",
        "authCode": "xxxxx"
      },
      "receivers": [
        "[email protected]",
        "[email protected]"
      ]
    }

    sender表示发件的邮箱,authCode为qq邮箱获得的授权码,receivers为收件人列表,在smtp中的ssl字段表示smtp server是否使用了ssl,1为是0为否

    注意需要把json格式压缩为一行,不然会导致命令行识别出错

  4. 新建NIST_API_KEY为你前面获取的nist api key

image-

其他的什么都不用做,他会在每天早上8点多给你发一封邮件

若需要测试功能是否能在actions正常跑通,可以运行以下代码:

import requests
import json

header = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "Accept": "application/vnd.github+json",
    "Authorization": "Bearer github_pat_xxxx",
    "X-GitHub-Api-Version": "2022-11-28"
}
body = {
    "event_type": "Test_Dispatch"
}

url_ = "https://api.github.com/repos/vvmdx/CVE-Daily-Push/dispatches"
json_body = json.dumps(body)

resp = requests.post(url_, headers=header, data=json_body, verify=False)

print(resp.status_code)

event_type是workflow文件中repository_dispatch指定的值,可以自己改

请求头的Authorization是前面提到的Github Api Token,然后url改成自己的,就可以测试了

返回204即代表触发成功(但不一定运行成功)

0x03 TODO

  • 加入翻译模块
  • 加入筛选功能(CVSS评分)
  • 简易NER抽取受影响组件/框架/系统等
  • 多爬几个cert或者漏洞详情网站
  • ...

cve-daily-push's People

Contributors

vvmdx avatar yaojieno1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.