geneva.engine¶
Geneva Strategy Engine
Given a strategy and a server port, the engine configures NFQueue to capture all traffic into and out of that port so the strategy can run over the connection.
-
class
engine.
Engine
(server_port, string_strategy, environment_id=None, server_side=False, output_directory='trials', log_level='info', file_log_level='info', enabled=True, in_queue_num=None, out_queue_num=None, forwarder=None, save_seen_packets=True, demo_mode=False)¶ Bases:
object
-
__init__
(server_port, string_strategy, environment_id=None, server_side=False, output_directory='trials', log_level='info', file_log_level='info', enabled=True, in_queue_num=None, out_queue_num=None, forwarder=None, save_seen_packets=True, demo_mode=False)¶ Parameters: - server_port (str) – The port(s) the engine will monitor
- string_strategy (str) – String representation of strategy DNA to apply to the network
- environment_id (str, None) – ID of the given strategy
- server_side (bool, False) – Whether or not the engine is running on the server side of the connection
- output_directory (str, 'trials') – The path logs and packet captures should be written to
- enabled (bool, True) – whether or not the engine should be started (used for conditional context managers)
- in_queue_num (int, None) – override the netfilterqueue number used for inbound packets. Used for running multiple instances of the engine at the same time. Defaults to None.
- out_queue_num (int, None) – override the netfilterqueue number used for outbound packets. Used for running multiple instances of the engine at the same time. Defaults to None.
- save_seen_packets (bool, True) – whether or not the engine should record and save packets it sees while running. Defaults to True, but it is recommended this be disabled on higher throughput systems.
- demo_mode (bool, False) – whether to replace IPs in log messages with random IPs to hide sensitive IP addresses.
-
configure_iptables
(remove=False)¶ Handles setting up ipables for this run
-
delayed_send
(packet, delay)¶ Method to be started by a thread to delay the sending of a packet without blocking the main thread.
-
do_nat
(packet)¶ NATs packet: changes the sources and destination IP if it matches the configured route, and clears the checksums for recalculating
Parameters: packet (layers.packet.Packet) – packet to modify before sending Returns: the modified packet Return type: layers.packet.Packet
-
handle_packet
(packet)¶ Handles processing an outbound packet through the engine.
-
in_callback
(nfpacket)¶ Callback bound to the incoming nfqueue rule. Since we can’t manually send packets to ourself, process the given packet here.
-
initialize_nfqueue
()¶ Initializes the nfqueue for input and output forests.
-
mysend
(packet)¶ Helper scapy sending method. Expects a Geneva Packet input.
-
out_callback
(nfpacket)¶ Callback bound to the outgoing nfqueue rule to run the outbound strategy.
-
run_nfqueue
(nfqueue, nfqueue_socket, direction)¶ Handles running the outbound nfqueue socket with the socket timeout.
-
shutdown_nfqueue
()¶ Shutdown nfqueue.
-
-
engine.
get_args
()¶ Sets up argparse and collects arguments.
-
engine.
main
(args)¶ Kicks off the engine with the given arguments.