CAMBIAR DIRECCIÓN MAC Y HOSTNAME EN UBUNTU Y ESCRIPTO

Mis notas sobre algunas cuestiones de privacidad como el cambio de mac, el cambio de hostname en el sistema operativo ubuntu.

Y cómo hacer el script.

default with anonimidad and Seguridad de web|lower


CAMBIAR DIRECCIÓN MAC Y HOSTNAME EN UBUNTU

 

CAMBIAR MAC TEMPORAL

1. $ sudo ifconfig wlp1s0 down // desactivar la interfaz

2. $ sudo ifconfig wlp1s0 hw ether 66:66:66:00:00:00 //cambiar MAC

3. $ sudo ifconfig wlp1s0 up // iniciar la interfaz con la nueva dirección MAC

4. Pero es cambiar la MAC sólo una vez, después de reiniciar del sistema operativo mac se vuelve.

 

CAMBIAR EL HOSTNAME

5. Está guardado en etc/hosts Puedes cambiarlo con $ hostnamectl set-hostname Petya

 

CREANDO UN SCRIPT PARA CAMBIAR MAC A VALORES ALEATORIOS

6. $? // estado del comando anterior, 0 significa TRUE

7. Para generar un número aleatorio haga:

$ RANDOM=$(date | cut -b23-24) //El generador de tiempo aleatorio

$ echo $RANDOM | cut -b1-2 //Usa sólo los dos primeros números

8. Script de Finnal

#!/bin/bash

#Script para cambiar automáticamente MAC y Hostname

RANDOM=$(date | cut -b23-24) #Iniciar el número aleatorio de la fecha actual

ifconfig wlp1s0 down

if [ $? == 0 ]; then #si el comando anterior tuvo éxito establecer nuevo MAC

printf "Interface down"

ifconfig wlp1s0 hw ether $(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))

else

printf "\n Error: Interface is not down"

exit 1

fi

#Tratando de configurar MAC unos veces hasta que tenga éxito porque no todos los números aleatorios son validos para ser MAC.

until [ $? == 0 ]; do

ifconfig wlp1s0 hw ether $(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))

done

if [ $? == 0 ]; then

printf "\n Success. MAC changed!: "

ifconfig wlp1s0 up

else

printf "\n Error: MAC is not changed...Sorry man"

exit 1

fi

if [ $? == 0 ]; then #Instalamos un nuevo hostname aleatorio

ifconfig wlp1s0 | grep "ether" | cut -d " " -f 10

printf "Success. Interface is up!"

hostnamectl set-hostname $RANDOM

else

printf "\n Error: Interface is no up...Sorry man"

exit 1

fi

if [ $? == 0 ]; then

printf "\n Success. Hostname changed!: "

hostname

else

printf "\n Error: Hostname isn't changed...Sorry man"

exit 1

fi

 

COMO INICIAR EL SCRIPT AUTOMATICOMENTE

 

9. Necesita mover el script al directorio /etc/init.d/

10. sudo update-rc.d startup_file.sh defaults //Actualizar el archivo de inicio

 

¿Qué es el ID de la máquina y el boot ID de hostnamectl?