Пример #1
0
    def __init__(self,
                 environment_id=None,
                 correct_order=None,
                 fragsize=-1,
                 segment=True,
                 overlap=0):
        """
        Initializes a fragment action object.

        Args:
            environment_id (str, optional): Environment ID of the strategy this object is a part of
            correct_order (bool, optional): Whether or not the fragments/segments should be returned in the correct order
            fragsize (int, optional): The index this packet should be cut. Defaults to -1, which cuts it in half.
            segment (bool, optional): Whether we should perform fragmentation or segmentation
            overlap (int, optional): How many bytes the fragments/segments should overlap
        """
        Action.__init__(self, "fragment", "out")
        self.enabled = True
        self.branching = True
        self.terminal = False
        self.fragsize = fragsize
        self.segment = segment
        self.overlap = overlap
        if correct_order == None:
            self.correct_order = self.get_rand_order()
        else:
            self.correct_order = correct_order
Пример #2
0
    def __init__(self,
                 environment_id=None,
                 field=None,
                 tamper_type=None,
                 tamper_value=None,
                 tamper_proto="TCP"):
        """
        Creates a tamper object.

        Args:
            environment_id (str, optional): environment_id of a previously run strategy, used to find packet captures
            field (str, optional): field that the object will tamper. If not set, all the parameters are chosen randomly
            tamper_type (str, optional): primitive this tamper will use ("corrupt")
            tamper_value (str, optional): value to tamper to
            tamper_proto (str, optional): protocol we are tampering
        """
        Action.__init__(self, "tamper", "both")
        self.field = field
        self.tamper_value = tamper_value
        self.tamper_proto = actions.utils.string_to_protocol(tamper_proto)
        self.tamper_proto_str = tamper_proto

        self.tamper_type = tamper_type
        if not self.tamper_type:
            self._mutate_tamper_type()

        if not self.field:
            self._mutate(environment_id)
Пример #3
0
    def __init__(self, environment_id=None):
        """
        Initializes this drop action.

        Args:
            environment_id (str, optional): Environment ID of the strategy we are a part of
        """
        Action.__init__(self, "drop", "both")
        self.terminal = True
        self.branching = False
Пример #4
0
 def __init__(self, start_ttl=1, end_ttl=64, environment_id=None):
     Action.__init__(self, "trace", "out")
     self.terminal = True
     self.branching = False
     self.start_ttl = start_ttl
     self.end_ttl = end_ttl
     # Since running this action might take enough time that additional packets
     # get generated, only allow this action to run once
     self.ran = False
     # Define a socket
     self.socket = conf.L3socket(iface=actions.utils.get_interface())
Пример #5
0
 def __init__(self,
              environment_id=None,
              field=None,
              tamper_type=None,
              tamper_value=None,
              tamper_proto="TCP"):
     Action.__init__(self, "tamper", "both")
     self.field = field
     self.tamper_value = tamper_value
     self.tamper_proto = actions.utils.string_to_protocol(tamper_proto)
     self.tamper_proto_str = tamper_proto
     self.tamper_type = tamper_type
Пример #6
0
    def __init__(self, time=1, environment_id=None):
        """
        Initializes the sleep action.

        Args:
            time (float): How much time the packet should delay before sending
            environment_id (str, optional): Environment ID of the strategy this action is a part of
        """
        Action.__init__(self, "sleep", "out")
        self.terminal = False
        self.branching = False
        self.time = time
Пример #7
0
    def __init__(self,
                 environment_id=None,
                 field=None,
                 tamper_type=None,
                 tamper_value=None,
                 tamper_proto="TCP"):
        Action.__init__(self, "tamper", "both")
        self.field = field
        self.tamper_value = tamper_value
        self.tamper_proto = actions.utils.string_to_protocol(tamper_proto)
        self.tamper_proto_str = tamper_proto

        self.tamper_type = tamper_type
        if not self.tamper_type:
            self.tamper_type = random.choice(["corrupt", "replace"])
Пример #8
0
    def __init__(self, start_ttl=1, end_ttl=64, environment_id=None):
        """
        Initializes the trace action.

        Args:
            start_ttl (int): Starting TTL to use
            end_ttl (int): TTL to end with
            environment_id (str, optional): Environment ID associated with the strategy we are a part of
        """
        Action.__init__(self, "trace", "out")
        self.enabled = True
        self.terminal = True
        self.branching = False
        self.start_ttl = start_ttl
        self.end_ttl = end_ttl
        # Since running this action might take enough time that additional packets
        # get generated, only allow this action to run once
        self.ran = False
        # Define a socket
        self.socket = conf.L3socket(iface=actions.utils.get_interface())
Пример #9
0
    def __init__(self,
                 environment_id=None,
                 correct_order=None,
                 fragsize=-1,
                 segment=True):
        '''
        correct_order specifies if the fragmented packets should come in the correct order
        fragsize specifies how
        '''
        Action.__init__(self, "fragment", "out")
        self.enabled = True
        self.branching = True
        self.terminal = False
        self.fragsize = fragsize
        self.segment = segment

        if correct_order == None:
            self.correct_order = self.get_rand_order()
        else:
            self.correct_order = correct_order
Пример #10
0
 def __init__(self, environment_id=None):
     Action.__init__(self, "drop", "both")
     self.terminal = True
     self.branching = False
Пример #11
0
 def __init__(self, environment_id=None):
     Action.__init__(self, "duplicate", "out")
     self.branching = True
Пример #12
0
 def __init__(self, time=1, environment_id=None):
     Action.__init__(self, "sleep", "both")
     self.terminal = False
     self.branching = False
     self.time = time
Пример #13
0
 def __init__(self):
     Action.__init__(self)
     self.responses = ['Alive and eating!']
Пример #14
0
 def __init__(self, responses=responses):
     Action.__init__(self)
     self.responses = responses
     self.params = None
     self.food = None