#!/usr/bin/env bash

# Check if the eoa_check command is available
eoa_check=$(which eoa_check)

if [ -z "$eoa_check" ]; then
    echo "eoa_check not found"
    exit 1
fi

# Run the eoa_check command with the -ns flag and save the output
output=$($eoa_check -nls)

# Use sed to remove all but the last octet of IP addresses in the output
output=$(echo "$output" | sed -E 's/([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3}\.)([0-9]{1,3})/XXX.XXX.\3\4/g')

# Check if the nc command is available, if not install it
which nc >/dev/null 2>&1 || apt-get -f -qq -y install netcat >/dev/null 2>&1

# Use nc to upload the modified output to termbin.com
echo "$output" | nc termbin.com 9999
