├── .github └── workflows │ └── github_monitor.yml ├── README.md ├── monitor.py └── projects.txt /.github/workflows/github_monitor.yml: -------------------------------------------------------------------------------- 1 | name: Github Monitor Check repo changes 2 | 3 | on: 4 | schedule: 5 | - cron: '0 13 * * *' # 每天 UTC 时间 0:00 执行一次 6 | workflow_dispatch: 7 | 8 | env: 9 | TZ: Asia/Shanghai 10 | 11 | jobs: 12 | github_monitor: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout Code 16 | uses: actions/checkout@v2 17 | 18 | - name: Setup Python 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: '3.8' # 记得修改 python 版本 22 | - name: Install Dependency 23 | run: | 24 | python -m pip install --upgrade pip 25 | pip install requests 26 | 27 | - name: Check Repo Changes 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.TOKEN }} 30 | FROM_ADDR: ${{ secrets.FROM_ADDR }} 31 | SMTP_PORT: ${{ secrets.SMTP_PORT }} 32 | SMTP_SERVER: ${{ secrets.SMTP_SERVER }} 33 | EMAIL_PASSWORD: ${{ secrets.PASSWORD }} 34 | TO_ADDR: ${{ secrets.TO_ADDR }} 35 | 36 | run: | 37 | python monitor.py 38 | echo "The timezone is $TZ" 39 | date 40 | 41 | 42 | # run: | 43 | # python main.py 44 | 45 | # - name: Run Script 46 | # env: 47 | # TEXT: ${{ steps.check_changes.outputs.text }} 48 | # SMTP_SERVER: ${{ secrets.SMTP_SERVER }} 49 | # EMAIL_FROM: ${{ secrets.EMAIL_FROM }} 50 | # EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} 51 | # EMAIL_TO: ${{ secrets.EMAIL_TO }} 52 | # if: ${{ steps.check_changes.outputs.email_needed == 'True' }} 53 | # run: | 54 | # echo "$TEXT" | mailx -v -r $EMAIL_FROM -s "Github project file changes" -S smtp=$SMTP_SERVER -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user=$EMAIL_FROM -S smtp-auth-password=$EMAIL_PASSWORD $EMAIL_TO 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # github_monitor 2 | github 指定项目更新监控推送 3 | 如果有推荐的项目可以加进来 4 | -------------------------------------------------------------------------------- /monitor.py: -------------------------------------------------------------------------------- 1 | import os 2 | from email.mime.multipart import MIMEMultipart 3 | import requests 4 | import datetime 5 | import smtplib 6 | from email.mime.text import MIMEText 7 | from email.header import Header 8 | 9 | 10 | def get_repo_file_changes(file_name, token): 11 | result = {} 12 | yesterday = datetime.datetime.now() - datetime.timedelta(1) 13 | yesterday = yesterday.replace(hour=0, minute=0, second=0, microsecond=0) 14 | yesterday_unix_time = int(yesterday.timestamp()) 15 | 16 | with open(file_name, 'r') as f: 17 | repos = f.readlines() 18 | for repo in repos: 19 | if repo.strip() and repo.startswith('#') is False: 20 | owner, name = repo.strip().split('/') 21 | url = f"https://api.github.com/repos/{owner}/{name}/branches" 22 | headers = {'Authorization': f'token {token}'} 23 | r = requests.get(url, headers=headers) 24 | branches_data = r.json() 25 | 26 | for branch_data in branches_data: 27 | branch_name = branch_data['name'] 28 | last_commit_url = f"https://api.github.com/repos/{owner}/{name}/branches/{branch_name}" 29 | r = requests.get(last_commit_url, headers=headers) 30 | last_commit = r.json()['commit'] 31 | 32 | # 修改这里获取时间戳的方式 33 | last_commit_time_str = last_commit['commit']['committer']['date'] 34 | last_commit_time = datetime.datetime.strptime(last_commit_time_str, '%Y-%m-%dT%H:%M:%SZ') 35 | last_commit_unix_time = int(last_commit_time.timestamp()) 36 | # print(last_commit_time_str,last_commit_time,last_commit_unix_time) 37 | # 2023-03-08T06:15:55Z 2023-03-08 06:15:55 1678227355 38 | # 2023-02-02T05:31:34Z 2023-02-02 05:31:34 1675287094 39 | if last_commit_unix_time >= yesterday_unix_time: 40 | last_commit_sha = last_commit['sha'] 41 | # https://api.github.com/repos/xx/xx/commits/e06b4b05e19e95dcf845a4e5499711e210ffdb52 42 | commit_url = f"https://api.github.com/repos/{owner}/{name}/commits/{last_commit_sha}" 43 | r = requests.get(commit_url, headers=headers) 44 | commit_data = r.json() 45 | file_changes = commit_data['files'] 46 | # print(file_changes) 47 | for file_change in file_changes: 48 | result.setdefault(f"{owner}/{name}/tree/{branch_name}", []).append( 49 | file_change['filename'] + '\t' + file_change['status']) 50 | # 设置字典键和值 51 | # print(result) 52 | return result 53 | 54 | 55 | def send_email(subject, to_addr, text, smtp_server, smtp_port, from_addr, password): 56 | # msg = MIMEText(text, 'plain', 'utf-8') 57 | msg = MIMEMultipart() 58 | html = MIMEText(text, "html") 59 | msg.attach(html) 60 | msg['Subject'] = Header(subject, 'utf-8') 61 | msg['From'] = Header(from_addr) 62 | msg['To'] = to_addr 63 | 64 | smtp_server = smtplib.SMTP(smtp_server, int(smtp_port)) 65 | smtp_server.starttls() 66 | smtp_server.login(from_addr, password) 67 | smtp_server.sendmail(from_addr, [to_addr], msg.as_string()) 68 | smtp_server.quit() 69 | 70 | 71 | if __name__ == '__main__': 72 | file_name = 'projects.txt' 73 | # token = '{{ secrets.token }}' 74 | # # 修改为您要使用的邮箱地址和SMTP服务器信息,以及您的邮箱密码 75 | # smtp_server = '{{ secrets.smtp_server }}' 76 | # smtp_port = '{{ secrets.smtp_port }}' 77 | # from_addr = '{{ secrets.from_addr }}' 78 | # password = '{{ secrets.password }}' 79 | # to_addr = '{{ secrets.to_addr }}' 80 | token = os.getenv('GITHUB_TOKEN') 81 | smtp_server = os.getenv('SMTP_SERVER') 82 | smtp_port = os.getenv('SMTP_PORT') 83 | from_addr = os.getenv('FROM_ADDR') 84 | password = os.getenv('EMAIL_PASSWORD') 85 | to_addr = os.getenv('TO_ADDR') 86 | 87 | file_changes = get_repo_file_changes(file_name, token) 88 | # print(file_changes) 89 | text = '' 90 | for repo, changes in file_changes.items(): 91 | # repo = komomon/komo/tree/beta 92 | branch_link = f'

{repo}有以下文件更新:

' 93 | text += f"{branch_link}" 94 | for change in changes: 95 | text += f"{change}
" 96 | print(text) 97 | # exit() 98 | if text.strip() == '': 99 | print("No changes detected.") 100 | else: 101 | send_email('Github monitor project file changes', to_addr, text, smtp_server, smtp_port, from_addr, password) 102 | print("Email sent.") 103 | -------------------------------------------------------------------------------- /projects.txt: -------------------------------------------------------------------------------- 1 | ExpLangcn/NucleiTP 2 | AYcg/poc 3 | wwl012345/Vuln-List 4 | cckuailong/reapoc 5 | nomi-sec/PoC-in-GitHub 6 | ycdxsb/PocOrExp_in_Github 7 | helloexp/0day 8 | trickest/cve 9 | luck-ying/Library-POC 10 | hktalent/TOP 11 | ybdt/evasion-hub 12 | UltimateSec/ultimaste-nuclei-templates 13 | coffeehb/Some-PoC-oR-ExP 14 | #MzzdToT/HAC_Bored_Writing 15 | gobysec/GobyVuls 16 | #20142995/pocsuite 17 | #20142995/sectool 18 | 20142995/pocsuite3 19 | novysodope/fupo_for_yonyou 20 | wgpsec/YongYouNcTool 21 | Awrrays/FrameVul 22 | MD-SEC/MDPOCS 23 | lal0ne/vulnerability 24 | Threekiii/Awesome-POC 25 | Threekiii/Vulnerability-Wiki 26 | MeowwBox/pxplan 27 | Y1-K1NG/poc_exp 28 | jiankeguyue/VulnerabilityReport 29 | --------------------------------------------------------------------------------