Saltar al contenido
Underc0de /foro

[BASH] Script to retrieve a person's data

🌐 This is an automatic translation of a topic from Underc0de, the largest Spanish-speaking hacking and IT community. Read the original (Spanish) and reply →
Barbol ·
Los enlaces son solo para miembros. Registrate o iniciá sesión

Hi. This is my first post on the forum. Here's a script that fetches a person's data based on their DNI. Ideal for user onboarding when you aren't given all the details.

Los enlaces son solo para miembros. Registrate o iniciá sesión

Código: text
#!/bin/bash

#[by fleiva]
#DIRBASE=/home/barbol/fullname
DIRBASE=~/fullname
NC='\033[0m'            # No Color
BBlue='\033[1;34m'      # Blue
UPurple='\033[4;35m'    # Purple

function limpiarArchivo () { #Recibe el nombre de archivo que tiene que procesar
        echo "" > $DIRBASE"/nombreLimpio.txt"
        while IFS= read -r line
        do
                line="${line#"${line%%[![:space:]]*}"}"   # elimina los espacios por delante
                line="${line%"${line##*[![:space:]]}"}"   # elimina los espacios por detrás
                echo $line >>$DIRBASE"/nombreLimpio.txt"
        done < $1
        sed -i '/^ *$/d' $DIRBASE"/nombreLimpio.txt" #elimina filas en blanco
}

function borrarArchivos () {
        rm -rf $DIRBASE/curl.txt
        rm -rf $DIRBASE/filaSucia.txt
        rm -rf $DIRBASE/parteFilaSucia.txt
        rm -rf $DIRBASE/partecitaFilaSucia.txt
        rm -rf $DIRBASE/nombreEspacio.txt
        rm -rf $DIRBASE/nombreLimpio.txt
}

function ConsultarNosis () {
    texto="$1"
    endpoint="https://informes.nosis.com/Home/Buscar"
    body="Texto=$texto"

    # Realizar la solicitud HTTP POST
    jsonResponse=$(curl -s -X POST -d "$body" "$endpoint")

    # Verificar la respuesta JSON
    entidadesEncontradas=$(echo "$jsonResponse" | jq '.EntidadesEncontradas')

    count=$(echo "$entidadesEncontradas" | jq 'length')

# Verificar si se encontraron entidades
    if [[ $count -gt 0 ]]; then
        for ((i = 0; i < $count; i++)); do
            documento=$(echo "$entidadesEncontradas" | jq -r ".[$i].Documento")
            razonSocial=$(echo "$entidadesEncontradas" | jq -r ".[$i].RazonSocial")
            provincia=$(echo "$entidadesEncontradas" | jq -r ".[$i].Provincia")
            echo "============ NOSIS ============" | lolcat
            echo -e "${BBlue}CUIL:$NC $documento"
            echo -e "${BBlue}NOMBRE:$NC $razonSocial"
            echo -e "${BBlue}PROVINCIA:$NC $provincia"
            echo "===============================" | lolcat
        done
    else
        echo "===========================================" | lolcat
        echo "&#128308; No se encontraron datos en nosis.com &#128308;"
        echo "===========================================" | lolcat
    fi
}

#INICIO PROGRAMA
cd $DIRBASE

ConsultarNosis $1

curl -s https://www.cuitonline.com/search.php\?q\=$1 | grep -a breadcrumbsContainer | cut -d'<' -f 10 | cut -d'>' -f 2 > $DIRBASE"/nombreLimpio.txt"
cantPalabras=`wc -w $DIRBASE"/nombreLimpio.txt" | awk '{print $1}'`;
        if test $cantPalabras -eq 0;
        then
                echo "================================================" | lolcat
                echo "&#128308; No se encontraron datos en cuitonline.com &#128308;"
                echo "================================================" | lolcat
        else
                echo ""
                echo "============ CUITONLINE ============" | lolcat
                resultado=`cat $DIRBASE"/nombreLimpio.txt"`
                echo "&#128994; $resultado &#128994;"
                echo "====================================" | lolcat
        fi


borrarArchivos
AXCESS ·
It's obviously for Argentina.

Question...

Does the script search the internet or does it have an internal database? I'm guessing the internet?

Would it be possible to add or modify a certain database, as well as the search pattern, such as a mobile number instead of the DNI, and have it work the same way? That would be a somewhat ambitious modification, please forgive me for aiming so high. It would be like a DB explorer or search engine.

Your work is really nice.

Too bad I'm not Argentinian...
AXCESS ·
Yes, I saw it in the script, but it's always good to ask.

It's very useful.
Grupo de WhatsApp