[Tails-dev] Prototype script for running macchanger at boot

Delete this message

Reply to this message
Autor: auenratio
Data:  
Dla: tails-dev
Temat: [Tails-dev] Prototype script for running macchanger at boot
Apparently, the mailing list scrubs attachments, so here are both the email body previously sent and the script named spoof-macaddr.sh inline with this email.  Note: I am forwarding this at intrigeri's request.----------Original Message----------From: auenratio@???Date: Oct 2, 2013 12:40:01 PMSubject: Prototype script for running macchanger at bootTo: intrigeri@??? Hi intrigeri,I am following the discussion on the tails-support mailing list, and after reading the article on Mac Spoofing by Etienne Perot at https://perot.me/mac-spoofing-what-why-how-and-something-about-coffee entitled Etienne Perot — MAC spoofing: What, why, how, and something about coffee, I wanted to contribute the attached working prototype script to your effort toward running macchanger at boot time.  It successfully generated the output file in the /etc/udev/rules.d directory for my two NIC system (eth0 and eth1).  It is coded to  generate lines in the output file for all configured network interfaces like wlan0 and/or wlan1 if they exist in the original file generated at boot time by the system, i.e. /etc/udev/rules.d/70-persistent-net.rules.I have not tested it further by making a new ISO file that includes it in /etc/rc.local as my router is partially borked due to messing with the admin password, and will need to be hard reset and reconfigured when I get the time, and also my router is not capable of handling the GB capability in eth1, so I'll need a new ISP service upgrade for that and/or a new router.I have always booted Tails with my router turned off, so that I could run macchanger before enabling networking (turning my router on).  Since then my ISP had remotely  rewritten the admin password before I attempted to change it, and they also apparently upgraded the firmware on the router at the same time.  Even after the router password change, my router seemed to accept spoofed Mac addresses from running macchanger for a while even after I borked my router's password.  Currently, my router only accepts my original Mac address, and cannot be used further for testing this script until I have at least resolved its admin password problem.As written, the new output file of the script named /etc/udev/rules.d/20-macspoof-net.rules should override the current Mac address(es) after all of the numbered scripts have initially run in both /etc/udev/rules.d and /lib/udev/rules.d and since the udev daemon monitors changes to files in the /etc/udev/rules.d directory.-- Tom#!/bin/sh
#
# Required Input file: /etc/udev/rules.d/70-persistent-net.rules
# Generated Output file: /etc/udev/rules.d/20-macspoof-net.rules
#
# N.B. This script should be run only after the 70-persistent-net.rules file
# has been generated by the /lib/udev/write_net_rules program, run by the
# persistent-net-generator.rules rules file at boot time which initially
# configures all of the present network devices.
#
# This is a working prototype intended for use in the development of running
# the macchanger at boot time for Tails.  This script may be useful in a boot
# role in /etc/init.d via /etc/rc.local which as yet has not been tested nor
# guaranteed to generate the output file if the input file to the nawk command 
# has not yet been generated at that point in booting.
#
# The function of this script is to override the eth*|wlan* HWaddr field value
# in the file named 70-persistent-net.rules located in the directory path
# /etc/udev/rules.d with a newly generated Mac address from running the
# macchanger command after booting up Tails before enabling networking.
#
# Exit if input file does not yet exist
#
if [ ! -f /etc/udev/rules.d/70-persistent-net.rules ]
then
   exit 1
fi
#
# Exit if output file exists from previous runlevel rc.local execution
#
if [ -f /etc/udev/rules.d/20-macspoof-net.rules ] 
then exit 2
fi
touch /etc/udev/rules.d/20-macspoof-net.rules
#
# Create the new 20-macspoof-net.rules file in /etc/udev/rules.d for only 
# configured network interfaces including: eth[0|1] and wlan[0|1]
# Note: the input file contains the original Mac address HWaddr field created
# at boot time and hence needs no check for its existence to create output file.
#
nawk '{ if ( $8 ~ /eth0/ ) {print $2" "$4" RUN+=\"/usr/bin/macchanger -A eth0\""} else if ( $8 ~ /eth1/ ) {print $2" "$4" RUN+=\"/usr/bin/macchanger -A eth1\""} else if ( $8 ~ /wlan0/ ) {print $2" "$4" RUN+=\"/usr/bin/macchanger -A wlan0\""} else if ( $8 ~ /wlan1/ ) {print $2" "$4" RUN+=\"/usr/bin/macchanger -A wlan1\""} }' /etc/udev/rules.d/70-persistent-net.rules >> /etc/udev/rules.d/20-macspoof-net.rules
chmod go+r /etc/udev/rules.d/20-macspoof-net.rules
exit 0