Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yehgdotnet
Created September 25, 2020 14:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yehgdotnet/27114d4bb5b28ec093e6dd36e329c389 to your computer and use it in GitHub Desktop.
Save yehgdotnet/27114d4bb5b28ec093e6dd36e329c389 to your computer and use it in GitHub Desktop.
Randomize Hostname and Renew IP
#!/bin/bash
echo +++++++++++++++++++++++++++++++++++++++++
echo Randomize Hostname and Renew IP
echo by Aung Khant, http://yehg.net
echo +++++++++++++++++++++++++++++++++++++++++
echo
########################################################
sleep 1
#Get Random String
#Ref: http://tldp.org/LDP/abs/html/string-manipulation.html#RANDSTRING
POS=2 # Starting from position 2 in the string.
LEN=8 # Extract eight characters.
str0="$$"
str1=$( echo "$str0" | md5sum | md5sum )
# Doubly scramble: ^^^^^^ ^^^^^^
randstring="${str1:$POS:$LEN}"
# Can parameterize ^^^^ ^^^^
# Set it to Hostname
echo
echo [*] Randomizing hostname ..
echo
hostname $randstring
echo -en Your new hostname is "\E[32m$randstring"
tput sgr0;
echo
echo
sleep 2
########################################################
#Renew IP
echo
echo [*] Renewing IP with random MAC
echo
ifconfig eth0 down
sleep 1
macchanger -r eth0
echo
sleep 1
ifconfig eth0 up
sleep 1
/etc/init.d/networking restart
ifconfig | grep "inet addr:"
echo
echo [*] Done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment