Skip to content

Commit

Permalink
Only use BIA option when setting fully random MAC
Browse files Browse the repository at this point in the history
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:
#1
  • Loading branch information
thoger-rh committed Apr 12, 2013
1 parent d93794a commit 52c07dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/macchanger.texi
Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion macchanger.1
Expand Up @@ -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.
Expand Down
13 changes: 9 additions & 4 deletions src/main.c
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 52c07dd

Please sign in to comment.