diff --git a/scapy/volatile.py b/scapy/volatile.py index 9f7c03f2b9031d83a1aaf183c39b4631df1dff68..c49bb2c31b72c214715df05c84f52b0e711bcbe6 100644 --- a/scapy/volatile.py +++ b/scapy/volatile.py @@ -507,10 +507,19 @@ class RandSingString(RandSingularity): "foo.exe\\", ] - - - - +class RandPool(RandField): + def __init__(self, *args): + """Each parameter is a volatile object or a couple (volatile object, weight)""" + pool = [] + for p in args: + w = 1 + if type(p) is tuple: + p,w = p + pool += [p]*w + self._pool = pool + def _fix(self): + r = random.choice(self._pool) + return r._fix() # Automatic timestamp