From 9e9f5ec9544f7924c7f44eee07fe825db65c3fa4 Mon Sep 17 00:00:00 2001
From: MasonLiu <2857911564@qq.com>
Date: Thu, 5 Dec 2024 21:25:31 +0800
Subject: [PATCH] update
---
Core.py | 16 ++-
GotoSend_seebug.py | 134 ++++++++++++++++++++
README.md | 9 ++
__pycache__/GotoSend_seebug.cpython-312.pyc | Bin 0 -> 5499 bytes
db/seebug.db | Bin 0 -> 20480 bytes
test.py | 9 ++
6 files changed, 167 insertions(+), 1 deletion(-)
create mode 100644 GotoSend_seebug.py
create mode 100644 __pycache__/GotoSend_seebug.cpython-312.pyc
create mode 100644 db/seebug.db
create mode 100644 test.py
diff --git a/Core.py b/Core.py
index c00bca8..5078280 100644
--- a/Core.py
+++ b/Core.py
@@ -14,6 +14,7 @@ from GotoSend_doonsec import Src_doonsec
from GotoSend_xianzhi import Src_xianzhi
from GotoSend_freebuf import Src_freebuf
from GotoSend_qianxin import Src_qianxin
+from GotoSend_seebug import Src_seebug
# 加载参数
with open('./config.yaml', 'r', encoding="utf-8") as file:
@@ -36,6 +37,7 @@ def send_job(time_1):
reslt_xianzhi = Src_xianzhi(time_1)
reslt_freebuf = Src_freebuf(time_1)
reslt_qianxin = Src_qianxin(time_1)
+ reslt_seebug = Src_seebug(time_1)
webhook_url, timestamp, sign = gen_sign()
@@ -106,6 +108,18 @@ def send_job(time_1):
print("-" * 40)
print("奇安信攻防社区数据为空,跳过执行。")
+ # 发送Seebug资讯
+ if reslt_seebug:
+ reslt_seebug = Src_seebug(1000)
+ webhook_url, timestamp, sign = gen_sign()
+ print("-" * 40)
+ print("Seebug社区资讯递送中:")
+ SendToFeishu(reslt_seebug, "Seebug社区资讯递送", webhook_url, timestamp, sign)
+ print("-" * 40 + "\n")
+ else:
+ print("-" * 40)
+ print("Seebug社区数据为空,跳过执行。")
+
def signal_handler(sig, frame):
print("接收到退出信号,程序即将退出...")
sys.exit(0)
@@ -150,7 +164,7 @@ def test_rss_source():
# "安全维基": "https://www.sec_wiki.com/news/rss",
"安全客": "https://api.anquanke.com/data/v1/rss",
"嘶吼": "https://www.4hou.com/feed",
- # "Seebug社区": "https://paper.seebug.org/rss/",
+ "Seebug社区": "https://paper.seebug.org/rss/",
"FreeBuf社区": "https://www.freebuf.com/feed",
"先知社区": "https://xz.aliyun.com/feed"
}
diff --git a/GotoSend_seebug.py b/GotoSend_seebug.py
new file mode 100644
index 0000000..2551f93
--- /dev/null
+++ b/GotoSend_seebug.py
@@ -0,0 +1,134 @@
+import json
+import sqlite3
+import os
+from datetime import datetime, timedelta
+from SendBot import SendToFeishu
+import email.utils
+
+
+def create_database():
+ conn = sqlite3.connect('./db/seebug.db')
+ cursor = conn.cursor()
+ cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ title TEXT,
+ link TEXT,
+ category TEXT,
+ description TEXT,
+ pubDate DATETIME
+ )''')
+ conn.commit()
+ conn.close()
+
+
+def insert_data(data):
+ conn = sqlite3.connect('./db/seebug.db')
+ cursor = conn.cursor()
+ for entry in data:
+ # 解析并格式化时间
+ parsed_date = email.utils.parsedate_to_datetime(entry['pubDate'])
+ formatted_date = parsed_date.strftime('%Y-%m-%d %H:%M:%S')
+
+ cursor.execute('''
+ INSERT INTO articles (title, link, category, description, pubDate)
+ VALUES (?, ?, ?, ?, ?)
+ ''', (entry['title'], entry['link'], entry['category'], entry['description'], formatted_date))
+ conn.commit()
+ conn.close()
+
+def get_seebug_json():
+ # 检查文件是否存在
+ if not os.path.exists('./JSON/seebug.json'):
+ raise FileNotFoundError(f"seebug.json文件不存在,请检查程序是否运行正常!")
+
+ # 打开并读取JSON文件
+ with open('./JSON/seebug.json', 'r', encoding='utf-8') as file:
+ data = json.load(file)
+
+ # 假设data是一个包含多个JSON对象的列表
+ if not isinstance(data, list):
+ raise ValueError("JSON文件格式错误,请检查common.py是否异常!")
+
+ # 提取所需字段并编号
+ total_data = []
+ for index, item in enumerate(data, start=1):
+ entry = {
+ "id": index,
+ "title": item.get("title", ""),
+ "link": item.get("link", ""),
+ "description": item.get("description", ""),
+ "pubDate": item.get("pubDate", ""),
+ "category": item.get("category", "")
+ }
+ total_data.append(entry)
+
+ return total_data
+
+def select_articles(e_hour):
+ conn = sqlite3.connect('./db/seebug.db')
+ cursor = conn.cursor()
+
+ # 获取当前日期和时间
+ now = datetime.now()
+ start_time = now - timedelta(hours=e_hour)
+ end_time = now
+
+ # 查询指定时间段内的数据
+ cursor.execute('''
+ SELECT * FROM articles
+ WHERE pubDate BETWEEN ? AND ?
+ ''', (start_time.strftime('%Y-%m-%d %H:%M:%S'), end_time.strftime('%Y-%m-%d %H:%M:%S')))
+
+ results = cursor.fetchall()
+ conn.close()
+ return results
+
+def clear_table():
+ conn = sqlite3.connect('./db/seebug.db')
+ cursor = conn.cursor()
+ cursor.execute('DELETE FROM articles')
+ conn.commit()
+ conn.close()
+
+def get_filtered_articles(entries):
+ result = ""
+ for entry in entries:
+ result += f"类型:{entry[3]}\t文章:{entry[1]}"
+ result += f"链接:{entry[2]}\t上传时间:{entry[5]}\n"
+ result += f"{entry[4]}\n"
+ result += "-" * 40 + "\n" # 添加分隔线以便区分不同文章
+ return result
+
+
+def Src_seebug(e_hour):
+ if not os.path.exists('./db/seebug.db'):
+ # 创建数据库和表
+ create_database()
+
+ # 清空表
+ clear_table()
+
+ # 获取 JSON 数据
+ M_seebug_data = get_seebug_json()
+
+ # 插入数据到数据库
+ insert_data(M_seebug_data)
+
+ # 查询指定时间段内的数据
+ filtered_articles = select_articles(e_hour)
+ # print(filtered_articles)
+
+ if filtered_articles:
+ results = get_filtered_articles(filtered_articles)
+ return results
+ else:
+ return False
+
+if __name__ == "__main__":
+ reslts = Src_seebug(100)
+ if reslts != False:
+ print(reslts)
+ else:
+ # 如果为空,则跳过执行
+ print("-" * 40)
+ print("Seebug社区数据为空,跳过执行。")
diff --git a/README.md b/README.md
index dd8b20b..6384510 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,15 @@ RSS订阅链接来源:https://github.com/zhengjim/Chinese-Security-RSS
使用python-json进行格式化,然后使用飞书webhook机器人进行发送
config.yaml可指定大部分可能需要的参数
+### 使用建议:
+Linux系统建议下载screen于后台持续运行本脚本。
+debian/ubuntu/kali: `apt install screen`
+centos: `yum install screen`
+创建新会话:`screen -S 会话名称`
+保存并退回到界面:`ctrl+a+d`
+重新进入会话:`screen -r 会话名称`
+结束对话:进入会话后输入`exit`
+
### 使用方法:
先下载支持库:`pip install -r requirements.txt`
随后便可直接运行:`python Core.py`
diff --git a/__pycache__/GotoSend_seebug.cpython-312.pyc b/__pycache__/GotoSend_seebug.cpython-312.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..4226ff85b06cc84cd9ff6f670ba822fc7ea59c6a
GIT binary patch
literal 5499
zcmdT|U2qfE6}~HJrIln!NdAWgHY6^VW1IX@sFOmCEn^cb5?c^(U^GIzHZro-*CrPtQEe`n9Vd++(q&;Hfnun{O92+wqURBI4Vlow3=$8
z)V`t30JR}%>@v0)yG(5+3g?Ycy35>VR@+q6(#CM66Qs?`(LimS8K|AJ0L|kVpbpLo
z)XCX^y7*O`{YW_>;syiZU0mLIO4~)7n|E`LBb#By3Ns$wt4#&gVx*El!z~7B=Aj3q?
zZiw%o>M
zON3*a`~lw%Ukm$mOH*@g%YODL-+s1sPhfYGA4E0#{DI0Gw;Yk9JR9)sTQU}n#E#rC
z6oyOa5X7E4hB;mei;-?QBE;^P>5d<&hiBM&*mIw
ztLg-fKk#(Vc0oR{Ly!ejjbQftx_cB?Sma?VK~SX7p^(Ij9*}|eB-H{*lB;&l;I@Hn
zsWlI!?Ul*;jKe+n+`x0E4kjBiCfiB>G58AZpl38fZw6dU9|dA$>;KjH_blWVCuI?YxVYC5)V*
z6qs~v?K34zosOkXX>HD!K74yiY2RBx7=m>tIE2n$~d;Hv8JrKrmVI1#hhLv7@GX8
zzLo%@VfPZCs2X3%qLNp#x?WeZOH{d%%`V}+P2AqvU3+}3Z27iIcJY6aMWI#6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gen_sign
+from GotoSend_seebug import Src_seebug
+
+reslt_seebug = Src_seebug(1000)
+webhook_url, timestamp, sign = gen_sign()
+print("-" * 40)
+print("Seebug社区资讯递送中:")
+SendToFeishu(reslt_seebug, "Seebug社区资讯递送", webhook_url, timestamp, sign)
+print("-" * 40 + "\n")
\ No newline at end of file