GuardianUnivalle-Benito-Yucra 0.1.34__py3-none-any.whl → 0.1.36__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of GuardianUnivalle-Benito-Yucra might be problematic. Click here for more details.
- GuardianUnivalle_Benito_Yucra/auditoria/registro_auditoria.py +41 -4
- GuardianUnivalle_Benito_Yucra/detectores/detector_keylogger.py +9 -22
- {guardianunivalle_benito_yucra-0.1.34.dist-info → guardianunivalle_benito_yucra-0.1.36.dist-info}/METADATA +1 -1
- {guardianunivalle_benito_yucra-0.1.34.dist-info → guardianunivalle_benito_yucra-0.1.36.dist-info}/RECORD +7 -7
- {guardianunivalle_benito_yucra-0.1.34.dist-info → guardianunivalle_benito_yucra-0.1.36.dist-info}/WHEEL +0 -0
- {guardianunivalle_benito_yucra-0.1.34.dist-info → guardianunivalle_benito_yucra-0.1.36.dist-info}/licenses/LICENSE +0 -0
- {guardianunivalle_benito_yucra-0.1.34.dist-info → guardianunivalle_benito_yucra-0.1.36.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Archivo donde se guardarán los eventos
|
|
6
|
+
LOG_FILE = "auditoria_guardian.log"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def registrar_evento(
|
|
10
|
+
tipo: str,
|
|
11
|
+
descripcion: str = "",
|
|
12
|
+
severidad: str = "MEDIA",
|
|
13
|
+
extra: dict | None = None,
|
|
14
|
+
):
|
|
15
|
+
"""
|
|
16
|
+
Registra un evento de auditoría en un archivo.
|
|
17
|
+
:param tipo: Tipo de evento (DoS, CSRF, XSS, SQLi, etc.)
|
|
18
|
+
:param descripcion: Descripción detallada del evento
|
|
19
|
+
:param severidad: Nivel de severidad (BAJA, MEDIA, ALTA)
|
|
20
|
+
:param extra: Datos adicionales opcionales
|
|
21
|
+
"""
|
|
22
|
+
try:
|
|
23
|
+
evento = {
|
|
24
|
+
"fecha": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
|
25
|
+
"tipo": tipo,
|
|
26
|
+
"descripcion": descripcion,
|
|
27
|
+
"severidad": severidad,
|
|
28
|
+
"extra": extra or {},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Asegurar que el archivo exista
|
|
32
|
+
os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
|
|
33
|
+
|
|
34
|
+
with open(LOG_FILE, "a", encoding="utf-8") as f:
|
|
35
|
+
f.write(json.dumps(evento, ensure_ascii=False) + "\n")
|
|
36
|
+
|
|
37
|
+
except Exception as e:
|
|
38
|
+
print(f"[Auditoría] Error al registrar evento: {e}")
|
|
2
39
|
|
|
3
|
-
def registrar_evento(tipo: str, mensaje: str):
|
|
4
|
-
with open("auditoria_guardian.log", "a", encoding="utf-8") as f:
|
|
5
|
-
f.write(f"[{datetime.datetime.now()}] {tipo}: {mensaje}\n")
|
|
6
40
|
|
|
7
41
|
def generar_reporte() -> str:
|
|
8
|
-
|
|
42
|
+
"""Devuelve todo el contenido del archivo de auditoría."""
|
|
43
|
+
if not os.path.exists(LOG_FILE):
|
|
44
|
+
return "No hay registros aún."
|
|
45
|
+
with open(LOG_FILE, "r", encoding="utf-8") as f:
|
|
9
46
|
return f.read()
|
|
@@ -108,33 +108,22 @@ def detectar_archivos_sospechosos() -> List[str]:
|
|
|
108
108
|
|
|
109
109
|
def detectar_programas_instalados() -> list[str]:
|
|
110
110
|
"""
|
|
111
|
-
|
|
112
|
-
Funciona incluso si WMIC está en otra ruta o no está disponible.
|
|
111
|
+
Detecta software potencialmente malicioso en Windows usando PowerShell.
|
|
113
112
|
"""
|
|
114
113
|
hallazgos = []
|
|
115
114
|
if platform.system() != "Windows":
|
|
116
115
|
return hallazgos
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
"C:\\Windows\\System32\\WMIC.exe",
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
wmic_path = None
|
|
126
|
-
for ruta in posibles_rutas:
|
|
127
|
-
if os.path.exists(ruta):
|
|
128
|
-
wmic_path = ruta
|
|
129
|
-
break
|
|
130
|
-
|
|
131
|
-
# Si no se encontró ruta, intenta usarlo directamente (PATH)
|
|
132
|
-
if wmic_path is None:
|
|
133
|
-
wmic_path = "wmic"
|
|
117
|
+
ps_command = (
|
|
118
|
+
"Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*,"
|
|
119
|
+
"HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Select-Object DisplayName"
|
|
120
|
+
)
|
|
134
121
|
|
|
135
122
|
try:
|
|
136
123
|
salida = subprocess.check_output(
|
|
137
|
-
[
|
|
124
|
+
["powershell", "-Command", ps_command],
|
|
125
|
+
stderr=subprocess.DEVNULL,
|
|
126
|
+
shell=True,
|
|
138
127
|
).decode("utf-8", errors="ignore")
|
|
139
128
|
|
|
140
129
|
for linea in salida.splitlines():
|
|
@@ -143,10 +132,8 @@ def detectar_programas_instalados() -> list[str]:
|
|
|
143
132
|
hallazgos.append(nombre)
|
|
144
133
|
registrar_evento("Keylogger", f"Software sospechoso: {nombre}")
|
|
145
134
|
|
|
146
|
-
except FileNotFoundError:
|
|
147
|
-
logger.warning("WMIC no encontrado. No se puede listar programas instalados.")
|
|
148
135
|
except Exception as e:
|
|
149
|
-
logger.error("Error al listar programas instalados: %s", e)
|
|
136
|
+
logger.error("Error al listar programas instalados con PowerShell: %s", e)
|
|
150
137
|
|
|
151
138
|
return hallazgos
|
|
152
139
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: GuardianUnivalle-Benito-Yucra
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.36
|
|
4
4
|
Summary: Middleware y detectores de seguridad (SQLi, XSS, CSRF, DoS, Keylogger) para Django/Flask
|
|
5
5
|
Author-email: Andres Benito Calle Yucra <benitoandrescalle035@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
GuardianUnivalle_Benito_Yucra/__init__.py,sha256=lbIRb8fCFYfAdyJV6NsYVZJ5pKYSJZKhhK-En9g_1M8,762
|
|
2
2
|
GuardianUnivalle_Benito_Yucra/utilidades.py,sha256=lFNVnlyTSYmQ1CqtmHx6aefK5uNw0wsMdHRQyxAIZy0,120
|
|
3
|
-
GuardianUnivalle_Benito_Yucra/auditoria/registro_auditoria.py,sha256=
|
|
3
|
+
GuardianUnivalle_Benito_Yucra/auditoria/registro_auditoria.py,sha256=D_N9HxjsREMRHozWy_40YOJYggigXq7N0JOxQrHSWWM,1407
|
|
4
4
|
GuardianUnivalle_Benito_Yucra/criptografia/cifrado_aead.py,sha256=wfoRpaKvOqPbollNQsDNUNWClYJlXYTKTYvv0qcR6aI,962
|
|
5
5
|
GuardianUnivalle_Benito_Yucra/criptografia/intercambio_claves.py,sha256=9djnlzb022hUhrDbQyWz7lWLbkn_vQZ4K7qar1FXYmo,829
|
|
6
6
|
GuardianUnivalle_Benito_Yucra/criptografia/kdf.py,sha256=_sbepEY1qHEKga0ExrX2WRg1HeCPY5MC5CfXZWYyl-A,709
|
|
7
7
|
GuardianUnivalle_Benito_Yucra/detectores/detector_csrf.py,sha256=wt9LRMG9XK4eSSmW91tlGmsJWfyk445b8-n2oxlXlwo,7893
|
|
8
8
|
GuardianUnivalle_Benito_Yucra/detectores/detector_dos.py,sha256=KpsFnZvPmtKVgxR2Em_gIQvoho3sGOE_qQSWOEhts48,6163
|
|
9
|
-
GuardianUnivalle_Benito_Yucra/detectores/detector_keylogger.py,sha256=
|
|
9
|
+
GuardianUnivalle_Benito_Yucra/detectores/detector_keylogger.py,sha256=L5RQ0Sdgg7hTU1qkZYwt7AcDqtAzT6u-jwBGo7YWfsw,8078
|
|
10
10
|
GuardianUnivalle_Benito_Yucra/detectores/detector_sql.py,sha256=o2IXqF3Nbsh5roPihyLal42iCzgxfyX3D6Ef-cxOpVo,6644
|
|
11
11
|
GuardianUnivalle_Benito_Yucra/detectores/detector_xss.py,sha256=Ipw1XXBd1-SsOOhhl9joQGduTq0GhSa61TRTyASF3XE,6795
|
|
12
12
|
GuardianUnivalle_Benito_Yucra/middleware_web/middleware_web.py,sha256=23pLLYqliUoMrIC6ZEwz3hKXeDjWfHSm9vYPWGmDDik,495
|
|
13
13
|
GuardianUnivalle_Benito_Yucra/mitigacion/limitador_peticion.py,sha256=ipMOebYhql-6mSyHs0ddYXOcXq9w8P_IXLlpiIqGncw,246
|
|
14
14
|
GuardianUnivalle_Benito_Yucra/mitigacion/lista_bloqueo.py,sha256=6AYWII4mrmwCLHCvGTyoBxR4Oasr4raSHpFbVjqn7d8,193
|
|
15
15
|
GuardianUnivalle_Benito_Yucra/puntuacion/puntuacion_amenaza.py,sha256=Wx5XfcII4oweLvZsTBEJ7kUc9pMpP5-36RfI5C5KJXo,561
|
|
16
|
-
guardianunivalle_benito_yucra-0.1.
|
|
17
|
-
guardianunivalle_benito_yucra-0.1.
|
|
18
|
-
guardianunivalle_benito_yucra-0.1.
|
|
19
|
-
guardianunivalle_benito_yucra-0.1.
|
|
20
|
-
guardianunivalle_benito_yucra-0.1.
|
|
16
|
+
guardianunivalle_benito_yucra-0.1.36.dist-info/licenses/LICENSE,sha256=5e4IdL542v1E8Ft0A24GZjrxZeTsVK7XrS3mZEUhPtM,37
|
|
17
|
+
guardianunivalle_benito_yucra-0.1.36.dist-info/METADATA,sha256=_k421TBz-SFWSQtlJ1dwWGNwkG3x7hyDfsPs2oChJ8s,1893
|
|
18
|
+
guardianunivalle_benito_yucra-0.1.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
guardianunivalle_benito_yucra-0.1.36.dist-info/top_level.txt,sha256=HTWfZM64WAV_QYr5cnXnLuabQt92dvlxqlR3pCwpbDQ,30
|
|
20
|
+
guardianunivalle_benito_yucra-0.1.36.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|