Connect to routers anonymously

Sat 28 September 2013

anonymous

I've created a little script that incorporates wicd, macchanger, hostname and john the ripper'spassword list to randomise your mac address and hostname when connecting to the internet.

I've gone with wicd over network manager as network-manager has a tendency to store connection details, so while your machine might id your hostname or mac address as something new, network-manager will actually connect using the original stored details.

I must admit I enjoyed writing this, it reminded me of the old days when linux network managers were all rubbish and you had to write bash scripts to connect to vaguely complex network configurations.

#!/bin/bash
# Anonymise your machines internet connection
# REQUIRES: macchanger, wicd and john the rippers password list

# Settings
INTERFACE=wlan1
HOSTS_FILE="/etc/hosts"
START_TOKEN="## start-anon"
END_TOKEN="## end-anon"


# Must be run as root
if [[ $EUID -ne 0 ]]; then
    printf "This script must be run as root\n" 1>&2
    exit 1
fi

# Network restart function
if [ "Linux" == `uname` ]; then
    restart_network="/etc/init.d/networking restart"
fi

# Function to clear old data and add new hosts entry
function update_hosts()
{
    # if no hosts file found...
    if [ ! -f $1 ]
    then
        printf \n"No hosts file found\n" 1>&2
        exit 1
    fi

    file=$1
    host=$2

    sed_script="{
    s/$END_TOKEN/$END_TOKEN/
    t finished_sites

    s/$START_TOKEN/$START_TOKEN/
    x
    t started_sites

    s/$START_TOKEN/$START_TOKEN/
    x
    t started_sites

    p
    b end
    : started_sites
    d
    : finished_sites
    x
    d
    : end
    d
    }"

    hostname $host

    sed --in-place -e "$sed_script" $file
    echo $START_TOKEN >> $file
    printf "\n127.0.1.1    $host\n" >> $file
    echo $END_TOKEN >> $file
}

# Presenting original information
printf "Starting to anonimise your data\n"

# Stop Wicd
sudo service wicd stop
sleep 1

#changing mac address to random
ifconfig $INTERFACE down > /dev/null
if [ $? == 0 ]; then
    printf "%snChanging mac address...\n"
    macchanger -r $INTERFACE
else
    printf "%sScript encountered an error, sorry...\n"
    exit 1
fi
sleep 1

# Use john to supply new hostname to function
OLDHOST=$(hostname)
printf "%s\nChanging hostname...\n"
printf "Current : $OLDHOST \n"
FILE=/usr/share/john/password.lst
WORD=$(sort -R $FILE | head -1)
update_hosts $HOSTS_FILE $WORD
NEWHOST=$(hostname)
printf "New : $NEWHOST \n"
sleep 1

# putting interface up
ifconfig $INTERFACE up > /dev/null
printf "\n"
sleep 1

# Restart networking
$restart_network

# Get wicd back up and running
service wicd start
sleep 1

wicd-gtk > /dev/null 2>&1 &

#END

Category: Projects Tagged: anonymous internet networking security

comments

Page 1 of 1