nopasaran 0.2.90__py3-none-any.whl → 0.2.92__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nopasaran/primitives/action_primitives/dns_primitives.py +39 -62
- {nopasaran-0.2.90.dist-info → nopasaran-0.2.92.dist-info}/METADATA +1 -1
- {nopasaran-0.2.90.dist-info → nopasaran-0.2.92.dist-info}/RECORD +7 -7
- {nopasaran-0.2.90.dist-info → nopasaran-0.2.92.dist-info}/LICENSE +0 -0
- {nopasaran-0.2.90.dist-info → nopasaran-0.2.92.dist-info}/WHEEL +0 -0
- {nopasaran-0.2.90.dist-info → nopasaran-0.2.92.dist-info}/entry_points.txt +0 -0
- {nopasaran-0.2.90.dist-info → nopasaran-0.2.92.dist-info}/top_level.txt +0 -0
@@ -155,42 +155,32 @@ class DNSPrimitives:
|
|
155
155
|
dns_packet['DNS'].qr = 1
|
156
156
|
state_machine.set_variable_value(outputs[0], dns_packet)
|
157
157
|
|
158
|
-
|
159
158
|
@staticmethod
|
160
159
|
@parsing_decorator(input_args=1, output_args=1)
|
161
160
|
def get_DNS_transaction_id(inputs, outputs, state_machine):
|
162
161
|
"""
|
163
162
|
Get the transaction ID from the DNS packet.
|
164
|
-
|
165
|
-
Number of input arguments: 1
|
166
|
-
|
167
|
-
Number of output arguments: 1
|
168
|
-
|
169
|
-
Optional input arguments: No
|
170
|
-
|
171
|
-
Optional output arguments: No
|
172
|
-
|
173
|
-
Args:
|
174
|
-
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.
|
175
|
-
|
176
|
-
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 transaction ID.
|
177
|
-
|
178
|
-
state_machine: The state machine object.
|
179
|
-
|
180
|
-
Returns:
|
181
|
-
None
|
182
163
|
"""
|
183
164
|
dns_packet = state_machine.get_variable_value(inputs[0])
|
184
|
-
|
165
|
+
dns_layer = None
|
166
|
+
|
167
|
+
# Try to get the DNS layer directly
|
168
|
+
if hasattr(dns_packet, 'haslayer') and dns_packet.haslayer(DNS):
|
169
|
+
dns_layer = dns_packet.getlayer(DNS)
|
170
|
+
|
171
|
+
# If no DNS layer, try to decode from Raw
|
172
|
+
elif hasattr(dns_packet, 'haslayer') and dns_packet.haslayer('Raw'):
|
185
173
|
try:
|
186
174
|
dns_layer = DNS(dns_packet['Raw'].load)
|
187
|
-
transaction_id = dns_layer.id
|
188
|
-
state_machine.set_variable_value(outputs[0], transaction_id)
|
189
175
|
except Exception as e:
|
190
|
-
logging.error(f"Failed to decode Raw payload as DNS: {e}")
|
191
|
-
|
176
|
+
logging.error(f"[Parsing] Failed to decode Raw payload as DNS: {e}")
|
177
|
+
|
178
|
+
# Extract transaction ID if DNS layer is found
|
179
|
+
if dns_layer:
|
180
|
+
transaction_id = dns_layer.id
|
181
|
+
state_machine.set_variable_value(outputs[0], transaction_id)
|
192
182
|
else:
|
193
|
-
logging.error("DNS layer not found
|
183
|
+
logging.error("[Parsing] DNS layer not found in packet")
|
194
184
|
state_machine.set_variable_value(outputs[0], None)
|
195
185
|
|
196
186
|
@staticmethod
|
@@ -282,42 +272,31 @@ class DNSPrimitives:
|
|
282
272
|
|
283
273
|
state_machine.set_variable_value(outputs[0], dns_packet)
|
284
274
|
|
285
|
-
|
286
275
|
@staticmethod
|
287
276
|
@parsing_decorator(input_args=1, output_args=1)
|
288
277
|
def get_DNS_query_from_DNS_packet(inputs, outputs, state_machine):
|
289
278
|
"""
|
290
279
|
Get the DNS query field (DNSQR) from a DNS packet.
|
291
|
-
|
292
|
-
Number of input arguments: 1
|
293
|
-
|
294
|
-
Number of output arguments: 1
|
295
|
-
|
296
|
-
Optional input arguments: No
|
297
|
-
|
298
|
-
Optional output arguments: No
|
299
|
-
|
300
|
-
Args:
|
301
|
-
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.
|
302
|
-
|
303
|
-
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 query.
|
304
|
-
|
305
|
-
state_machine: The state machine object.
|
306
|
-
|
307
|
-
Returns:
|
308
|
-
None
|
309
280
|
"""
|
310
281
|
dns_packet = state_machine.get_variable_value(inputs[0])
|
311
|
-
|
282
|
+
dns_layer = None
|
283
|
+
|
284
|
+
# Try to get DNS layer directly if present
|
285
|
+
if hasattr(dns_packet, 'haslayer') and dns_packet.haslayer(DNS):
|
286
|
+
dns_layer = dns_packet.getlayer(DNS)
|
287
|
+
|
288
|
+
# Attempt to decode Raw payload as DNS if DNS layer isn't directly present
|
289
|
+
elif hasattr(dns_packet, 'haslayer') and dns_packet.haslayer('Raw'):
|
312
290
|
try:
|
313
291
|
dns_layer = DNS(dns_packet['Raw'].load)
|
314
|
-
dns_query = dns_layer.qd
|
315
|
-
state_machine.set_variable_value(outputs[0], dns_query)
|
316
292
|
except Exception as e:
|
317
|
-
logging.error(f"Failed to decode Raw payload as DNS: {e}")
|
318
|
-
|
293
|
+
logging.error(f"[Parsing] Failed to decode Raw payload as DNS: {e}")
|
294
|
+
|
295
|
+
if dns_layer and getattr(dns_layer, "qd", None):
|
296
|
+
dns_query = dns_layer.qd
|
297
|
+
state_machine.set_variable_value(outputs[0], dns_query)
|
319
298
|
else:
|
320
|
-
logging.error("DNS
|
299
|
+
logging.error("[Parsing] DNS query not found in packet")
|
321
300
|
state_machine.set_variable_value(outputs[0], None)
|
322
301
|
|
323
302
|
@staticmethod
|
@@ -858,15 +837,10 @@ class DNSPrimitives:
|
|
858
837
|
48: "DNSKEY", 255: "ANY"
|
859
838
|
}
|
860
839
|
|
861
|
-
dnsqtypes = dnsatypes # if you meant dnsatypes to cover both
|
862
|
-
|
863
840
|
dns_layer = None
|
864
841
|
|
865
|
-
# Try to get DNS layer from packet
|
866
842
|
if hasattr(packet, 'haslayer') and packet.haslayer(DNS):
|
867
843
|
dns_layer = packet.getlayer(DNS)
|
868
|
-
|
869
|
-
# Try to parse DNS from Raw if not directly available
|
870
844
|
elif hasattr(packet, 'haslayer') and packet.haslayer('Raw'):
|
871
845
|
try:
|
872
846
|
dns_layer = DNS(packet['Raw'].load)
|
@@ -890,33 +864,36 @@ class DNSPrimitives:
|
|
890
864
|
"answers": []
|
891
865
|
}
|
892
866
|
|
893
|
-
# Handle DNS
|
867
|
+
# Handle DNS questions
|
894
868
|
if getattr(dns_layer, "qdcount", 0) > 0 and getattr(dns_layer, "qd", None):
|
895
869
|
try:
|
896
870
|
question = dns_layer.qd
|
897
871
|
formatted_response["questions"].append({
|
898
872
|
"qname": question.qname.decode() if isinstance(question.qname, bytes) else question.qname,
|
899
873
|
"qtype": question.qtype,
|
900
|
-
"qtype_name":
|
874
|
+
"qtype_name": dnsatypes.get(question.qtype, f"Unknown({question.qtype})"),
|
901
875
|
"qclass": question.qclass
|
902
876
|
})
|
903
877
|
except Exception as e:
|
904
878
|
logging.error(f"[Parsing] Failed to parse DNS question: {e}")
|
905
879
|
|
906
|
-
# Handle DNS answers
|
880
|
+
# Handle DNS answers (support for lists and chained payloads)
|
907
881
|
try:
|
908
|
-
ans = dns_layer.an
|
909
|
-
|
882
|
+
ans = dns_layer.an
|
883
|
+
for _ in range(getattr(dns_layer, "ancount", 0)):
|
884
|
+
if not isinstance(ans, DNSRR):
|
885
|
+
break
|
910
886
|
answer_info = {
|
911
887
|
"rrname": ans.rrname.decode() if isinstance(ans.rrname, bytes) else ans.rrname,
|
912
888
|
"type": ans.type,
|
913
889
|
"type_name": dnsatypes.get(ans.type, f"Unknown({ans.type})"),
|
914
890
|
"rclass": ans.rclass,
|
915
891
|
"ttl": ans.ttl,
|
916
|
-
"rdata": str(ans.rdata),
|
892
|
+
"rdata": ans.rdata.decode() if isinstance(ans.rdata, bytes) else str(ans.rdata),
|
893
|
+
"rdlen": getattr(ans, "rdlen", None)
|
917
894
|
}
|
918
895
|
formatted_response["answers"].append(answer_info)
|
919
|
-
ans = ans.payload
|
896
|
+
ans = ans.payload
|
920
897
|
except Exception as e:
|
921
898
|
logging.error(f"[Parsing] Failed to parse DNS answers: {e}")
|
922
899
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nopasaran
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.92
|
4
4
|
Summary: NoPASARAN is an advanced network tool designed to detect, fingerprint, and locate network middleboxes in a unified framework.
|
5
5
|
Home-page: https://github.com/BenIlies/NoPASARAN
|
6
6
|
Author: Ilies Benhabbour
|
@@ -34,7 +34,7 @@ nopasaran/primitives/action_primitives/client_echo_primitives.py,sha256=2Qupem0N
|
|
34
34
|
nopasaran/primitives/action_primitives/control_channel_primitives.py,sha256=_OMgxLLtaK0vvobwhPvSAJhYCOgn4optcGhXOdgh1Q4,11281
|
35
35
|
nopasaran/primitives/action_primitives/data_channel_primitives.py,sha256=gDnjw76kFeMtDD4Mnv31vsx6xQsxvavsbYr4yhRH_hg,4557
|
36
36
|
nopasaran/primitives/action_primitives/data_manipulation.py,sha256=mt-BNOEIxyvXzHTwRO1ch1DzzYHQK1AduhRs11TOKH4,15450
|
37
|
-
nopasaran/primitives/action_primitives/dns_primitives.py,sha256=
|
37
|
+
nopasaran/primitives/action_primitives/dns_primitives.py,sha256=grtwAMKBSUPWX4t-tOMGPejDasS7KVflrUKSSOcfM0A,33371
|
38
38
|
nopasaran/primitives/action_primitives/event_primitives.py,sha256=V2FurvbeRy6nAcDne3Xm4Y86bvo5UYpEeUJFos842tY,2699
|
39
39
|
nopasaran/primitives/action_primitives/http_1_request_primitives.py,sha256=ov4OLXyNiWNjJYS0GjHwuRFkS5DLQaAh6P6ETy1r5ng,14562
|
40
40
|
nopasaran/primitives/action_primitives/http_1_response_primitives.py,sha256=0wS61tl1KSAlIkYkPXMjbbnY5LqKzl9UtuoK56S4IHQ,7947
|
@@ -73,9 +73,9 @@ nopasaran/tools/http_2_socket_client.py,sha256=5mmc8FuT2dNVAihbMdvyytVwME_xSc7me
|
|
73
73
|
nopasaran/tools/http_2_socket_server.py,sha256=8W-bxmdoGyK5moxpC87V1EGuZ9jJpIKhokvZrDV84kk,5551
|
74
74
|
nopasaran/tools/https_1_socket_server.py,sha256=0mJ_0zCC-7rtvyjehTnm1QJxWx8R4YHkAWRHm2msvL4,9217
|
75
75
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
76
|
-
nopasaran-0.2.
|
77
|
-
nopasaran-0.2.
|
78
|
-
nopasaran-0.2.
|
79
|
-
nopasaran-0.2.
|
80
|
-
nopasaran-0.2.
|
81
|
-
nopasaran-0.2.
|
76
|
+
nopasaran-0.2.92.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
77
|
+
nopasaran-0.2.92.dist-info/METADATA,sha256=qdh8BZCslIEOBGYQHXFLZ1_bWUv9sUuegmP0EA6OFqw,5474
|
78
|
+
nopasaran-0.2.92.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
79
|
+
nopasaran-0.2.92.dist-info/entry_points.txt,sha256=LaOz5GlWuMLjzg4KOEB5OVTattCXVW6a4nSW-WQajCw,55
|
80
|
+
nopasaran-0.2.92.dist-info/top_level.txt,sha256=60R1FzpprzU8iiJ1cBMNOA0F083_lYoctFo7pzOpMwY,16
|
81
|
+
nopasaran-0.2.92.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|