-
Notifications
You must be signed in to change notification settings - Fork 6
/
getposts.py
37 lines (31 loc) · 1.01 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
import requests
from jinja2 import Environment, FileSystemLoader, select_autoescape
from datetime import datetime as dt
from datetime import timezone
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=dt.now(tz=timezone.utc).strftime('%d-%b-%Y %H:%M %Z')))