Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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