Created
September 25, 2020 14:56
-
-
Save yehgdotnet/27114d4bb5b28ec093e6dd36e329c389 to your computer and use it in GitHub Desktop.
Randomize Hostname and Renew IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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