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:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    8 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    17 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    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