From 52c07ddc355a3415ac31a4106334098e336a5890 Mon Sep 17 00:00:00 2001 From: Tomas Hoger Date: Fri, 12 Apr 2013 22:03:02 +0200 Subject: [PATCH] Only use BIA option when setting fully random MAC macchanger 1.6.0 added -b / --bia option to control whether locally administered bit should be set on the randomly generated MACs. If this option is specified, locally administered bit is cleared, and it's set otherwise. This option is considered when generating fully random MAC (-r / --random), but also when setting random vendor MACs (-e / --endding, -a / --another, -A). As locally administered bit is part of the first MAC octet, which is part of OUI, clearing the bit (default behaviour when -b is not used) breaks all these random vendor MAC modes, setting MACs that are not for any recognized vendor. This fixes makes macchanger set or unset locally administered bit when generating fully random MAC. Use of --bia option in combination with other option than --random generates warning. Upstream bug report: https://github.com/alobbs/macchanger/issues/1 --- doc/macchanger.texi | 4 ++-- macchanger.1 | 3 ++- src/main.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/macchanger.texi b/doc/macchanger.texi index b48d151..77595aa 100644 --- a/doc/macchanger.texi +++ b/doc/macchanger.texi @@ -154,8 +154,8 @@ print only vendor that matches the string. @cindex @code{-b} @itemx --bia @cindex @code{--bia} -Pretend to be a burned-in-address. If not used, the MAC will have the -locally-administered bit set. +When setting fully random MAC pretend to be a burned-in-address. If not used, +the MAC will have the locally-administered bit set. @item -m @cindex @code{-m} diff --git a/macchanger.1 b/macchanger.1 index 525d44f..442b2c5 100644 --- a/macchanger.1 +++ b/macchanger.1 @@ -67,7 +67,8 @@ Reset MAC address to its original, permanent hardware value. Print known vendors (with keyword in the vendor's description string). .TP .B \-b, \-\-bia -Pretend to be a burned-in-address. If not used, the MAC will have the locally-administered bit set. +When setting fully random MAC pretend to be a burned-in-address. If not used, +the MAC will have the locally-administered bit set. .TP .B \-m, \-\-mac XX:XX:XX:XX:XX:XX, \-\-mac=XX:XX:XX:XX:XX:XX Set the MAC XX:XX:XX:XX:XX:XX. diff --git a/src/main.c b/src/main.c index d6c757d..1117cb4 100644 --- a/src/main.c +++ b/src/main.c @@ -217,13 +217,18 @@ main (int argc, char *argv[]) /* Seed a random number generator */ random_seed(); - /* Read the MAC */ + /* Read the MAC */ if ((net = mc_net_info_new(device_name)) == NULL) { exit (EXIT_ERROR); } mac = mc_net_info_get_mac(net); mac_permanent = mc_net_info_get_permanent_mac(net); + /* --bia can only be used with --random */ + if (set_bia && !random) { + fprintf (stderr, "[WARNING] Ignoring --bia option that can only be used with --random\n"); + } + /* Print the current MAC info */ print_mac ("Current MAC: ", mac); print_mac ("Permanent MAC: ", mac_permanent); @@ -240,14 +245,14 @@ main (int argc, char *argv[]) } else if (random) { mc_mac_random (mac_faked, 6, set_bia); } else if (ending) { - mc_mac_random (mac_faked, 3, set_bia); + mc_mac_random (mac_faked, 3, 1); } else if (another_same) { val = mc_maclist_is_wireless (mac); mc_maclist_set_random_vendor (mac_faked, val); - mc_mac_random (mac_faked, 3, set_bia); + mc_mac_random (mac_faked, 3, 1); } else if (another_any) { mc_maclist_set_random_vendor(mac_faked, mac_is_anykind); - mc_mac_random (mac_faked, 3, set_bia); + mc_mac_random (mac_faked, 3, 1); } else if (permanent) { mac_faked = mc_mac_dup (mac_permanent); } else {