Date: Fri, 03 Oct 2014 08:37:49 -0400 From: "John Ten" <ritanopi@eclipso.ch> To: <freebsd-ports-bugs@freebsd.org> Subject: Re: ports/187363: [new port][net/macchanger] GNU macchanger port for the FreeBSD system Message-ID: <5618e56da225038b1fd86b91015f8f60@mail.eclipso.de> In-Reply-To: <201932d5b6ec7b5fa73f925b85fcef6b@mail.eclipso.de> References: <201932d5b6ec7b5fa73f925b85fcef6b@mail.eclipso.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Sorry, the command is: sysctl dev.XX.Y.nvm=1 sysctl dev.XX.Y.debug=1 :) Regards --- Ursprüngliche Nachricht --- Von: "John Ten" <ritanopi@eclipso.ch> Datum: 03.10.2014 08:22:52 An: <freebsd-ports-bugs@freebsd.org> Betreff: ports/187363: [new port][net/macchanger] GNU macchanger port for the FreeBSD system > Sorry, I don't know how to reply to a thread so I guess this will do. > > Anyway, this port lacks the "-p" option, basically getting the > original > NIC MAC address. It seems it's a bit harder on BSD, since there's no > ethtool, still > > ethtool -P doesn't work on my system, it shows me the cloned mac, not > > the original one. Anyway on BSD this can be achieved by doing two > things: > > 1. using sysctl.XX.Y.nvm=1 (on newer bsd) or sysctl.XX.Y.debug=1 on > older ones (thanks Jeremy Chadwick) to do an EEPROM dump, where XXX is > > interface name (e.g. em), and Y is the number(e.g. 0) > > 2. inspecting the output of dmesg, /var/log/messages specifically the > > first line, that is the original/permanent MAC of the NIC (tested also > > on VirtualBox) > > I am sure there is a better way to find this out, but syslog source > needs to be inspected and such and it's gonna take some time, just > wanted to point the author in the right direction. > > Regards > >Number: 187363 > >Category: ports > >Synopsis: [new port][net/macchanger] GNU macchanger port for the > FreeBSD > system > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-ports-bugs > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: change-request > >Submitter-Id: current-users > >Arrival-Date: Sat Mar 08 08:30:00 UTC 2014 > >Closed-Date: > >Last-Modified: > >Originator: clutton > >Release: > >Organization: > >Environment: > >Description: > GNU macchanger is a good tool because of it's mac's addresses database. > > The pool request [1]https://github.com/alobbs/macchanger/pull/9 > > I hope patches will be accepted in new versions, for now I'd like to start > by pr > oviding a working version. > > One feature was commented, because I don't know how to implement it now... > > >How-To-Repeat: > > >Fix: > > > Patch attached with submission follows: > > # This is a shell archive. Save it in a file, remove anything before > # this line, and then unpack it by entering "sh file". Note, it > may > # create directories; files and directories will be owned by you and > # have default permissions. > # > # This archive contains: > # > # macchanger > # macchanger/pkg-plist > # macchanger/files > # macchanger/files/patch-src_netinfo.h > # macchanger/files/patch-src_netinfo.c > # macchanger/files/patch-src_main.c > # macchanger/Makefile > # macchanger/distinfo > # macchanger/pkg-descr > # > echo c - macchanger > mkdir -p macchanger > /dev/null 2>&1 > echo x - macchanger/pkg-plist > sed 's/^X//' >macchanger/pkg-plist << 'd03b69c5dadd960b1ea1d2397b6ac821' > > Xbin/macchanger > Xman/man1/macchanger.1.gz > X%%DATADIR%%/OUI.list > X%%DATADIR%%/wireless.list > [2]X at dirrmtry %%DATADIR%% > d03b69c5dadd960b1ea1d2397b6ac821 > echo c - macchanger/files > mkdir -p macchanger/files > /dev/null 2>&1 > echo x - macchanger/files/patch-src_netinfo.h > sed 's/^X//' >macchanger/files/patch-src_netinfo.h << 'cb21b643c2b0f08fdb9e24dc4 > > 956a846' > X--- src/netinfo.h 2013-03-17 00:54:41.000000000 +0200 > X+++ src/netinfo.h 2014-03-08 07:14:58.334245891 +0200 > X@@ -30,6 +30,17 @@ > X #include <net/if.h> > X #include "mac.h" > X > X+#ifdef __linux__ > X+#define sockaddr_dl sockaddr_ll > X+#define sdl_family sll_family > X+#define AF_LINK AF_PACKET > X+#define LLADDR(s) s->sll_addr; > X+#endif > X+ > X+#ifdef __FreeBSD__ > X+#define SIOCSIFHWADDR SIOCSIFLLADDR > X+#endif > X+ > X typedef struct { > X int sock; > X struct ifreq dev; > cb21b643c2b0f08fdb9e24dc4956a846 > echo x - macchanger/files/patch-src_netinfo.c > sed 's/^X//' >macchanger/files/patch-src_netinfo.c << '6698a3f09c341f61778b29439 > > b1b7d42' > X--- src/netinfo.c 2013-03-17 00:56:37.000000000 +0200 > X+++ src/netinfo.c 2014-03-08 07:03:30.388297174 +0200 > X@@ -29,8 +29,17 @@ > X #include <unistd.h> > X #include <sys/ioctl.h> > X > X-#include <linux/ethtool.h> > X-#include <linux/sockios.h> > X+#if defined(__linux__) > X+# include <linux/ethtool.h> > X+# include <linux/sockios.h> > X+#elif defined(__FreeBSD__) > X+# include <net/if.h> > X+# include <net/if_dl.h> > X+# include <net/if_var.h> > X+# include <net/if_types.h> > X+# include <net/ethernet.h> > X+# include <ifaddrs.h> > X+#endif > X > X #include "netinfo.h" > X > X@@ -47,8 +56,9 @@ > X return NULL; > X } > X > X- strcpy (new->dev.ifr_name, device); > X- if (ioctl(new->sock, SIOCGIFHWADDR, &new->dev) < 0) > { > X+ strncpy (new->dev.ifr_name, device, sizeof(new->dev.ifr_name)); > > X+ new->dev.ifr_name[sizeof(new->dev.ifr_name)-1] = '\0'; > X+ if (if_nametoindex(device) == 0) { > X perror ("[ERROR] Set device name"); > X free(new); > X return NULL; > X@@ -65,31 +75,56 @@ > X free(net); > X } > X > X- > X mac_t * > X mc_net_info_get_mac (const net_info_t *net) > X { > X- int i; > X- mac_t *new = (mac_t *) malloc (sizeof(mac_t)); > X+ int i; > X+ mac_t *mac = (mac_t *) malloc (sizeof(mac_t)); > X+ u_char *lladr; > X > X- for (i=0; i<6; i++) { > X- new->byte[i] = net->dev.ifr_hwaddr.sa_data[i] & > 0xFF; > X- } > X+ struct ifaddrs *ifap, *ifa; > X+ struct sockaddr_dl *sdl; > X > X- return new; > X-} > X+ if (getifaddrs(&ifap) == 0) { > X+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { > X+ > X+ sdl = (struct sockaddr_dl *) ifa->ifa_addr; > X > X+ if (strcmp(ifa->ifa_name, net->dev.ifr_name) > != 0) > X+ continue; > X+ > X+ if (!sdl && sdl->sdl_family != AF_LINK) > > X+ continue; > X+ > X+ lladr = (u_char *) LLADDR(sdl); > X+ for (i=0; i<6; i++) > X+ mac->byte[i] = lladr[i] & 0xFF; > X+ break; > X+ } > X+ freeifaddrs(ifap); > X+ } else > X+ perror("getifaddrs"); > X+ > X+ return mac; > X+} > X > X int > X mc_net_info_set_mac (net_info_t *net, const mac_t *mac) > X { > X int i; > X+#if defined(__FreeBSD__) > X+ net->dev.ifr_addr.sa_family = AF_LINK; > X+ net->dev.ifr_addr.sa_len = ETHER_ADDR_LEN; > X+#endif > X > X- for (i=0; i<6; i++) { > X+ for (i=0; i<6; i++) > X+#if defined(__linux__) > X net->dev.ifr_hwaddr.sa_data[i] = mac->byte[i]; > X- } > X+#elif defined(__FreeBSD__) > X+ net->dev.ifr_addr.sa_data[i] = mac->byte[i]; > X+#endif > X > X- if (ioctl(net->sock, SIOCSIFHWADDR, &net->dev) < 0) > { > X+ if (ioctl(net->sock, SIOCSIFHWADDR, &net->dev) == -1) { > > X perror ("[ERROR] Could not change MAC: interface up > or insuffici > ent permissions"); > X return -1; > X } > X@@ -97,6 +132,7 @@ > X return 0; > X } > X > X+#if defined(__linux__) > X mac_t * > X mc_net_info_get_permanent_mac (const net_info_t *net) > X { > X@@ -125,3 +161,4 @@ > X free(epa); > X return newmac; > X } > X+#endif > 6698a3f09c341f61778b29439b1b7d42 > echo x - macchanger/files/patch-src_main.c > sed 's/^X//' >macchanger/files/patch-src_main.c << '3805d61673e2a7a097c57875d5c3 > > 8ba9' > X--- src/main.c 2013-03-17 00:57:41.000000000 +0200 > X+++ src/main.c 2014-03-08 06:42:36.021380219 +0200 > X@@ -40,9 +40,6 @@ > X #include "maclist.h" > X #include "netinfo.h" > X > X-#define EXIT_OK 0 > X-#define EXIT_ERROR 1 > X- > X static void > X print_help (void) > X { > X@@ -51,10 +48,12 @@ > X " -h, --help Print this help\n" > > X " -V, --version Print version and exit\n" > > X " -s, --show Print the MAC address > and exit\ > n" > X- " -e, --endding Don't change the vendor > bytes\n > " > X+ " -e, --ending Don't change the vendor > bytes\n > " > X " -a, --another Set random vendor MAC > of the sa > me kind\n" > X " -A Set random vendor MAC > of any ki > nd\n" > X+#ifdef __linux__ > X " -p, --permanent Reset to original, > permanent ha > rdware MAC\n" > X+#endif > X " -r, --random Set fully random MAC\n" > > X " -l, --list[=keyword] Print known vendors\n" > > X " -b, --bia Pretend to be a burned-in-addre > > ss\n" > X@@ -94,8 +93,9 @@ > X struct timeval tv; > X unsigned int seed; > X > X- if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 || > X- (fd = open("/dev/random", O_RDONLY)) >= 0) > X+ if ((fd = open("/dev/hwrng", O_RDONLY)) >= 0 || > X+ (fd = open("/dev/random", O_RDONLY)) >= 0 || > X+ (fd = open("/dev/urandom", O_RDONLY)) >= 0) > X { > X read (fd, &seed, sizeof(seed)); > X close (fd); > X@@ -112,10 +112,12 @@ > X main (int argc, char *argv[]) > X { > X char random = 0; > X- char endding = 0; > X+ char ending = 0; > X char another_any = 0; > X char another_same = 0; > X+#ifdef __linux__ > X char permanent = 0; > X+#endif > X char print_list = 0; > X char show = 0; > X char set_bia = 0; > X@@ -127,9 +129,12 @@ > X {"help", no_argument, NULL, 'h'}, > > X {"version", no_argument, NULL, 'V'}, > > X {"random", no_argument, NULL, 'r'}, > > X- {"endding", no_argument, NULL, 'e'}, > > X+ {"ending", no_argument, NULL, 'e'}, > > X+ {"endding", no_argument, NULL, 'e'}, > /* kept for backw > ards compatibility */ > X {"another", no_argument, NULL, 'a'}, > > X+#ifdef __linux__ > X {"permanent", no_argument, NULL, 'p'}, > > X+#endif > X {"show", no_argument, NULL, 's'}, > > X {"another_any", no_argument, NULL, 'A'}, > > X {"bia", no_argument, NULL, 'b'}, > > X@@ -140,7 +145,9 @@ > X > X net_info_t *net; > X mac_t *mac; > X+#ifdef __linux__ > X mac_t *mac_permanent; > X+#endif > X mac_t *mac_faked; > X char *device_name; > X int val; > X@@ -156,7 +163,7 @@ > X "This is free software; see the source > for copyi > ng conditions. There is NO\n" > X "warranty; not even for MERCHANTABILITY > or FITNE > SS FOR A PARTICULAR PURPOSE.\n", > X VERSION); > X- exit (EXIT_OK); > X+ exit (EXIT_SUCCESS); > X break; > X case 'l': > X print_list = 1; > X@@ -166,7 +173,7 @@ > X random = 1; > X break; > X case 'e': > X- endding = 1; > X+ ending = 1; > X break; > X case 'b': > X set_bia = 1; > X@@ -180,9 +187,11 @@ > X case 'A': > X another_any = 1; > X break; > X+#ifdef __linux__ > X case 'p': > X permanent = 1; > X break; > X+#endif > X case 'm': > X set_mac = optarg; > X break; > X@@ -190,67 +199,78 @@ > X case '?': > X default: > X print_help(); > X- exit (EXIT_OK); > X+ exit (EXIT_SUCCESS); > X break; > X } > X } > X > X /* Read the MAC lists */ > X if (mc_maclist_init() < 0) { > X- exit (EXIT_ERROR); > X+ exit (EXIT_FAILURE); > X } > X > X /* Print list? */ > X if (print_list) { > X mc_maclist_print(search_word); > X- exit (EXIT_OK); > X+ exit (EXIT_SUCCESS); > X } > X > X /* Get device name argument */ > X if (optind >= argc) { > X print_usage(); > X- exit (EXIT_OK); > X+ exit (EXIT_SUCCESS); > X } > X device_name = argv[optind]; > X > X /* Seed a random number generator */ > X random_seed(); > X > X- /* Read the MAC */ > X+ /* Read the MAC */ > X if ((net = mc_net_info_new(device_name)) == NULL) { > X- exit (EXIT_ERROR); > X+ exit (EXIT_FAILURE); > X } > X mac = mc_net_info_get_mac(net); > X+#ifdef __linux__ > X mac_permanent = mc_net_info_get_permanent_mac(net); > X+#endif > X+ > X+ /* --bia can only be used with --random */ > X+ if (set_bia && !random) { > X+ fprintf (stderr, "[WARNING] Ignoring --bia option that > can only > be used with --random\n"); > X+ } > X > X /* Print the current MAC info */ > X print_mac ("Current MAC: ", mac); > X+#ifdef __linux__ > X print_mac ("Permanent MAC: ", mac_permanent); > X+#endif > X > X /* Change the MAC */ > X mac_faked = mc_mac_dup (mac); > X > X if (show) { > X- exit (EXIT_OK); > X+ exit (EXIT_SUCCESS); > X } else if (set_mac) { > X if (mc_mac_read_string (mac_faked, set_mac) < 0) { > X- exit (EXIT_ERROR); > X+ exit (EXIT_FAILURE); > X } > X } else if (random) { > X mc_mac_random (mac_faked, 6, set_bia); > X- } else if (endding) { > X- mc_mac_random (mac_faked, 3, set_bia); > X+ } else if (ending) { > X+ mc_mac_random (mac_faked, 3, 1); > X } else if (another_same) { > X val = mc_maclist_is_wireless (mac); > X mc_maclist_set_random_vendor (mac_faked, val); > X- mc_mac_random (mac_faked, 3, set_bia); > X+ mc_mac_random (mac_faked, 3, 1); > X } else if (another_any) { > X mc_maclist_set_random_vendor(mac_faked, mac_is_anykind); > > X- mc_mac_random (mac_faked, 3, set_bia); > X+ mc_mac_random (mac_faked, 3, 1); > X+#ifdef __linux__ > X } else if (permanent) { > X mac_faked = mc_mac_dup (mac_permanent); > X+#endif > X } else { > X- mc_mac_next (mac_faked); > X+ exit (EXIT_SUCCESS); /* default to show */ > X } > X > X /* Set the new MAC */ > X@@ -272,9 +292,11 @@ > X /* Memory free */ > X mc_mac_free (mac); > X mc_mac_free (mac_faked); > X+#ifdef __linux__ > X mc_mac_free (mac_permanent); > X+#endif > X mc_net_info_free (net); > X mc_maclist_free(); > X > X- return (ret == 0) ? EXIT_OK : EXIT_ERROR; > X+ return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; > X } > 3805d61673e2a7a097c57875d5c38ba9 > echo x - macchanger/Makefile > sed 's/^X//' >macchanger/Makefile << '3a74b2cc6a0f2b8b8b8e28da5443e260' > > X# $FreeBSD$ > X > XPORTNAME= macchanger > XPORTVERSION= 1.6.0 > XCATEGORIES= net > XMASTER_SITES= GNU > X > XMAINTAINER= [3]clutton at zoho.com > XCOMMENT= GNU MAC Changer > X > XLICENSE= GPLv3 > X > XGNU_CONFIGURE= yes > X > XINFO= macchanger > X > X.include <bsd.port.mk> > 3a74b2cc6a0f2b8b8b8e28da5443e260 > echo x - macchanger/distinfo > sed 's/^X//' >macchanger/distinfo << '614a08e9cf0867f64ce5227faaa18894' > > XSHA256 (macchanger-1.6.0.tar.gz) = 31534f138f1d21fa247be74ba6bef3fbfa47bbcd5033 > > e99bd10c432fe58e51f7 > XSIZE (macchanger-1.6.0.tar.gz) = 352061 > 614a08e9cf0867f64ce5227faaa18894 > echo x - macchanger/pkg-descr > sed 's/^X//' >macchanger/pkg-descr << '23d5d0fdb10e0c2778a645d256385f23' > > XGNU MAC Changer is an utility that makes the maniputation of MAC addresses > of > Xnetwork interfaces easier. > X > XWWW: [4]http://www.gnu.org/software/macchanger > 23d5d0fdb10e0c2778a645d256385f23 > exit > > > ---- > eclipso Freemail - Sicher, kostenlos, schnell! > [5]https://www.eclipso.ch > > References > > 1. https://github.com/alobbs/macchanger/pull/9 > 2. http://lists.freebsd.org/mailman/listinfo/freebsd-ports-bugs > 3. http://lists.freebsd.org/mailman/listinfo/freebsd-ports-bugs > 4. http://www.gnu.org/software/macchanger > 5. https://www.eclipso.ch/ > _______________________________________________ > freebsd-ports-bugs@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-ports-bugs > To unsubscribe, send any mail to "freebsd-ports-bugs-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5618e56da225038b1fd86b91015f8f60>