mirror of https://github.com/Aidaho12/haproxy-wi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.0 KiB
56 lines
2.0 KiB
#!/usr/bin/env python3 |
|
import funct |
|
import sql |
|
from jinja2 import Environment, FileSystemLoader |
|
|
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True) |
|
template = env.get_template('portscanner.html') |
|
form = funct.form |
|
serv = form.getvalue('history') |
|
|
|
print('Content-type: text/html\n') |
|
funct.check_login() |
|
|
|
try: |
|
user, user_id, role, token, servers = funct.get_users_params(virt=1) |
|
except Exception as e: |
|
print(str(e)) |
|
|
|
if serv: |
|
title = 'Port scanner history for ' + serv |
|
port_scanner_settings = sql.select_port_scanner_history(serv) |
|
history = '1' |
|
port_scanner = '' |
|
port_scanner_stderr = '' |
|
count_ports = '' |
|
else: |
|
history = '' |
|
title = 'Port scanner dashboard' |
|
user_group = funct.get_user_group(id=1) |
|
port_scanner_settings = sql.select_port_scanner_settings(user_group) |
|
if not port_scanner_settings: |
|
port_scanner_settings = '' |
|
count_ports = '' |
|
else: |
|
count_ports = list() |
|
for s in servers: |
|
count_ports_from_sql = sql.select_count_opened_ports(s[2]) |
|
i = (s[2], count_ports_from_sql) |
|
count_ports.append(i) |
|
|
|
cmd = "systemctl status portscanner |grep Act |awk '{print $2}'" |
|
port_scanner, port_scanner_stderr = funct.subprocess_execute(cmd) |
|
|
|
|
|
output_from_parsed_template = template.render(h2=1, autorefresh=0, |
|
title=title, |
|
role=role, |
|
user=user, |
|
servers=servers, |
|
port_scanner_settings=port_scanner_settings, |
|
count_ports=count_ports, |
|
history=history, |
|
port_scanner=''.join(port_scanner), |
|
port_scanner_stderr=port_scanner_stderr, |
|
token=token) |
|
print(output_from_parsed_template)
|
|
|