Skip to content

Instantly share code, notes, and snippets.

@kafkaesqu3
Last active January 22, 2019 20:48
Show Gist options
  • Select an option

  • Save kafkaesqu3/13477dc67d6a95f88176ed678ec69ae8 to your computer and use it in GitHub Desktop.

Select an option

Save kafkaesqu3/13477dc67d6a95f88176ed678ec69ae8 to your computer and use it in GitHub Desktop.
macchanger configuration
root@kali:~# apt-get install macchanger
root@kali:~# systemctl disable network-manager
root@kali:~# cat /etc/default/macchanger
# before bringing up any network interface, run macchanger. Careful, this is
# not guaranteed to prevent leaking your real MAC address before the new one
# gets assigned!
#
ENABLE_ON_POST_UP_DOWN=false
# by default, macchanger runs on all network interfaces but loopback (lo). If
# you only want it to run on specific network interfaces, set them here:
#
ENABLE_INTERFACES="eth0"
IFACE="eth0"
root@kali:~# cat /etc/network/if-pre-up.d/macchanger
#!/bin/sh
#
# randomize MAC address before connecting to wifi or ethernet
#
# This script should always be run in if-pre-up.d, but unfortunately
# NetworkManager does not run if-pre-up.d scripts before it sets up a network
# connection (https://bugzilla.gnome.org/show_bug.cgi?id=387832).
# if-post-down.d scripts are run, so there is a symlink to this script
# there. That means when running network config from the terminal, macchanger
# will be run twice, but it'll only be run in if-post-down.d when using
# NetworkManager.
package=macchanger
. /etc/default/${package}
LOGFILE=/var/log/${package}.log
if [ "$ENABLE_ON_POST_UP_DOWN" != "true" ]; then
echo "disabled in /etc/default/${package}" >> $LOGFILE
exit
fi
echo "IFACE = $IFACE" >> $LOGFILE
# quit if we're called for the loopback
if [ "$IFACE" = lo ]; then
echo "ignoring loopback" >> $LOGFILE
exit 0
fi
/root/macc.sh $IFACE >> $LOGFILE 2>&1
#/usr/bin/${package} -e $IFACE >> $LOGFILE 2>&1
root@kali:~# cat macc.sh
#!/bin/bash
iface=$1
hexchars="0123456789ABCDEF"
end=$( for i in {1..6} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' )
# cisco OUI
newmac=F0:29:29$end
echo $newmac >> /root/mac.log
ifconfig $iface down
macchanger -m $newmac $iface
ifconfig $iface up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment