-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSNews_Alert.py
235 lines (173 loc) · 6.55 KB
/
CSNews_Alert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/usr/bin/python3
'''
CSNEWS stands for CyberSecurity News !!
Stay in alert with CSNews !
Check News from several websites in one instance.
By N0vachr0n0
Github: https://github.com/N0vachr0n0
'''
from bs4 import BeautifulSoup
from tkinter import *
from tkinter import ttk
from tkinter.ttk import *
from datetime import datetime, date, timedelta
from tkinter.messagebox import *
from threading import Thread
import webbrowser
import requests
import time
sites = ["https://cyberguerre.numerama.com/feed/", "https://feeds.feedburner.com/TheHackersNews?format=xml",
"https://rss.packetstormsecurity.com/news/", "https://www.zdnet.fr/blogs/cybervigilance/rss/",
"https://www.zataz.com/rss/zataz-news.rss", "https://portswigger.net/daily-swig/rss",
"https://threatpost.com/feed"]
# title_list[0] and link_list[0] correspond to the title and the website of article
title_list_today = []
link_list_today = []
title_list_yest = []
link_list_yest = []
title_list_old = []
link_list_old = []
root = Tk()
root.title("CyberSecurity News")
root.geometry('650x450')
root.resizable(0, 0) # Block resizing of window
root.config(cursor="pirate")
win_loading = Tk()
win_loading.geometry('250x100')
win_loading.title("Loading...")
msg = Label(win_loading, text="WAIT PLEASE")
# Progress bar widget
progress = Progressbar(win_loading, orient=HORIZONTAL,
length=100, mode='determinate')
tabControl = ttk.Notebook(root)
tab1 = ttk.Frame(tabControl)
tab2 = ttk.Frame(tabControl)
tab3 = ttk.Frame(tabControl)
tab4 = ttk.Frame(tabControl)
tabControl.add(tab1, text='HOT')
tabControl.add(tab2, text='RECENT')
tabControl.add(tab3, text='OLD')
tabControl.add(tab4, text='CREDIT')
tabControl.pack(expand=1, fill="both")
scrollbar = Scrollbar(tab1)
scrollbar_re = Scrollbar(tab2)
scrollbar_old = Scrollbar(tab3)
scrollbar.pack(side=RIGHT, fill=Y)
scrollbar_re.pack(side=RIGHT, fill=Y)
scrollbar_old.pack(side=RIGHT, fill=Y)
article_hot = Listbox(tab1, selectbackground="pink", width=80, yscrollcommand=scrollbar.set)
article_recent = Listbox(tab2, selectbackground="pink", width=80, yscrollcommand=scrollbar_re.set)
article_old = Listbox(tab3, selectbackground="pink", width=80, yscrollcommand=scrollbar_old.set)
credit = "CyberSecurity News\n\nMade by N0vachr0n0\nThanks for downloading,\
please share ;)\n\nGithub: https://github.com/N0vachr0n0"
Label(tab4, text=credit, justify="center").grid(padx=180, pady=110)
# Function responsible for the updation
# of the progress bar value
def bar():
progress['value'] = 20
win_loading.update_idletasks()
time.sleep(0.5)
progress['value'] = 40
win_loading.update_idletasks()
time.sleep(0.5)
progress['value'] = 50
win_loading.update_idletasks()
time.sleep(0.5)
progress['value'] = 60
win_loading.update_idletasks()
time.sleep(0.5)
progress['value'] = 80
win_loading.update_idletasks()
time.sleep(0.5)
progress['value'] = 100
win_loading.update_idletasks()
time.sleep(0.5)
# Look for title and link of articles in a XML doc
def cooking(url):
try:
response = requests.get(url)
except:
showerror(title="CONNECTION ERROR", message="Please check your internet connection and try again.")
showinfo(title="CREDIT", message="Made by N0vachr0n0\nGoodbye Friend ;) ")
root.destroy()
soup = BeautifulSoup(response.content, "xml")
for item in soup.find_all("item"):
pubdate = item.find("pubDate")
pubdate = int((str(pubdate.text))[5:7])
# print(pubdate)
if pubdate == (datetime.now()).day:
title = item.find("title")
link = item.find("link")
title_list_today.append(">_ " + title.text)
link_list_today.append(link.text)
elif pubdate == (date.today()-timedelta(1)).day:
title = item.find("title")
link = item.find("link")
title_list_yest.append(">_ " + title.text)
link_list_yest.append(link.text)
else:
title = item.find("title")
link = item.find("link")
title_list_old.append(">_ " + title.text)
link_list_old.append(link.text)
# Retrieves index of article title from listbox and go to website
def go_recent(event):
cs = article_recent.curselection()
for pos in cs:
webbrowser.open(link_list_yest[pos])
def go_hot(event):
cs = article_hot.curselection()
for pos in cs:
webbrowser.open(link_list_today[pos])
def go_old(event):
cs = article_old.curselection()
for pos in cs:
webbrowser.open(link_list_old[pos])
# Actualization (look for new articles and insert into the lists)
def refresh():
showinfo(title="REFRESHING...", message="We are looking for News ;) ")
root.config(cursor="watch")
title_list_old.clear()
link_list_old.clear()
title_list_today.clear()
link_list_today.clear()
title_list_yest.clear()
link_list_yest.clear()
article_old.delete(0, END)
article_hot.delete(0, END)
article_recent.delete(0, END)
for i in range(len(sites)):
cooking(sites[i])
# Insertion in listbox
for x in range(len(title_list_today)):
article_hot.insert(END, title_list_today[x])
for x in range(len(title_list_yest)):
article_recent.insert(END, title_list_yest[x])
for x in range(len(title_list_old)):
article_old.insert(END, title_list_old[x])
article_old.pack(expand=1, side=LEFT, fill=BOTH)
article_hot.pack(expand=1, side=LEFT, fill=BOTH)
article_recent.pack(expand=1, side=LEFT, fill=BOTH)
root.config(cursor="pirate")
showinfo(title=INFO, message="DOUBLE-CLICK OR PRESS ENTER ON A TITLE TO OPEN WEBSITE XD")
if __name__ == '__main__':
root.withdraw() # Hide root window ;)
msg.pack(padx=10, pady=10)
progress.pack(pady=10)
bar()
win_loading.destroy()
control_thread = Thread(target=refresh, daemon=True) # Start Refresh function in parallel
control_thread.start()
root.deiconify() # Show root window
Button(root, text='REFRESH', command=refresh).pack(side=BOTTOM, padx=5, pady=5)
# Waiting for Double-click or Key ENTER to go on the website
article_hot.bind("<Double-1>", go_hot)
article_hot.bind("<Return>", go_hot)
article_recent.bind("<Double-1>", go_recent)
article_recent.bind("<Return>", go_recent)
article_old.bind("<Double-1>", go_old)
article_old.bind("<Return>", go_old)
scrollbar.config(command=article_hot.yview)
scrollbar_re.config(command=article_recent.yview)
scrollbar_old.config(command=article_old.yview)
mainloop()