Pistas

  1. There is a samba share that allows anonymous access. Wonder what's in there!
  2. One of the samba users have a bad password. Their private share with the same name as their username is at risk!
  3. Follow the hint given in the previous flag to uncover this one.
  4. This is a warning meant to deter unauthorized users from logging in.

Empezamos escaneando con nmap

nmap -sV -sC -p- target.ine.local

image.png

Probamos de todo, enum4linux , el módulo smbenumshares de metasploit y no vemos nada, a si que optamos por hacer un script de enumeración con diccionario:

Script para enumerar shares

#!/bin/bash

# Valores por defecto
WORDLIST="/usr/share/enum4linux/share-list.txt" # Ruta común en Kali/INE

usage() {
    echo "Uso: $0 -t <IP> [-w <wordlist>] [-o <output_file>]"
    echo "  -t, --target   IP del objetivo o hostname"
    echo "  -w, --wordlist Ruta al diccionario de shares (opcional)"
    echo "  -o, --output   Archivo donde guardar los shares válidos (opcional)"
    exit 1
}

# Procesar argumentos
while [[ "$#" -gt 0 ]]; do
    case $1 in
        -t|--target) TARGET="$2"; shift ;;
        -w|--wordlist) WORDLIST="$2"; shift ;;
        -o|--output) OUTPUT="$2"; shift ;;
        *) usage ;;
    esac
    shift
done

# Validar que el target existe
if [ -z "$TARGET" ]; then
    usage
fi

# Verificar si el diccionario existe
if [ ! -f "$WORDLIST" ]; then
    echo "[-] Error: Diccionario no encontrado en $WORDLIST"
    exit 1
fi

# Función para limpiar el rastro al salir (Ctrl+C)
trap "exit" INT

# Bucle de escaneo
while read -r SHARE; do
    # Intentamos conectar de forma anónima (-N) y ejecutar un comando vacío
    # Usamos SMB2/3 por si acaso el servidor rechaza SMB1
    smbclient "//$TARGET/$SHARE" -N -c "ls" --option='client min protocol=SMB2' &>/dev/null

    if [ $? -eq 0 ]; then
        echo "$SHARE" # Imprime solo el nombre para que sea procesable
        
        # Si se definió un archivo de salida, guardamos el share
        if [ ! -z "$OUTPUT" ]; then
            echo "$SHARE" >> "$OUTPUT"
        fi
    fi
done < "$WORDLIST"

USO:

./shares.sh -t target.ine.local -w /root/Desktop/wordlists/shares.txt  -o shares.txt

image.png

Accedemos con smbclient

smbclient //target.ine.local/pubfiles -N

image.png