-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetposts.py
38 lines (32 loc) · 1.04 KB
/
getposts.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
import requests
from jinja2 import Environment, FileSystemLoader, select_autoescape
# from datetime import datetime as dt
# from datetime import timezone
from datetime import datetime
import json
env = Environment(
loader=FileSystemLoader( searchpath="./templates" ),
autoescape=select_autoescape()
)
url = "https://ransomwhat.telemetry.ltd/groups"
r = requests.get(url)
groups_raw = r.json()
groups ={}
for group in groups_raw:
groups[group['name']] = None
for location in group['locations']:
if location['available']:
groups[group['name']] = location['fqdn']
break
url = "https://ransomwhat.telemetry.ltd/posts"
r = requests.get(url)
template = env.get_template("temp1.html")
ransoms = r.json()
ransoms.reverse()
for ransom in ransoms:
try:
ransom['group_fqdn'] = groups[ransom['group_name']]
except KeyError:
ransom['group_fqdn'] = None
with open('./index.html','w') as f:
f.write(template.render(ransoms=ransoms,fecha=datetime.now().strftime('%d-%b-%Y %H:%M %Z')))