-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBLACKOUT.py
More file actions
85 lines (69 loc) · 2.71 KB
/
BLACKOUT.py
File metadata and controls
85 lines (69 loc) · 2.71 KB
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
83
84
85
#!/usr/bin/env python3
import socket
import requests
# Define a cor vermelha.
RED = '\033[91m'
# Define a cor preta.
BLACK = '\033[0m'
# Exibe o menu de ajuda.
def help():
print(f"{RED}Menu de ajuda{BLACK}")
print(f"{RED}Comandos: {BLACK}")
print(f"{RED}* help: Exibe este menu de ajuda.{BLACK}")
print(f"{RED}* version: Exibe a versão do script.{BLACK}")
print(f"{RED}* quit: Sai do script.{BLACK}")
print(f"{RED}* check_open_ports: Verifica as portas abertas de um site.{BLACK}")
print(f"{RED}* get_ip: Consulta o IP de um site.{BLACK}")
print(f"{RED}* check_sql_vulnerabilities: Verifica se um site é vulnerável a SQLi.{BLACK}")
print(f"{RED}* get_protocol: Consulta se um site usa UDP ou TCP.{BLACK}")
# Exibe a versão do script.
def version():
print(f"{RED}Versão: {BLACK}1.0")
# Sai do script.
def quit():
sys.exit(0)
# Exibe o menu de comandos.
def show_commands():
print(f"{RED}**Menu de comandos**{BLACK}")
print(f"{RED}* help: Exibe este menu de ajuda.{BLACK}")
print(f"{RED}* version: Exibe a versão do script.{BLACK}")
print(f"{RED}* quit: Sai do script.{BLACK}")
print(f"{RED}* check_open_ports: Verifica as portas abertas de um site.{BLACK}")
print(f"{RED}* get_ip: Consulta o IP de um site.{BLACK}")
print(f"{RED}* check_sql_vulnerabilities: Verifica se um site é vulnerável a SQLi.{BLACK}")
print(f"{RED}* get_protocol: Consulta se um site usa UDP ou TCP.{BLACK}")
# Obtém o nome do site.
site_name = input(f"{RED}Digite o nome do site: {BLACK}")
# Obtém o IP do site.
site_ip = socket.gethostbyname(site_name)
# Verifica as portas abertas no site.
for port in range(1, 65535):
try:
socket.create_connection((site_ip, port), 2)
print(f"{RED}A porta {port} está aberta.{BLACK}")
except socket.error:
pass
# Verifica se o site usa UDP ou TCP.
if socket.getservbyport(80, "tcp") == site_ip:
print(f"{RED}O site usa TCP.{BLACK}")
else:
print(f"{RED}O site usa UDP.{BLACK}")
# Verifica se há um painel de administração.
admin_url = f"http://{site_ip}/admin"
try:
requests.get(admin_url)
print(f"{RED}Há um painel de administração no site.{BLACK}")
except requests.exceptions.ConnectionError:
print(f"{RED}Não há painel de administração no site.{BLACK}")
# Verifica se há vulnerabilidades SQL.
sql_vulnerabilities = ["/sqli-labs/", "/sqli-labs/vulnerabilities/"]
for vulnerability in sql_vulnerabilities:
try:
requests.get(f"http://{site_ip}{vulnerability}")
print(f"{RED}O site está vulnerável a SQLi.{BLACK}")
except requests.exceptions.ConnectionError:
pass
# Limpa a tela.
if commands_executed == 2:
clear()
commands_executed = commands_executed + 1