Mac MACSpoof is a Mac utility that allows the user to change the MAC address of the network interfaces of your Mac (Ethernet, Wi-Fi and so on) with any custom value. Mac MACSpoof screenshots - click image to zoom. I give permission for Macbeth Trailer Project to use this video on their channel.Group Members: Isaac O'Brien, Kyle Hickin, Caitlyn Conley, Zach LescalleetTe.
Jason, CEO/Lead Engineer JNETechnologies. FMR--USAF Special Operations Command at A.F. Information Warfare Center FL, NV.. Simply put, I assign a =<0.0 value to any 'Trace' objectives. If attempting to spoof BIG BROTHER, know this value. Mac ID Properties Emulation and Manipulation (MIPEN), my pen, abilities would NEVER exist if we did not conceive it. Further, I heard a story, from a guy, went like this: Iraq was enriching an element via centrifugal methods. There was a software CDD. This PCUI directly accessed and modulated a DCM which had had it's and 3217 of it's partner's MAC ID modified. Guess what? Found first round. Then deployit.exe. I can untangle ANY EMI's at will with a single (GOV) snap-in.FYI
There are three pieces of libvirt functionality which do network filtering of some type.
At a high level they are:
- The virtual network driver
This provides an isolated bridge device (ie no physical NICs attached). Guest TAP devices are attached to this bridge. Guests can talk to each other and the host, and optionally the wider world. - The QEMU driver MAC filtering
This provides a generic filtering of MAC addresses to prevent the guest spoofing its MAC address. This is mostly obsoleted by the next item, so won't be discussed further. - The network filter driver
This provides fully configurable, arbitrary network filtering of traffic on guest NICs. Generic rulesets are defined at the host level to control traffic in some manner. Rules sets are then associated with individual NICs of a guest. While not as expressive as directly using iptables/ebtables, this can still do nearly everything you would want to on a guest NIC filter.
The typical configuration for guests is to use bridging of the physical NIC on the host to connect the guest directly to the LAN. In RHEL6 there is also the possibility of using macvtap/sr-iov and VEPA connectivity. None of this stuff plays nicely with wireless NICs, since they will typically silently drop any traffic with a MAC address that doesn't match that of the physical NIC.
Thus the virtual network driver in libvirt was invented. This takes the form of an isolated bridge device (ie one with no physical NICs attached). The TAP devices associated with the guest NICs are attached to the bridge device. This immediately allows guests on a single host to talk to each other and to the host OS (modulo host IPtables rules).
libvirt then uses iptables to control what further connectivity is available. There are three configurations possible for a virtual network at time of writing:
- isolated: all off-node traffic is completely blocked
- nat: outbound traffic to the LAN is allowed, but MASQUERADED
- forward: outbound traffic to the LAN is allowed
The latter 'forward' case requires the virtual network be on a separate sub-net from the main LAN, and that the LAN admin has configured routing for this subnet. In the future we intend to add support for IP subnetting and/or proxy-arp. This allows for the virtual network to use the same subnet as the main LAN and should avoid need for the LAN admin to configure special routing.
Libvirt will optionally also provide DHCP services to the virtual network using DNSMASQ. In all cases, we need to allow DNS/DHCP queries to the host OS. Since we can't predict whether the host firewall setup is already allowing this, we insert 4 rules into the head of the INPUT chain
Note we have restricted our rules to just the bridge associated with the virtual network, to avoid opening undesirable holes in the host firewall wrt the LAN/WAN.
The next rules depend on the type of connectivity allowed, and go in the main FORWARD chain:
- type=isolated
Allow traffic between guests. Deny inbound. Deny outbound. - type=nat
Allow inbound related to an established connection. Allowoutbound, but only from our expected subnet. Allow trafficbetween guests. Deny all other inbound. Deny all other outbound. - type=routed
Allow inbound, but only to our expected subnet. Allowoutbound, but only from our expected subnet. Allow trafficbetween guests. Deny all other inbound. Deny all other outbound. - Finally, with type=nat, there is also an entry in the POSTROUTINGchain to apply masquerading:
If firewalld is active on the host, libvirt will attempt to place the bridge interface of a libvirt virtual network into the firewalld zone named 'libvirt' (thus making all guest->host traffic on that network subject to the rules of the 'libvirt' zone). This is done because, if firewalld is using its nftables backend (available since firewalld 0.6.0) the default firewalld zone (which would be used if libvirt didn't explicitly set the zone) prevents forwarding traffic from guests through the bridge, as well as preventing DHCP, DNS, and most other traffic from guests to host. The zone named 'libvirt' is installed into the firewalld configuration by libvirt (not by firewalld), and allows forwarded traffic through the bridge as well as DHCP, DNS, TFTP, and SSH traffic to the host - depending on firewalld's backend this will be implemented via either iptables or nftables rules. libvirt's own rules outlined above will *always* be iptables rules regardless of which backend is in use by firewalld.
NB: It is possible to manually set the firewalld zone for a network's interface with the 'zone' attribute of the network's 'bridge' element.
NB: Prior to libvirt 5.1.0, the firewalld 'libvirt' zone did not exist, and prior to firewalld 0.7.0 a feature crucial to making the 'libvirt' zone operate properly (rich rule priority settings) was not implemented in firewalld. In cases where one or the other of the two packages is missing the necessary functionality, it's still possible to have functional guest networking by setting the firewalld backend to 'iptables' (in firewalld prior to 0.6.0, this was the only backend available).
This driver provides a fully configurable network filtering capability that leverages ebtables, iptables and ip6tables. This was written by the libvirt guys at IBM and although its XML schema is defined by libvirt, the conceptual model is closely aligned with the DMTF CIM schema for network filtering:
The filters are managed in libvirt as a top level, standalone object. This allows the filters to then be referenced by any libvirt object that requires their functionality, instead tying them only to use by guest NICs. In the current implementation, filters can be associated with individual guest NICs via the libvirt domain XML format. In the future we might allow filters to be associated with the virtual network objects. Further we're expecting to define a new 'virtual switch' object to remove the complexity of configuring bridge/sriov/vepa networking modes. This make also end up making use of network filters.
There are a new set of virsh commands for managing network filters:
- virsh nwfilter-define
define or update a network filter from an XML file - virsh nwfilter-undefine
undefine a network filter - virsh nwfilter-dumpxml
network filter information in XML - virsh nwfilter-list
list network filters - virsh nwfilter-edit
edit XML configuration for a network filter
There are equivalently named C APIs for each of these commands.
As with all objects libvirt manages, network filters are configuredusing an XML format. At a high level the format looks like this:
Every filter has a name and UUID which serve as unique identifiers. A filter can have zero-or-more <rule>
elements which are used to actually define network controls. Filters can be arranged into a DAG, so zero-or-more <filterref/>
elements are also allowed. Cycles in the graph are not allowed.
The <rule>
element is where all the interesting stuff happens. It has three attributes, an action, a traffic direction and an optional priority. E.g.:
Within the rule there are a wide variety of elements allowed, which do protocol specific matching. Supported protocols currently include mac
, arp
, rarp
, ip
, ipv6
, tcp/ip
, icmp/ip
, igmp/ip
, udp/ip
, udplite/ip
, esp/ip
, ah/ip
, sctp/ip
, tcp/ipv6
, icmp/ipv6
, igmp/ipv6
, udp/ipv6
, udplite/ipv6
, esp/ipv6
, ah/ipv6
, sctp/ipv6
. Each protocol defines what is valid inside the <rule> element. The general pattern though is:
So, eg a TCP protocol, matching ports 0-1023 would be expressed as:
Attributes can included references to variables defined by the object using the rule. So the guest XML format allows each NIC to have a MAC address and IP address defined. These are made available to filters via the variables $IP
and $MAC
.
So to define a filter that prevents IP address spoofing we can simply match on source IP address != $IP
like this:
I'm not going to go into details on all the other protocol matches you can do, because it'll take far too much space. You can read about the options here.
Out of the box in RHEL6/Fedora rawhide, libvirt ships with a set of default useful rules:
Most of these are just building blocks. The interesting one here is 'clean-traffic'. This pulls together all the building blocks into one filter that you can then associate with a guest NIC. This stops the most common bad things a guest might try, IP spoofing, arp spoofing and MAC spoofing. To look at the rules for any of these just do:
They are all stored in /etc/libvirt/nwfilter
, but don't edit the files there directly. Use virsh nwfilter-define
to update them. This ensures the guests have their iptables/ebtables rules recreated.
To associate the clean-traffic filter with a guest, edit the guest XML config and change the <interface>
element to include a <filterref>
and also specify the <ip address/>
that the guest is allowed to use:
Mac Spoofing Apps
If no <ip address>
is included, the network filter driver will activate its 'learning mode'. This uses libpcap to snoop on network traffic the guest sends and attempts to identify the first IP address it uses. It then locks traffic to this address. Obviously this isn't entirely secure, but it does offer some protection against the guest being trojaned once up and running. In the future we intend to enhance the learning mode so that it looks for DHCPOFFERS from a trusted DHCP server and only allows the offered IP address to be used.
Now, how is all this implemented...?
The network filter driver uses a combination of ebtables, iptables and ip6tables, depending on which protocols are referenced in a filter. The out of the box 'clean-traffic' filter rules only require use of ebtables. If you want to do matching at tcp/udp/etc protocols (eg to add a new filter 'no-email-spamming' to block port 25), then iptables will also be used.
The driver attempts to keep its rules separate from those that the host admin might already have configured. So the first thing it does with ebtables, is to add two hooks in POSTROUTING and PREROUTING chains, to redirect traffic to custom chains. These hooks match on the TAP device name of the guest NIC, so they should not interact badly with any administrator defined rules:
To keep things manageable and easy to follow, the driver will then create further sub-chains for each protocol then it needs to match against:
Finally, here comes the actual implementation of the filters. This example shows the 'clean-traffic' filter implementation. I'm not going to explain what this is doing now. :-)
NB, we would have liked to include the prefix 'libvirt-' in all of our chain names, but unfortunately the kernel limits names to a very short maximum length. So only the first two custom chains can include that prefix. The others just include the TAP device name + protocol name.
If I define a new filter 'no-spamming' and then add this to the 'clean-traffic' filter, I can illustrate how iptables usage works:
...add <filterref filter='no-spamming'/>
All active guests immediately have their iptables/ebtables rules rebuilt.
The network filter driver deals with iptables in a very similar way. First it separates out its rules from those the admin may have defined, by adding a couple of hooks into the INPUT/FORWARD chains:
These custom chains then do matching based on the TAP device name, so they won't open holes in the admin defined matches for the LAN/WAN (if any).
Finally, we can see the interesting bit which is the actual implementation of my filter to block port 25 access:
Mac Spoofing
One thing in looking at this you may notice is that if there are many guests all using the same filters, we will be duplicating the iptables rules over and over for each guest. This is merely a limitation of the current rules engine implementation. At the libvirt object modelling level you can clearly see we've designed the model so filter rules are defined in one place, and indirectly referenced by guests. Thus it should be possible to change the implementation in the future so we can share the actual iptables/ebtables rules for each guest to create a more scalable system. The stuff in current libvirt is more or less the very first working implementation we've had of this, so there's not been much optimization work done yet.
Also notice that at the XML level we don't expose the fact we are using iptables or ebtables at all. The rule definition is done in terms of network protocols. Thus if we ever find a need, we could plug in an alternative implementation that calls out to a different firewall implementation instead of ebtables/iptables (providing that implementation was suitably expressive of course)
Finally, in terms of problems we have in deployment. The biggest problem is that if the admin does service iptables restart
all our work gets blown away. We've experimented with using lokkit to record our custom rules in a persistent config file, but that caused different problem. Admins who were not using lokkit for their config found that all their own rules got blown away. So we threw away our lokkit code. Instead we document that if you run service iptables restart
, you need to send SIGHUP to libvirt to make it recreate its rules.
Mac Spoof App
More in depth documentation on this is here.