what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

BKtclipabdc.c

BKtclipabdc.c
Posted Aug 14, 2000
Authored by Bikappa

BKtclipabdc.c is a tool to change the mac address of your ethernet device. It doesn't change the hardware address, but just the stack implementation of it.

systems | unix
SHA-256 | f8bd82cad3394a8e8ffbbce3e28b60bcb00bff580ed81044a67a2b1a2e664187

BKtclipabdc.c

Change Mirror Download
/*
* _/_/_/ _/ _/ _/ _/ _/_/_/ _/_/_/ _/
* _/ _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/_/
* _/_/_/_/ _/ _/_/ _/ _/ _/_/_/ _/_/_/ _/ _/
* _/ _/ _/ _/ _/ _/_/_/_/ _/ _/ _/_/_/_/
* _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/
*
*
* $Id: BKtclipabdc.c ,v 9.9 2000/03/18 12:11:09 l0wlevel Exp $
*
* BKtrpibdc.c - Network tool for change local mac address
* Based on Amua Library - Arp&Mac:Use&Abuse
* Coded on a Redbug 5.0+1.0
* Tools used: vi,gcc,ifconfig
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Copyright (c) 2000 bikappa <bikappa@itapac.net> [l0wlevel]
* All rights reserved.
*
*/


#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

u_char mac_address[6] =
{
0xd0,
0xd0,
0xd0,
0xd0,
0xd0,
0xd0
};

void info()
{
printf("\n Based on Amua Library - Arp&Mac:Use&Abuse\n");
printf("\n This tool change mac address to your ethernet device\n");
printf(" It doesn't change the hardware address, but just the\n");
printf(" stack implementation of it.\n");
printf(" The device must be down. (ifconfig eth$ down)\n\n");
printf(" Copyright (C) 2000 by bikappa <bikappa@itapac.net> [l0wlevel]\n\n");
}

void usage(char * arg)
{
printf("\n BKtclipabdc - Copyright (C) 2000 by bikappa [l0wlevel]\n");
printf(" This tool permit to change your ethernet's MAC address \n\n");
printf(" usage: %s <-i> <-r | -a> \n\n", arg);
printf(" -i info print info about this tool \n");
printf(" -d device number of ethernet device (0 for eth0) \n");
printf(" -r random random address \n");
printf(" -a address set the address \n\n");
}

void print_mac_address(int c,char *arg)
{
for (c = 0; c < 6; c++)
printf("%X ", c[arg] & 0xff);
printf("*\n");
}

void change_mac_address (unsigned char *mac_add, char *ethernet_device)
{
struct ifreq devea;
int socket_chk, i;

socket_chk = socket(AF_INET, SOCK_DGRAM, 0);
if (socket_chk < 0)
{
perror("Socket error");
exit(1);
}

sprintf(devea.ifr_name, "%s", ethernet_device);

if (ioctl(socket_chk, SIOCGIFHWADDR, &devea) < 0)
{
perror(devea.ifr_name);
exit(1);
}

printf("\n *************************************************\n");
printf(" * The current MAC address is: ");
print_mac_address(i,devea.ifr_hwaddr.sa_data);

for(i = 0; i < 6; i++)
i[devea.ifr_hwaddr.sa_data] = i[mac_add];

printf(" * It Changing MAC address to: ");
for (i = 0; i < 6; i++)
printf("%X ", i[mac_add] & 0xff);
printf("*\n");

if (ioctl(socket_chk,SIOCSIFHWADDR,&devea) < 0)
{
printf("\n The %s device must be down\n", ethernet_device);
perror(devea.ifr_name);
exit(1);
}

printf(" * The MAC address is correctly changed *\n");

if (ioctl(socket_chk, SIOCGIFHWADDR, &devea) < 0)
{
perror(devea.ifr_name);
exit(1);
}

printf(" * The setted MAC address is: ");
print_mac_address(i,devea.ifr_hwaddr.sa_data);
printf(" *************************************************\n\n");
close(socket_chk);
}

void set_random_mac_address (char *mac_add)
{
int i;

for(i = 0; i < 6; i++)
i[mac_add] = random() % 256;
}

void set_address (char *mac, char *mac_add)
{
unsigned int temp[6];
int i;

if (sscanf (mac, "%2x:%2x:%2x:%2x:%2x:%2x",
&temp[0], &temp[1], &temp[2], &temp[3], &temp[4], &temp[5]) != 6)
{
printf("The address format is not correct\n");
exit(0);
}

for(i = 0; i < 6; i++)
i[mac_add] = temp[i];
}

int main(int argc, char ** argv)
{
char c;
char *ethernet_device = "eth0";

int
count_1 = 0,
count_2 = 0;

extern char *optarg;

if (argc == 1)
{
usage(argv[0]);
exit(1);
}

while ((c = getopt(argc, argv, "-ira:d:")) != EOF)
{
switch(c)
{
case 'i' :
info();
exit(1);
case 'r' :
count_1++;
set_random_mac_address(mac_address);
break;
case 'a' :
count_1++;
set_address(optarg,mac_address);
break;
case 'd' :
count_2++;
ethernet_device = optarg;
break;
}

if (count_1 > 1 || count_2 > 1)
{
printf("Bad options\n");
exit(1);
}
}
change_mac_address(mac_address,ethernet_device);
return (0);
}
Login or Register to add favorites

File Archive:

December 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Dec 1st
    0 Files
  • 2
    Dec 2nd
    41 Files
  • 3
    Dec 3rd
    0 Files
  • 4
    Dec 4th
    0 Files
  • 5
    Dec 5th
    0 Files
  • 6
    Dec 6th
    0 Files
  • 7
    Dec 7th
    0 Files
  • 8
    Dec 8th
    0 Files
  • 9
    Dec 9th
    0 Files
  • 10
    Dec 10th
    0 Files
  • 11
    Dec 11th
    0 Files
  • 12
    Dec 12th
    0 Files
  • 13
    Dec 13th
    0 Files
  • 14
    Dec 14th
    0 Files
  • 15
    Dec 15th
    0 Files
  • 16
    Dec 16th
    0 Files
  • 17
    Dec 17th
    0 Files
  • 18
    Dec 18th
    0 Files
  • 19
    Dec 19th
    0 Files
  • 20
    Dec 20th
    0 Files
  • 21
    Dec 21st
    0 Files
  • 22
    Dec 22nd
    0 Files
  • 23
    Dec 23rd
    0 Files
  • 24
    Dec 24th
    0 Files
  • 25
    Dec 25th
    0 Files
  • 26
    Dec 26th
    0 Files
  • 27
    Dec 27th
    0 Files
  • 28
    Dec 28th
    0 Files
  • 29
    Dec 29th
    0 Files
  • 30
    Dec 30th
    0 Files
  • 31
    Dec 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close