alobbs / macchanger

GNU MAC Changer
http://www.gnu.org/software/macchanger
GNU General Public License v3.0
588 stars 112 forks source link

macchanger BIA option breaks other options #1

Closed thoger closed 11 years ago

thoger commented 11 years ago

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.

Examples:

# macchanger -e eth0
Current MAC:   00:00:0c:aa:bb:cc (Cisco Systems, Inc.)
Permanent MAC: ...
New MAC:       02:00:0c:a6:f7:9d (unknown)

# macchanger -a eth0
Current MAC:   00:00:0c:aa:bb:cc (Cisco Systems, Inc.)
Permanent MAC: ...
New MAC:       b6:04:18:e9:09:e5 (unknown)

# macchanger -A eth0
Current MAC:   00:00:0c:aa:bb:cc (Cisco Systems, Inc.)
Permanent MAC: ...
New MAC:       c2:12:42:50:67:a8 (unknown)

All of the above now require -b option to be specified to work correctly.

BIA command line option should only be honored when setting fully random MAC. All OUI / vendor MACs are expected to have locally administered bit cleared. Hence my fix is to call mc_mac_random() with set_bia set to 1 unconditionally when setting random vendor MAC. I've also added warning printed when -b is not used in conjunction with -r.

thoger commented 11 years ago

Suggested fix: https://github.com/thoger/macchanger/commit/52c07ddc355a3415ac31a4106334098e336a5890

alobbs commented 11 years ago

Merged. Thanks @thoger!