forked from JMousqueton/ransomware.live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphgroup.py
82 lines (68 loc) · 2.96 KB
/
graphgroup.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
import json
import datetime
import matplotlib.pyplot as plt
def statsgroup(specific_group_name):
# Reset variables
victim_counts = {}
dates = []
counts = []
# Read posts.json and filter posts for the specific group name and start date
with open('posts.json', 'r') as posts_file:
posts_data = json.load(posts_file)
filtered_posts = [
post for post in posts_data
if post['group_name'] == specific_group_name
and datetime.datetime.strptime(post['published'], '%Y-%m-%d %H:%M:%S.%f') >= datetime.datetime(2022, 1, 1)
]
# Count the number of victims per day
for post in filtered_posts:
date = datetime.datetime.strptime(post['published'], '%Y-%m-%d %H:%M:%S.%f').date()
victim_counts[date] = victim_counts.get(date, 0) + 1
# Sort the victim counts by date
sorted_counts = sorted(victim_counts.items())
# Extract the dates and counts for plotting
dates, counts = zip(*sorted_counts)
start_date = datetime.datetime(2022, 1, 1).date()
# Plot the graph
plt.clf()
# Create a new figure and axes for each group with a larger figure size
fig,ax = plt.subplots(figsize=(10, 3)) # Adjust the width (10) and height (6) as desired
# plt.plot(dates, counts)
ax.bar(dates, counts, color = '#42b983')
ax.set_xlabel('Date\nRansomware.live', color = '#42b983')
ax.set_ylabel('Number of Victims', color = '#42b983')
ax.set_title('Number of Victims for Group: ' + specific_group_name, color = '#42b983')
ax.tick_params(axis='x', rotation=45)
# Set the x-axis limits
ax.set_xlim(start_date, datetime.datetime.now().date())
# Format y-axis ticks as whole numbers without a comma separator
plt.tight_layout()
# Save the graph as an image file
plt.savefig('docs/graphs/stats-' + specific_group_name + '.png')
plt.close(fig)
print(
'''
_______________ |*\_/*|________
| ___________ | ||_/-\_|______ |
| | | | | | | |
| | 0 0 | | | | 0 0 | |
| | - | | | | - | |
| | \___/ | | | | \___/ | |
| |___ ___| | | |___________| |
|_____|\_/|_____| |_______________|
_|__|/ \|_|_.............💔.............._|________|_
/ ********** \ / ********** \
/ ************ \ ransomwhat? / ************ \
-------------------- --------------------
'''
)
# Read groups.json and extract group names
with open('groups.json', 'r') as groups_file:
groups_data = json.load(groups_file)
group_names = [group['name'] for group in groups_data]
for group_name in group_names:
try:
statsgroup(group_name)
except:
print("no graph for " + group_name)
pass