summaryrefslogtreecommitdiff
path: root/community_modules/winremote
diff options
context:
space:
mode:
Diffstat (limited to 'community_modules/winremote')
-rw-r--r--community_modules/winremote/winremote_check.sh55
-rw-r--r--community_modules/winremote/winremote_check.tr.en6
-rw-r--r--community_modules/winremote/winremote_check.tr.es6
-rw-r--r--community_modules/winremote/winremote_detect.sh65
-rw-r--r--community_modules/winremote/winremote_detect.tr.en10
-rw-r--r--community_modules/winremote/winremote_detect.tr.es10
-rw-r--r--community_modules/winremote/winremote_exec.sh60
-rw-r--r--community_modules/winremote/winremote_exec.tr.en6
-rw-r--r--community_modules/winremote/winremote_exec.tr.es6
-rw-r--r--community_modules/winremote/winremote_exec_winrm.sh74
-rw-r--r--community_modules/winremote/winremote_exec_winrm.tr.en6
-rw-r--r--community_modules/winremote/winremote_exec_winrm.tr.es6
12 files changed, 310 insertions, 0 deletions
diff --git a/community_modules/winremote/winremote_check.sh b/community_modules/winremote/winremote_check.sh
new file mode 100644
index 0000000..4f0d608
--- /dev/null
+++ b/community_modules/winremote/winremote_check.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+# Module: winremote_check
+# Description: Verifica conectividad y ejecución remota básica en equipos Windows mediante SSH y PowerShell
+# License: GPLv3
+# Author: Luis GuLo
+# Version: 1.2.0
+# Dependencies: ssh, powershell (en el host remoto)
+
+winremote_check_task() {
+ local host="$1"; shift
+ declare -A args
+ for arg in "$@"; do key="${arg%%=*}"; value="${arg#*=}"; args["$key"]="$value"; done
+
+ local winuser="${args[winuser]}"
+ local winpassword="${args[winpassword]}"
+ local port="${args[port]:-22}"
+ local command="Write-Output 'Conexión establecida desde ShFlow'"
+
+ # 🌐 Cargar traducciones
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_check.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if [[ -z "$host" || -z "$winuser" || -z "$winpassword" ]]; then
+ echo "${tr[missing_args]:-❌ [winremote_check] Parámetros incompletos. Se requiere host, winuser y winpassword.}"
+ return 1
+ fi
+
+ [[ "$host" == *@* ]] && host=$(echo "$host" | awk -F '@' '{print $2}')
+
+ echo "$(render_msg "${tr[start]}" "host=$host")"
+
+ if sshpass -p "$winpassword" ssh -o PreferredAuthentications=password -o StrictHostKeyChecking=no -p "$port" "$winuser@$host" powershell -Command "\"$command\"" &>/dev/null; then
+ echo "$(render_msg "${tr[success]}" "host=$host")"
+ return 0
+ else
+ echo "$(render_msg "${tr[fail]}" "host=$host")"
+ return 1
+ fi
+}
+
+check_dependencies_winremote_check() {
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_check.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if ! command -v ssh &> /dev/null; then
+ echo "${tr[missing_ssh]:-❌ [winremote_check] ssh no está disponible.}"
+ return 1
+ fi
+ echo "${tr[ssh_ok]:-✅ [winremote_check] ssh disponible.}"
+ return 0
+}
diff --git a/community_modules/winremote/winremote_check.tr.en b/community_modules/winremote/winremote_check.tr.en
new file mode 100644
index 0000000..3af94a8
--- /dev/null
+++ b/community_modules/winremote/winremote_check.tr.en
@@ -0,0 +1,6 @@
+missing_args=❌ [winremote_check] Missing parameters. host, winuser and winpassword are required.
+start=🖥️ [winremote_check] Checking remote access to {host}...
+success=✅ [winremote_check] Remote connection and execution OK on {host}
+fail=❌ [winremote_check] Connection or execution failed on {host}
+missing_ssh=❌ [winremote_check] ssh is not available.
+ssh_ok=✅ [winremote_check] ssh is available.
diff --git a/community_modules/winremote/winremote_check.tr.es b/community_modules/winremote/winremote_check.tr.es
new file mode 100644
index 0000000..b80f33b
--- /dev/null
+++ b/community_modules/winremote/winremote_check.tr.es
@@ -0,0 +1,6 @@
+missing_args=❌ [winremote_check] Parámetros incompletos. Se requiere host, winuser y winpassword.
+start=🖥️ [winremote_check] Verificando acceso remoto a {host}...
+success=✅ [winremote_check] Conexión y ejecución remota OK en {host}
+fail=❌ [winremote_check] Fallo de conexión o ejecución en {host}
+missing_ssh=❌ [winremote_check] ssh no está disponible.
+ssh_ok=✅ [winremote_check] ssh disponible.
diff --git a/community_modules/winremote/winremote_detect.sh b/community_modules/winremote/winremote_detect.sh
new file mode 100644
index 0000000..4477acd
--- /dev/null
+++ b/community_modules/winremote/winremote_detect.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# Module: winremote_detect
+# Description: Detecta si un host Windows tiene habilitado SSH, WinRM, ambos o ninguno
+# License: GPLv3
+# Author: Luis GuLo
+# Version: 1.2.0
+# Dependencies: nc, curl, pwsh (opcional)
+
+winremote_detect_task() {
+ local host="$1"; shift
+ declare -A args
+ for arg in "$@"; do key="${arg%%=*}"; value="${arg#*=}"; args["$key"]="$value"; done
+
+ local ssh_port="${args[ssh_port]:-22}"
+ local winrm_port="${args[winrm_port]:-5985}"
+
+ # 🌐 Cargar traducciones
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_detect.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ [[ "$host" == *@* ]] && host=$(echo "$host" | awk -F '@' '{print $2}')
+
+ echo "$(render_msg "${tr[start]}" "host=$host")"
+
+ local ssh_status="${tr[ssh_off]:-❌ SSH no disponible}"
+ local winrm_status="${tr[winrm_off]:-❌ WinRM no disponible}"
+
+ if nc -z -w2 "$host" "$ssh_port" &>/dev/null; then
+ ssh_status="$(render_msg "${tr[ssh_on]}" "port=$ssh_port")"
+ fi
+
+ if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 2 "http://$host:$winrm_port/wsman" | grep -q "405"; then
+ winrm_status="$(render_msg "${tr[winrm_on]}" "port=$winrm_port")"
+ fi
+
+ echo " $ssh_status"
+ echo " $winrm_status"
+
+ if [[ "$ssh_status" == *✅* && "$winrm_status" == *✅* ]]; then
+ echo "$(render_msg "${tr[both]}" "host=$host")"
+ return 0
+ elif [[ "$ssh_status" == *✅* || "$winrm_status" == *✅* ]]; then
+ echo "${tr[one]:-🟡 Uno de los protocolos está disponible}"
+ return 0
+ else
+ echo "$(render_msg "${tr[none]}" "host=$host")"
+ return 1
+ fi
+}
+
+check_dependencies_winremote_detect() {
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_detect.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if ! command -v nc &> /dev/null || ! command -v curl &> /dev/null; then
+ echo "${tr[missing_deps]:-❌ [winremote_detect] nc o curl no están disponibles.}"
+ return 1
+ fi
+ echo "${tr[deps_ok]:-✅ [winremote_detect] nc y curl disponibles.}"
+ return 0
+}
diff --git a/community_modules/winremote/winremote_detect.tr.en b/community_modules/winremote/winremote_detect.tr.en
new file mode 100644
index 0000000..986e44f
--- /dev/null
+++ b/community_modules/winremote/winremote_detect.tr.en
@@ -0,0 +1,10 @@
+start=🔍 [winremote_detect] Checking connectivity with {host}...
+ssh_on=✅ SSH enabled (port {port})
+ssh_off=❌ SSH not available
+winrm_on=✅ WinRM enabled (port {port})
+winrm_off=❌ WinRM not available
+both=🟢 Both protocols available on {host}
+one=🟡 One protocol is available
+none=🔴 No remote protocol detected on {host}
+missing_deps=❌ [winremote_detect] nc or curl are not available.
+deps_ok=✅ [winremote_detect] nc and curl are available.
diff --git a/community_modules/winremote/winremote_detect.tr.es b/community_modules/winremote/winremote_detect.tr.es
new file mode 100644
index 0000000..530a034
--- /dev/null
+++ b/community_modules/winremote/winremote_detect.tr.es
@@ -0,0 +1,10 @@
+start=🔍 [winremote_detect] Analizando conectividad con {host}...
+ssh_on=✅ SSH habilitado (puerto {port})
+ssh_off=❌ SSH no disponible
+winrm_on=✅ WinRM habilitado (puerto {port})
+winrm_off=❌ WinRM no disponible
+both=🟢 Ambos protocolos disponibles en {host}
+one=🟡 Uno de los protocolos está disponible
+none=🔴 Ningún protocolo remoto detectado en {host}
+missing_deps=❌ [winremote_detect] nc o curl no están disponibles.
+deps_ok=✅ [winremote_detect] nc y curl disponibles.
diff --git a/community_modules/winremote/winremote_exec.sh b/community_modules/winremote/winremote_exec.sh
new file mode 100644
index 0000000..79bf413
--- /dev/null
+++ b/community_modules/winremote/winremote_exec.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Module: winremote_exec
+# Description: Ejecuta comandos PowerShell en un host Windows remoto vía SSH
+# License: GPLv3
+# Author: Luis GuLo
+# Version: 1.2.0
+# Dependencies: sshpass, ssh
+
+winremote_exec_task() {
+ local host="$1"; shift
+ declare -A args
+ for arg in "$@"; do key="${arg%%=*}"; value="${arg#*=}"; args["$key"]="$value"; done
+
+ local winuser="${args[winuser]}"
+ local winpassword="${args[winpassword]}"
+ local port="${args[port]:-22}"
+ local command="${args[command]}"
+
+ # 🌐 Cargar traducciones
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_exec.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if [[ -z "$host" || -z "$winuser" || -z "$winpassword" || -z "$command" ]]; then
+ echo "${tr[missing_args]:-❌ [winremote_exec] Parámetros incompletos. Se requiere host, winuser, winpassword y command.}"
+ return 1
+ fi
+
+ [[ "$host" == *@* ]] && host=$(echo "$host" | awk -F '@' '{print $2}')
+ local safe_command=$(printf "%q" "$command")
+
+ echo "$(render_msg "${tr[start]}" "host=$host" "port=$port" "user=$winuser")"
+
+ sshpass -p "$winpassword" ssh -o PreferredAuthentications=password -o StrictHostKeyChecking=no -p "$port" "$winuser@$host" \
+ "powershell -Command \"$safe_command\""
+
+ local exit_code=$?
+ if [[ $exit_code -eq 0 ]]; then
+ echo "${tr[success]:-✅ [winremote_exec] Comando ejecutado correctamente.}"
+ return 0
+ else
+ echo "$(render_msg "${tr[fail]}" "code=$exit_code")"
+ return $exit_code
+ fi
+}
+
+check_dependencies_winremote_exec() {
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_exec.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if ! command -v sshpass &> /dev/null || ! command -v ssh &> /dev/null; then
+ echo "${tr[missing_deps]:-❌ [winremote_exec] sshpass o ssh no están disponibles.}"
+ return 1
+ fi
+ echo "${tr[deps_ok]:-✅ [winremote_exec] sshpass y ssh disponibles.}"
+ return 0
+}
diff --git a/community_modules/winremote/winremote_exec.tr.en b/community_modules/winremote/winremote_exec.tr.en
new file mode 100644
index 0000000..e1fa189
--- /dev/null
+++ b/community_modules/winremote/winremote_exec.tr.en
@@ -0,0 +1,6 @@
+missing_args=❌ [winremote_exec] Missing parameters. host, winuser, winpassword and command are required.
+start=🔧 [winremote_exec] Executing remote command on {host}:{port} as {user}...
+success=✅ [winremote_exec] Command executed successfully.
+fail=❌ [winremote_exec] Error executing command (code {code}).
+missing_deps=❌ [winremote_exec] sshpass or ssh are not available.
+deps_ok=✅ [winremote_exec] sshpass and ssh are available.
diff --git a/community_modules/winremote/winremote_exec.tr.es b/community_modules/winremote/winremote_exec.tr.es
new file mode 100644
index 0000000..1a52f10
--- /dev/null
+++ b/community_modules/winremote/winremote_exec.tr.es
@@ -0,0 +1,6 @@
+missing_args=❌ [winremote_exec] Parámetros incompletos. Se requiere host, winuser, winpassword y command.
+start=🔧 [winremote_exec] Ejecutando comando remoto en {host}:{port} como {user}...
+success=✅ [winremote_exec] Comando ejecutado correctamente.
+fail=❌ [winremote_exec] Error al ejecutar el comando (código {code}).
+missing_deps=❌ [winremote_exec] sshpass o ssh no están disponibles.
+deps_ok=✅ [winremote_exec] sshpass y ssh disponibles.
diff --git a/community_modules/winremote/winremote_exec_winrm.sh b/community_modules/winremote/winremote_exec_winrm.sh
new file mode 100644
index 0000000..8d4e1bd
--- /dev/null
+++ b/community_modules/winremote/winremote_exec_winrm.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+# Module: winremote_exec_winrm
+# Description: Ejecuta comandos en un host Windows remoto vía WSMan (WinRM) desde Linux
+# License: GPLv3
+# Author: Luis GuLo
+# Version: 1.3.0
+# Dependencies: wsman
+
+winremote_exec_winrm_task() {
+ local host="$1"; shift
+ declare -A args
+ for arg in "$@"; do key="${arg%%=*}"; value="${arg#*=}"; args["$key"]="$value"; done
+
+ local winuser="${args[winuser]}"
+ local winpassword="${args[winpassword]}"
+ local port="${args[port]:-5985}"
+ local command="${args[command]}"
+
+ # 🌐 Cargar traducciones
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_exec_winrm.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if [[ -z "$host" || -z "$winuser" || -z "$winpassword" || -z "$command" ]]; then
+ echo "${tr[missing_args]:-❌ [winremote_exec_winrm] Parámetros incompletos. Se requiere host, winuser, winpassword y command.}"
+ return 1
+ fi
+
+ [[ "$host" == *@* ]] && host=$(echo "$host" | awk -F '@' '{print $2}')
+
+ local xml_file=$(mktemp --suffix=.xml)
+ trap '[[ -n "$xml_file" && -f "$xml_file" ]] && rm -f "$xml_file"' EXIT
+
+ cat > "$xml_file" <<EOF
+<p:Create_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Process">
+ <p:CommandLine>${command}</p:CommandLine>
+</p:Create_INPUT>
+EOF
+
+ echo "$(render_msg "${tr[start]}" "host=$host" "port=$port" "user=$winuser")"
+
+ wsman invoke http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Process \
+ -a Create \
+ -h "$host" \
+ -P "$port" \
+ -u "$winuser" \
+ -p "$winpassword" \
+ -y basic \
+ -J "$xml_file"
+
+ local exit_code=$?
+ if [[ $exit_code -eq 0 ]]; then
+ echo "${tr[success]:-✅ [winremote_exec_winrm] Comando ejecutado correctamente vía WSMan.}"
+ return 0
+ else
+ echo "$(render_msg "${tr[fail]}" "code=$exit_code")"
+ return $exit_code
+ fi
+}
+
+check_dependencies_winremote_exec_winrm() {
+ local lang="${shflow_vars[language]:-es}"
+ local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_exec_winrm.tr.${lang}"
+ declare -A tr
+ if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+ if ! command -v wsman &> /dev/null; then
+ echo "${tr[missing_wsman]:-❌ [winremote_exec_winrm] El cliente 'wsman' no está disponible.}"
+ return 1
+ fi
+ echo "${tr[wsman_ok]:-✅ [winremote_exec_winrm] Cliente 'wsman' disponible.}"
+ return 0
+}
diff --git a/community_modules/winremote/winremote_exec_winrm.tr.en b/community_modules/winremote/winremote_exec_winrm.tr.en
new file mode 100644
index 0000000..ddb3ebe
--- /dev/null
+++ b/community_modules/winremote/winremote_exec_winrm.tr.en
@@ -0,0 +1,6 @@
+missing_args=❌ [winremote_exec_winrm] Missing parameters. host, winuser, winpassword and command are required.
+start=🔧 [winremote_exec_winrm] Executing remote command on {host}:{port} as {user}...
+success=✅ [winremote_exec_winrm] Command executed successfully via WSMan.
+fail=❌ [winremote_exec_winrm] Error executing command (code {code}).
+missing_wsman=❌ [winremote_exec_winrm] 'wsman' client is not available.
+wsman_ok=✅ [winremote_exec_winrm] 'wsman' client is available.
diff --git a/community_modules/winremote/winremote_exec_winrm.tr.es b/community_modules/winremote/winremote_exec_winrm.tr.es
new file mode 100644
index 0000000..51fe754
--- /dev/null
+++ b/community_modules/winremote/winremote_exec_winrm.tr.es
@@ -0,0 +1,6 @@
+missing_args=❌ [winremote_exec_winrm] Parámetros incompletos. Se requiere host, winuser, winpassword y command.
+start=🔧 [winremote_exec_winrm] Ejecutando comando remoto en {host}:{port} como {user}...
+success=✅ [winremote_exec_winrm] Comando ejecutado correctamente vía WSMan.
+fail=❌ [winremote_exec_winrm] Error al ejecutar el comando (código {code}).
+missing_wsman=❌ [winremote_exec_winrm] El cliente 'wsman' no está disponible.
+wsman_ok=✅ [winremote_exec_winrm] Cliente 'wsman' disponible.