report_attacks

This commit is contained in:
n.diaz
2024-11-25 19:40:09 +01:00
parent ea685a8b09
commit 86c4366724

21
waf3.py
View File

@ -62,6 +62,27 @@ class Attack(peewee.Model):
Attack.create_table(True)
# Utils
def report_attacks():
click.echo(
click.style(
f"Attacks in database: {Attack.select().count()}",
fg="cyan"
)
)
hosts = {}
for a in Attack.select():
# print(a.host)
if a.host in hosts:
hosts[a.host] = hosts[a.host] + 1
else:
hosts[a.host] = 1
sorted_hosts = dict(sorted(hosts.items(), key=lambda x:x[1]))
for h, v in sorted_hosts.items():
print(h, v)
def report():
click.echo(
click.style(