→ Applies to: SynetoOS 4.x
Step 1. Connect to SynetoOS appliance via SSH as admin
ssh admin@<your_ip_address_or_hostname>
Step 2. Remove bash_profile
rm ~admin/.bash_profile
After running the command, you need to perform logout and login again.
Step 3. Become Super User
sudo su
Step 4. Create an empty file
touch /tmp/test.py
Step 5. Assigning permissions
chmod +x /tmp/test.py
Step 6. Open the file previously created
vi /tmp/test.py
Step 7. Paste the following code within the file and save it
import socket
import sys
# Definizione dei colori per la barra di progresso e gli stati delle porte
COLOR_GREEN = "\033[92m"
COLOR_RED = "\033[91m"
COLOR_YELLOW = "\033[93m"
COLOR_END = "\033[0m"
# Definizione degli indirizzi da testare e delle porte corrispondenti
addresses_ports = {
'syneto.eu': [22, 80, 443],
'central.syneto.eu': [80, 443],
'central.api.syneto.eu': [80, 443],
'files.syneto.eu': [22, 80, 443],
'stc-0.syneto.eu': [22],
'stc-1.syneto.eu': [22],
'stc-2.syneto.eu': [22],
'stc-3.syneto.eu': [22],
'stc-4.syneto.eu': [22],
'stc-5.syneto.eu': [22],
'stc-6.syneto.eu': [22],
'stc-7.syneto.eu': [22],
'proxy.t.syneto.eu': [443],
'pkg.syneto.eu': [80],
}
# Numero massimo di tentativi per ciascuna porta
max_attempts = 2
# Timeout della connessione in secondi
timeout = 3
# Funzione per stampare la barra di progresso
def print_progress(current, total):
progress = current / total
bar_length = 50
block = int(round(bar_length * progress))
progress_bar = "[" + COLOR_GREEN + "#" * block + COLOR_YELLOW + "-" * (bar_length - block) + COLOR_END + "]"
sys.stdout.write("\rTesting progress: {}/{} addresses | {}".format(current, total, progress_bar))
sys.stdout.flush()
# Esecuzione del test per ciascun indirizzo e porta
total_addresses = len(addresses_ports)
current_address = 0
total_opened_ports = 0
results = {}
for address, ports in addresses_ports.items():
current_address += 1
current_port = 0
print_progress(current_address, total_addresses)
results[address] = {}
for port in ports:
current_port += 1
results[address][port] = False
for attempt in range(1, max_attempts + 1):
try:
# Creazione del socket e tentativo di connessione
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(timeout)
result = s.connect_ex((address, port))
if result == 0:
results[address][port] = True
total_opened_ports += 1
break # Se la porta è aperta, non c'è bisogno di continuare il tentativo
except Exception as e:
pass
finally:
s.close()
# Stampa completamento del test e riassunto dei risultati
print("\nTesting completed.\n")
for address, ports in results.items():
print("Results for address:", address)
for port in addresses_ports[address]:
if port in ports:
if ports[port]:
print("Port", port, "is open", COLOR_GREEN + "✓" + COLOR_END)
else:
print("Port", port, "is closed", COLOR_RED + "✗" + COLOR_END)
else:
print("Port", port, "was not tested")
print()
# Stampa del numero totale di porte aperte
total_tested_ports = sum(len(ports) for ports in addresses_ports.values())
print("Total opened ports:", total_opened_ports, "/", total_tested_ports)
Step 8. Execute the script
python3 /tmp/test.py
Example output: