#From: am@innuendo.princeton.edu (Andrew Myers)
#Subject: NEW: Linux module which changes your ethernet address
#Date: 28 Sep 1995 02:35:42 GMT
 
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1995-09-27 22:14 EDT by <am@innuendo>.
# Source directory was `/home/am/scrap'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
# This format requires very little intelligence at unshar time.
# "if test", "echo", and "sed" may be needed.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   1448 -rw-r--r-- README
#   1202 -rw-r--r-- Makefile
#   2412 -rw-r--r-- scrap.c
#
# ============= README ==============
if test -f 'README' && test X"$1" != X"-c"; then
  echo 'x - skipping README (file already exists)'
else
  echo 'x - extracting README (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'README' &&
XHowdy.  This here's a distribution of scrap v0.3.  Scrap is a handy
Xloadable module for linux that will change a computer's ethernet
Xaddress (that's the ethernet adaptor's hardware address, not the IP
Xaddress, which is much easier to mess with) for a time.
X
XHow's it used?  Glad you asked.  All it takes is three easy steps.
XFirst, unpack the distribution and build it by typing 'make.'  Second,
Xfind a cool ethernet address and decide which ethernet device you'll
Xbe wanting to mess with.  Last, insert the module with insmod.  Here's
Xan example command line:
X
Xinsmod scrap.o name=eth0 address=0x9,0xa,0xb,0xc,0xd,0xe
X
XThis would alter the hardware address of device eth0 to 9:a:b:c:d:e.
XNow, say you wanted to go back to your old address.  No worries, just
Xremove the module:
X
Xrmmod scrap
X
XPresto, everything's back to normal.
X
XWARNING:  Some people, who may be system administrators, may be less
Xthan enthusiastic if you use this module.  But hey, lots of people are
Xalways upset about something, so draw your own conclusions.
X
XFinally, we'd just like to say that we wrote this code to learn a
Xthing or two, not to break into any systems (systems we have no wish
Xto break into include the Department of Defense, the White House, and
XPrinceton University).  Anyway, we're sure there are lots of good uses
Xfor this code, so we're releasing it under the GPL.
X
XLouis Kruger <lpkruger@cs.princeton.edu> and 
XAndrew Myers <acmyers@cs.princeton.edu>
X
X
SHAR_EOF
  : || echo 'restore of README failed'
fi
# ============= Makefile ==============
if test -f 'Makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping Makefile (file already exists)'
else
  echo 'x - extracting Makefile (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
X#  scrap.c --- a linux loadable module that changes a machine's hardware 
X#                address
X#    Copyright (C) 1995 by Louis P. Kruger <lpkruger@cs.princeton.edu> and
X#                          Andrew C. Myers <acmyers@cs.princeton.edu>
X#
X#    This program is free software; you can redistribute it and/or modify
X#    it under the terms of the GNU General Public License as published by
X#    the Free Software Foundation; either version 2 of the License, or
X#    (at your option) any later version.
X#
X#    This program is distributed in the hope that it will be useful,
X#    but WITHOUT ANY WARRANTY; without even the implied warranty of
X#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X#    GNU General Public License for more details.
X#
X#    To receive a copy of the GNU General Public Licent, write to the 
X#    Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 
X#    USA.
X
XCPPFLAGS       = -DLINUX
XCFLAGS         = -m486 -O2 -g -Wall
XCC             = gcc
XRM             = rm
X
Xscrap.o:       scrap.c release.h
X               $(CC) -D__KERNEL__ -DMODULE $(CPPFLAGS) -c -m486 -O scrap.c -o s
crap.o
X
Xrelease.h: 
X       @echo char kernel_version[] = \"`uname -r`\"\; > release.h
X
Xclean:
X       -$(RM) -f *.o release.h *~ core
X
SHAR_EOF
  : || echo 'restore of Makefile failed'
fi
# ============= scrap.c ==============
if test -f 'scrap.c' && test X"$1" != X"-c"; then
  echo 'x - skipping scrap.c (file already exists)'
else
  echo 'x - extracting scrap.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'scrap.c' &&
X/*  scrap.c --- a linux loadable module that changes a machine's hardware 
X                address
X    Copyright (C) 1995 by Louis P. Kruger <lpkruger@cs.princeton.edu> and
X                          Andrew C. Myers <acmyers@cs.princeton.edu>
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 2 of the License, or
X    (at your option) any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    To receive a copy of the GNU General Public Licent, write to the 
X    Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 
X    USA.
X
X*/
X
X
X#include <linux/sched.h>
X#include <linux/errno.h>
X#include <linux/major.h>
X#include <asm/io.h>
X#include <asm/segment.h>
X#include <asm/system.h>
X#include <linux/autoconf.h>
X#include <linux/module.h>
X#include <linux/mm.h>
X#include <linux/ioport.h>
X
X#include <linux/netdevice.h>
X#include <linux/etherdevice.h>
X
X#include "release.h"
X
X/* int bad_user_access_length(void) {} */
X
Xunsigned int addr[MAX_ADDR_LEN]={0,0,0,0,0,0};
Xchar *name = "eth0";
X
Xstatic unsigned int old_addr[MAX_ADDR_LEN]={0,0,0,0,0,0};
Xstatic struct device *the_dev = NULL;
X
Xstatic struct device *my_dev_get(void)
X{
X  struct device *d;
X  const char *a, *b;
X
X  for (d = dev_base; d != NULL; d = d->next)
X    {
X      a = d->name; 
X      b = name;
X      for ( ; *a != '\0' && *b != '\0'; a++, b++)
X       if (*a != *b) goto hack;
X      return d;
X    hack:
X    }
X  return NULL;
X}
X
X
Xstatic void set_address(struct device *dev)
X{
X  int i;
X
X  for (i = 0; i < MAX_ADDR_LEN; i++) {
X    old_addr[i] = dev->dev_addr[i];
X    dev->dev_addr[i] = (unsigned char)addr[i];
X  }
X}
X
Xint init_module(void)
X{
X  struct device *d;
X
X  printk("Just started spoofing hardware address\n");
X  d = my_dev_get();
X  the_dev = d;
X  if (d == NULL)
X    {
X      printk("Captain, I can't find any ethernet device named %s!\n", name);
X      return 1;
X    }
X  set_address(d);
X  return 0;
X}
X
Xvoid cleanup_module(void) 
X{
X  int i;
X
X  for (i = 0; i < MAX_ADDR_LEN; i++) {
X    the_dev->dev_addr[i] = (unsigned char)old_addr[i];
X  }
X  printk("Just stopped spoofing hardware address\n");
X}
X
SHAR_EOF
  : || echo 'restore of scrap.c failed'
fi
exit 0
 
 
