nopasaran.primitives.action_primitives.dns_primitives.DNSPrimitives¶
- class nopasaran.primitives.action_primitives.dns_primitives.DNSPrimitives¶
Bases:
objectClass containing DNS action primitives for the state machine.
- __init__()¶
Methods
__init__()add_DNS_query_to_DNS_packet(inputs, outputs, ...)Add a DNS query (DNSQR) to a DNS packet.
add_DNS_response_to_additional(inputs, ...)Add a DNS response packet to the additional answer section of a DNS packet.
add_DNS_response_to_answer(inputs, outputs, ...)Add a DNS response packet to the answer section of a DNS packet.
append_random_label_to_qname(inputs, ...)Append a random label to the existing qname in a DNS query packet.
create_DNS_packet(inputs, outputs, state_machine)Create a DNS packet and store it in an output variable in the machine's state.
create_DNS_query(inputs, outputs, state_machine)Create a DNS query (DNSQR) and store it in an output variable in the machine's state.
create_DNS_resource_record(inputs, outputs, ...)Create a DNS resource record without input arguments and store it in an output variable in the machine's state.
Create a malformed DNS packet (e.g., claims QDCOUNT=1 but provides no DNSQR).
disable_DNS_rd_flag(inputs, outputs, ...)Disable the recursion desired (rd) flag in the DNS packet.
enable_DNS_rd_flag(inputs, outputs, ...)Enable the recursion desired (rd) flag in the DNS packet.
format_dns_query_packet(inputs, outputs, ...)Extracts metadata from a DNS Query packet and stores the formatted dictionary.
format_dns_response_packet(inputs, outputs, ...)Extracts metadata from a DNS Response packet and stores the formatted dictionary.
Get the DNS additional answer field from a DNS packet.
get_DNS_answer_from_DNS_packet(inputs, ...)Get the DNS answer field from a DNS packet.
get_DNS_query_from_DNS_packet(inputs, ...)Get the DNS query field (DNSQR) from a DNS packet.
get_DNS_transaction_id(inputs, outputs, ...)Get the transaction ID from the DNS packet.
get_dns_rcode_from_dns_packet(inputs, ...)Extract the DNS RCODE (e.g., NXDOMAIN is 3) from a DNS packet.
get_query_name(inputs, outputs, state_machine)Get the domain name (qname) of a DNS query (DNSQR).
set_DNS_packet_query(inputs, outputs, ...)Set the DNS packet as a query packet.
set_DNS_packet_response(inputs, outputs, ...)Set the DNS packet as a response packet.
set_DNS_resource_record_domain(inputs, ...)Set the domain name for a DNS resource record.
set_DNS_resource_record_type(inputs, ...)Set the record type for a DNS resource record.
set_DNS_resource_record_value(inputs, ...)Set the value for a DNS resource record.
set_DNS_transaction_id(inputs, outputs, ...)Set the transaction ID in the DNS packet.
set_query_class(inputs, outputs, state_machine)Set the query class (qclass) of a DNS query (DNSQR).
set_query_name(inputs, outputs, state_machine)Set the domain name (qname) of a DNS query (DNSQR).
set_query_type(inputs, outputs, state_machine)Set the query type (qtype) of a DNS query (DNSQR).
- static add_DNS_query_to_DNS_packet(inputs, outputs, state_machine)¶
Add a DNS query (DNSQR) to a DNS packet.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS packet.
The name of the variable containing the DNS query to be added.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static add_DNS_response_to_additional(inputs, outputs, state_machine)¶
Add a DNS response packet to the additional answer section of a DNS packet.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS packet.
The name of the variable containing the DNS response packet to be added to the additional answer section.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static add_DNS_response_to_answer(inputs, outputs, state_machine)¶
Add a DNS response packet to the answer section of a DNS packet.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS packet.
The name of the variable containing the DNS response packet to be added to the answer section.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static append_random_label_to_qname(inputs, outputs, state_machine)¶
Append a random label to the existing qname in a DNS query packet.
Number of input arguments: 1 - The name of the variable containing the DNS packet (which must have a DNSQR layer).
Number of output arguments: 1 - The name of the variable to store the modified DNS packet.
- Args:
- inputs (List[str]): The list of input variable names, containing one mandatory argument:
The DNS query packet variable name.
- outputs (List[str]): The list of output variable names, containing one mandatory argument:
The modified DNS packet variable name.
state_machine: The state machine object.
- static create_DNS_packet(inputs, outputs, state_machine)¶
Create a DNS packet and store it in an output variable in the machine’s state.
Number of input arguments: 0
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the created DNS packet.
state_machine: The state machine object.
- Returns:
None
- static create_DNS_query(inputs, outputs, state_machine)¶
Create a DNS query (DNSQR) and store it in an output variable in the machine’s state.
Number of input arguments: 0
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the created DNS query.
state_machine: The state machine object.
- Returns:
None
- static create_DNS_resource_record(inputs, outputs, state_machine)¶
Create a DNS resource record without input arguments and store it in an output variable in the machine’s state.
Number of input arguments: 0
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the created DNS resource record.
state_machine: The state machine object.
- Returns:
None
- static create_dns_query_packet_with_qdcount_mismatch(inputs, outputs, state_machine)¶
Create a malformed DNS packet (e.g., claims QDCOUNT=1 but provides no DNSQR).
Number of input arguments: 0 Number of output arguments: 1 Optional input arguments: No Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. Not used in this method. outputs (List[str]): The list of output variable names. Contains one mandatory output argument:
The name of the variable to store the malformed DNS packet.
state_machine: The state machine object.
- Returns:
None
- static disable_DNS_rd_flag(inputs, outputs, state_machine)¶
Disable the recursion desired (rd) flag in the DNS packet.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the name of the variable containing the DNS packet.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static enable_DNS_rd_flag(inputs, outputs, state_machine)¶
Enable the recursion desired (rd) flag in the DNS packet.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the name of the variable containing the DNS packet.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static format_dns_query_packet(inputs, outputs, state_machine)¶
Extracts metadata from a DNS Query packet and stores the formatted dictionary.
- static format_dns_response_packet(inputs, outputs, state_machine)¶
Extracts metadata from a DNS Response packet and stores the formatted dictionary.
- static get_DNS_additional_answer_from_DNS_packet(inputs, outputs, state_machine)¶
Get the DNS additional answer field from a DNS packet.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the name of the variable containing the DNS packet.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the DNS additional answer.
state_machine: The state machine object.
- Returns:
None
- static get_DNS_answer_from_DNS_packet(inputs, outputs, state_machine)¶
Get the DNS answer field from a DNS packet.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the name of the variable containing the DNS packet.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the DNS answer.
state_machine: The state machine object.
- Returns:
None
- static get_DNS_query_from_DNS_packet(inputs, outputs, state_machine)¶
Get the DNS query field (DNSQR) from a DNS packet.
- static get_DNS_transaction_id(inputs, outputs, state_machine)¶
Get the transaction ID from the DNS packet.
- static get_dns_rcode_from_dns_packet(inputs, outputs, state_machine)¶
Extract the DNS RCODE (e.g., NXDOMAIN is 3) from a DNS packet.
Number of input arguments: 1 (the name of the variable containing the DNS packet) Number of output arguments: 1 (the name of the variable to store the DNS rcode)
- Args:
- inputs (List[str]): The list of input variable names.
inputs[0] is the variable name storing the DNS packet.
- outputs (List[str]): The list of output variable names.
outputs[0] is the variable name to store the DNS rcode.
state_machine: Your state machine object for variable management.
- Returns:
None
- static get_query_name(inputs, outputs, state_machine)¶
Get the domain name (qname) of a DNS query (DNSQR).
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the name of the variable containing the DNS query.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the qualified domain name.
state_machine: The state machine object.
- Returns:
None
- static set_DNS_packet_query(inputs, outputs, state_machine)¶
Set the DNS packet as a query packet.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains one mandatory input argument:
The name of the variable containing the DNS packet.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static set_DNS_packet_response(inputs, outputs, state_machine)¶
Set the DNS packet as a response packet.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains one mandatory input argument:
The name of the variable containing the DNS packet.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static set_DNS_resource_record_domain(inputs, outputs, state_machine)¶
Set the domain name for a DNS resource record.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS resource record.
The name of the variable containing the domain name to set.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS resource record.
state_machine: The state machine object.
- Returns:
None
- static set_DNS_resource_record_type(inputs, outputs, state_machine)¶
Set the record type for a DNS resource record.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS resource record.
The name of the variable containing the record type to set.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS resource record.
state_machine: The state machine object.
- Returns:
None
- static set_DNS_resource_record_value(inputs, outputs, state_machine)¶
Set the value for a DNS resource record.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS resource record.
The name of the variable containing the value to set.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is
the name of the variable to store the modified DNS resource record.
state_machine: The state machine object.
- Returns:
None
- static set_DNS_transaction_id(inputs, outputs, state_machine)¶
Set the transaction ID in the DNS packet.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments. The first argument is the name of the variable containing the DNS packet, and the second argument is the name of the variable containing the new transaction ID.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS packet.
state_machine: The state machine object.
- Returns:
None
- static set_query_class(inputs, outputs, state_machine)¶
Set the query class (qclass) of a DNS query (DNSQR).
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS query.
The name of the variable containing the new query class.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS query.
state_machine: The state machine object.
- Returns:
None
- static set_query_name(inputs, outputs, state_machine)¶
Set the domain name (qname) of a DNS query (DNSQR).
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS query.
The name of the variable containing the new query name (qname).
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS query.
state_machine: The state machine object.
- Returns:
None
- static set_query_type(inputs, outputs, state_machine)¶
Set the query type (qtype) of a DNS query (DNSQR).
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the variable containing the DNS query.
The name of the variable containing the new query type.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the modified DNS query.
state_machine: The state machine object.
- Returns:
None