PHP Classes

File: ids/rfi.sh

Recommend this page to a friend!
  Packages of Moises Espindola   Sentinela   ids/rfi.sh   Download  
File: ids/rfi.sh
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Sentinela
Linux protection tools with Web dashboard panel
Author: By
Last change:
Date: 6 days ago
Size: 2,393 bytes
 

Contents

Class file image Download
#!/usr/bin/env bash #============================================================================= # Sentinela ? Intelligent Linux Security Framework # ids/rfi.sh ? Detección de Remote File Inclusion #============================================================================= # # Detecta intentos de inclusión remota de archivos. # # Vectores cubiertos: # - URLs externas en parámetros (http://evil.com/shell.txt) # - URLs con protocolos (ftp://, https://) # - Short URLs (bit.ly, tinyurl) # - IPs en URLs # - Puertos no estándar en URLs #============================================================================= # shellcheck source=lib/common.sh source "${SENTINELA_DIR}/lib/common.sh" #============================================================================= # Patrones RFI #============================================================================= RFI_PATTERNS=( # HTTP/HTTPS remotos (con extensión ejecutable) 'https?://[^/]+/[^\s&]+\.(php|php3|php4|php5|phtml|pht|phar|asp|aspx|jsp|cfm|shtml|pl|py|rb|sh|bash|cgi|cmd|bat|ps1|vbs|js|jse|wsf|wsh|hta)' # FTP remoto 'ftp://[^/]+/[^\s&]+\.(php|php3|php4|php5|phtml|pht|phar|asp|aspx|jsp|cfm|shtml|pl|py|rb|sh|bash|cgi|cmd|bat|ps1|vbs|js|jse|wsf|wsh|hta)' # URLs con IPs externas (no privadas) 'https?://[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/.*\.(php|txt|cmd)' # Shell remota vía eval/include 'include\s*\(.*https?://' 'include_once\s*\(.*https?://' 'require\s*\(.*https?://' 'require_once\s*\(.*https?://' 'fopen\s*\(.*https?://' 'file_get_contents\s*\(.*https?://' 'curl_exec\s*\(' 'file_put_contents\s*\(.*https?://' # Wrappers remotos 'http://' 'https://' 'ftp://' # Data injection 'data://.*base64' 'expect://' ) #============================================================================= # Verificar si una URI contiene RFI #============================================================================= rfi_check() { local uri="$1" local decoded_uri decoded_uri=$(echo "${uri}" | python3 -c "import sys,urllib.parse; print(urllib.parse.unquote(sys.stdin.read()))" 2>/dev/null || echo "${uri}") for pattern in "${RFI_PATTERNS[@]}"; do if echo "${decoded_uri}" | grep -qiP "${pattern}"; then echo "${pattern}" return 0 fi done return 1 }