diff -urNb scapy/volatile.py scapy/volatile.py --- scapy/volatile.py 2009-12-10 23:38:23.000000000 +0100 +++ scapy/volatile.py 2010-05-29 18:42:13.000000000 +0200 @@ -240,6 +240,115 @@ self.mac += (v,) def _fix(self): return "%02x:%02x:%02x:%02x:%02x:%02x" % self.mac +# +# ffranz@iniqua.com - www.iniqua.com +# GetMulticastMAC(Index) - For use in fuzzing probes. +# Based on iana.org multicast addresses list. + +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) + ''' An Ethernet multicast address consists of the multicast bit, the + 23-bit vendor component, and the 24-bit group identifier assigned by + the vendor. For example, DEC is assigned the vendor component + 08-00-2B, so multicast addresses assigned by DEC have the first + 24-bits 09-00-2B (since the multicast bit is the low-order bit of the + first byte, which is "the first bit on the wire").''' + + + Index can be zero or another number. + - If valor is zero script will generate a random number (default Index = 0). + - Use index to generate a secuecial list. + Example: + ... + >>> for i in range(66111): print GetMulticastMAC(i) + ... + >>> GetMulticastMAC() + ... + + +info: + www.iniqua.com/labs + """ + 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 = hex(relativeIndex).split('x')[1] + macof = str("%04X" % relativeIndex) + if len(macof) < 4: + macof = '0' + macof + 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 class RandIP6(RandString): def __init__(self, ip6template="**"):