nopasaran 0.2.93__py3-none-any.whl → 0.2.95__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.
@@ -386,7 +386,7 @@ class DNSPrimitives:
386
386
  """
387
387
  dns_query = state_machine.get_variable_value(inputs[0])
388
388
  new_query_type = state_machine.get_variable_value(inputs[1])
389
- dns_query.qtype = new_query_type
389
+ dns_query.qtype = int(new_query_type)
390
390
  state_machine.set_variable_value(outputs[0], dns_query)
391
391
 
392
392
  @staticmethod
@@ -838,6 +838,7 @@ class DNSPrimitives:
838
838
 
839
839
  dns_layer = None
840
840
 
841
+ # Try to extract DNS layer directly or from Raw
841
842
  if hasattr(packet, 'haslayer') and packet.haslayer(DNS):
842
843
  dns_layer = packet.getlayer(DNS)
843
844
  elif hasattr(packet, 'haslayer') and packet.haslayer('Raw'):
@@ -863,9 +864,9 @@ class DNSPrimitives:
863
864
  "answers": []
864
865
  }
865
866
 
866
- # Handle DNS questions
867
- if getattr(dns_layer, "qdcount", 0) > 0 and getattr(dns_layer, "qd", None):
868
- try:
867
+ # Parse questions
868
+ try:
869
+ if getattr(dns_layer, "qdcount", 0) > 0 and getattr(dns_layer, "qd", None):
869
870
  question = dns_layer.qd
870
871
  formatted_response["questions"].append({
871
872
  "qname": question.qname.decode() if isinstance(question.qname, bytes) else question.qname,
@@ -873,26 +874,29 @@ class DNSPrimitives:
873
874
  "qtype_name": dnsatypes.get(question.qtype, f"Unknown({question.qtype})"),
874
875
  "qclass": question.qclass
875
876
  })
876
- except Exception as e:
877
- logging.error(f"[Parsing] Failed to parse DNS question: {e}")
877
+ except Exception as e:
878
+ logging.error(f"[Parsing] Failed to parse DNS question: {e}")
878
879
 
879
- # Handle DNS answers (support for lists and chained payloads)
880
+ # Parse answers (assuming it's a list or iterable)
880
881
  try:
881
- ans = dns_layer.an
882
- for _ in range(getattr(dns_layer, "ancount", 0)):
883
- if not isinstance(ans, DNSRR):
884
- break
885
- answer_info = {
886
- "rrname": ans.rrname.decode() if isinstance(ans.rrname, bytes) else ans.rrname,
887
- "type": ans.type,
888
- "type_name": dnsatypes.get(ans.type, f"Unknown({ans.type})"),
889
- "rclass": ans.rclass,
890
- "ttl": ans.ttl,
891
- "rdata": ans.rdata.decode() if isinstance(ans.rdata, bytes) else str(ans.rdata),
892
- "rdlen": getattr(ans, "rdlen", None)
893
- }
894
- formatted_response["answers"].append(answer_info)
895
- ans = ans.payload
882
+ answers = dns_layer.an
883
+ if isinstance(answers, list):
884
+ answer_rrs = answers
885
+ else:
886
+ answer_rrs = [answers] # wrap single DNSRR for uniform handling
887
+
888
+ for ans in answer_rrs:
889
+ if isinstance(ans, DNSRR):
890
+ answer_info = {
891
+ "rrname": ans.rrname.decode() if isinstance(ans.rrname, bytes) else ans.rrname,
892
+ "type": ans.type,
893
+ "type_name": dnsatypes.get(ans.type, f"Unknown({ans.type})"),
894
+ "rclass": ans.rclass,
895
+ "ttl": ans.ttl,
896
+ "rdata": ans.rdata.decode() if isinstance(ans.rdata, bytes) else str(ans.rdata),
897
+ "rdlen": getattr(ans, "rdlen", None)
898
+ }
899
+ formatted_response["answers"].append(answer_info)
896
900
  except Exception as e:
897
901
  logging.error(f"[Parsing] Failed to parse DNS answers: {e}")
898
902
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nopasaran
3
- Version: 0.2.93
3
+ Version: 0.2.95
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=lkL2fgBpFpuj2YmrbBQi-GnGyp4aq9lQYx1UBqCN76I,33332
37
+ nopasaran/primitives/action_primitives/dns_primitives.py,sha256=vmo-jVb4fRzRNhGz1tBiuCH_6JZUbIrLLgB-nUqRMDA,33509
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.93.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
77
- nopasaran-0.2.93.dist-info/METADATA,sha256=wG1DQZBCDCrZsGPc1XTuzLt0UTRW-xCMSBPCniTIWt0,5474
78
- nopasaran-0.2.93.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
79
- nopasaran-0.2.93.dist-info/entry_points.txt,sha256=LaOz5GlWuMLjzg4KOEB5OVTattCXVW6a4nSW-WQajCw,55
80
- nopasaran-0.2.93.dist-info/top_level.txt,sha256=60R1FzpprzU8iiJ1cBMNOA0F083_lYoctFo7pzOpMwY,16
81
- nopasaran-0.2.93.dist-info/RECORD,,
76
+ nopasaran-0.2.95.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
77
+ nopasaran-0.2.95.dist-info/METADATA,sha256=tugqx4ZppBaS98cYZASox_JZMjhzKmluIcO1R4P0DUU,5474
78
+ nopasaran-0.2.95.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
79
+ nopasaran-0.2.95.dist-info/entry_points.txt,sha256=LaOz5GlWuMLjzg4KOEB5OVTattCXVW6a4nSW-WQajCw,55
80
+ nopasaran-0.2.95.dist-info/top_level.txt,sha256=60R1FzpprzU8iiJ1cBMNOA0F083_lYoctFo7pzOpMwY,16
81
+ nopasaran-0.2.95.dist-info/RECORD,,