Ticket #352 (new enhancement)

Opened 3 months ago

Last modified 3 months ago

Function Addon: GetMulticastMAC()

Reported by: ffranz <ffranz@…> Owned by: pbi
Priority: major Milestone:
Component: Scapy Version: 2.0.0.x
Keywords: multicast, MAC, Addon, Volatile Cc:

Description

GetMulticastMAC()

This function provides a MAC address from the multicast MAC created by IANA. With a total of 66 111 possible MACs, the MAC can be random if the parameter is omitted or is zero. Also, you can obtain a MAC by index within the range 1-66111.For use in fuzzing probes.Develop in scapy-2.1.0.

Attached patch. More info: www.iniqua.com/labs

Examples: ...

/>>> print GetMulticastMAC(0)

ab:00:04:01:5e:43

/>>> help(GetMulticastMAC)

...

/>>> for i in range(66111): print GetMulticastMAC(i)

...

Cheers. ffranz.

Attachments

volatile.patch (5.0 KB) - added by ffranz <ffranz@…> 3 months ago.
Add GetMulticastMAC() to versatile.py

Change History

Changed 3 months ago by ffranz <ffranz@…>

Add GetMulticastMAC() to versatile.py

Changed 3 months ago by ffranz <ffranz@…>

multicastList = ["01:00:5E:00:00:00","01:00:5E:7F:FF:FF","01:00:5E:80:00:00", "01:00:5E:8F:FF:FF","01:00:5E:90:00:00","01:00:5E:FF:FF:FF","01:80:C2:00:00:00", "09:00:02:04:00:01","09:00:02:04:00:02","09:00:09:00:00:01","09:00:09:00:00:01", "09:00:09:00:00:04","09:00:1E:00:00:00","09:00:2B:00:00:00","09:00:2B:00:00:01", "09:00:2B:00:00:02","09:00:2B:00:00:03","09:00:2B:00:00:04","09:00:2B:00:00:05", "09:00:2B:00:00:06","09:00:2B:00:00:07","09:00:2B:00:00:0F","09:00:2B:00:00:10", "09:00:2B:00:00:11","09:00:2B:00:00:12","09:00:2B:00:00:13","09:00:2B:00:00:14", "09:00:2B:00:00:15","09:00:2B:00:00:16","09:00:2B:00:00:17","09:00:2B:00:00:18", "09:00:2B:00:00:19","09:00:2B:00:00:1A","09:00:2B:00:00:1B","09:00:2B:00:00:1C", "09:00:2B:00:00:1D","09:00:2B:00:00:1E","09:00:2B:00:00:1F","09:00:2B:01:00:00", "09:00:2B:01:00:01","09:00:2B:02:00:00","09:00:2B:02:01:00","09:00:2B:02:01:01", "09:00:2B:02:01:02","09:00:2B:04:00:00","09:00:2B:23:00:00","09:00:4E:00:00:02", "09:00:56:00:00:00","09:00:56:FE:FF:FF","09:00:56:FF:00:00","09:00:56:FF:FF:FF", "09:00:77:00:00:01","09:00:7C:02:00:05","09:00:7C:05:00:01","0D:1E:15:BA:DD:06", "AB:00:00:01:00:00","AB:00:00:02:00:00","AB:00:00:03:00:00","AB:00:00:04:00:00", "AB:00:00:05:00:00","AB:00:03:FF:FF:FF","AB:00:03:00:00:00","CF:00:00:00:00:00", "09:00:2B:03:xx:xx","AB:00:04:00:xx:xx","AB:00:04:01:xx:yy"]

class GetMulticastMAC(RandMAC):

""" ------------------------ GetMulticastMAC(Index) - For use in fuzzing probes. -------------------------------------------------- Get a multicast MAC from the list generated by IANA ( http://www.iana.org/assignments/ethernet-numbers) """ def init(self, Index=0):

self.randMac = None self.indexMac = None self.mac = () template = "ff:ff:ff:ff:ff:ff" if Index == 0:

rn = RandNum?(0,66111)

if 0 <= rn < 63:

self.randMac = multicastList[rn]

elif 63 <= rn < 319:

template = multicastList[63]

elif 319 <= rn < 575:

template = multicastList[64]

elif 575 <= rn < 66111:

template = multicastList[65] template = template.split(":")

for i in range(6):

if template[i] == "xx" and template[i-1] != "xx":

v = RandByte?()

elif template[i] == "xx" and template[i-1] == "xx":

v = v

elif template [i] == "yy":

v = RandByte?()

else:

v = int(template[i],16)

self.mac += (v,)

else:

if 0 <= Index < 63:

self.indexMac = multicastList[Index]

if 63 <= Index < 319:

template = multicastList[63] template = template.split(":") relativeIndex = Index - 63 for i in range(6):

if template[i] == "xx":

v = int(hex(relativeIndex).split('x')[1],16)

else:

v = int(template[i],16)

self.mac += (v,)

if 319 <= Index < 575:

template = multicastList[64] template = template.split(":") relativeIndex = Index - 319 for i in range(6):

if template[i] == "xx":

v = int(hex(relativeIndex).split('x')[1],16)

else:

v = int(template[i],16)

self.mac += (v,)

if 575 <= Index < 66111:

template = multicastList[65] relativeIndex = Index - 575 template = template.split(":") macof = str("%04X" % relativeIndex) for i in range(6):

if template[i] == "xx":

v = int(macof[0] + macof[1],16)

elif template[i] == "yy":

v = int(macof[2] + macof[3],16)

else:

v = int(template[i],16)

self.mac += (v,)

def _fix(self):

if self.randMac:

return self.randMac

elif self.indexMac:

return self.indexMac

else:

return "%02x:%02x:%02x:%02x:%02x:%02x" % self.mac

Add/Change #352 (Function Addon: GetMulticastMAC())

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from pbi. Next status will be 'new'
The owner will change from pbi to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.