ahlashkari / DoHLyzer

DoHlyzer is a DNS over HTTPS (DoH) traffic flow generator and analyzer for anomaly detection and characterization.
56 stars 31 forks source link

No python interpreter seems to comply with meter module. #10

Open DanielCochavi opened 3 years ago

DanielCochavi commented 3 years ago

I've tried Python 2.7, 3.5, 3.6, 3.7, and 3.8 each with its own issues. Python 2.7, Python 3.5 & Python 3.8 are not relevant - due to syntax and unsatisfied requirements.

All python versions producing the following exception:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv36/lib/python3.6/site-packages/scapy/sendrecv.py", line 836, in _run
    *session_args, **session_kwargs)
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow_session.py", line 31, in __init__
    super(FlowSession, self).__init__(None, True, *args, **kwargs)
TypeError: __init__() got multiple values for argument 'prn'

As no use is done with args and kwargs at FlowSession, we can remove the asterisks from the super constructor: super(FlowSession, self).__init__(None, True, *args, **kwargs) Not a good solution, but it's working.

After "fixing" the above issue, with Python 3.6 we get the following exception:

Packet count: 10000
Garbage Collection Began. Flows = 191
Garbage Collection Finished. Flows = 191
Packet count: 20000
Garbage Collection Began. Flows = 485
/home/ubuntu/Desktop/DoHlyzer-master/venv36/lib/python3.6/site-packages/scipy/stats/stats.py:269: RuntimeWarning: The input array could not be properly checked for nan values. nan values will be ignored.
  "values. nan values will be ignored.", RuntimeWarning)
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv36/lib/python3.6/site-packages/scapy/sendrecv.py", line 989, in _run
    session.on_packet_received(p)
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow_session.py", line 105, in on_packet_received
    self.garbage_collect(packet.time)
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow_session.py", line 119, in garbage_collect
    data = flow.get_data()
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow.py", line 80, in get_data
    'PacketTimeMode': packet_time.get_mode(),
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/features/packet_time.py", line 116, in get_mode
    mode = float(stat.mode(self._get_packet_times())[0])
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv36/lib/python3.6/site-packages/scipy/stats/stats.py", line 469, in mode
    if a.dtype == object and np.nan in set(a.ravel()):
TypeError: unhashable type: 'EDecimal'

With Python 3.7 we have the following exception:

Packet count: 10000
Garbage Collection Began. Flows = 191
Garbage Collection Finished. Flows = 191
Packet count: 20000
Garbage Collection Began. Flows = 485
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv37/lib/python3.7/site-packages/scapy/sendrecv.py", line 989, in _run
    session.on_packet_received(p)
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow_session.py", line 105, in on_packet_received
    self.garbage_collect(packet.time)
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow_session.py", line 119, in garbage_collect
    data = flow.get_data()
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/flow.py", line 78, in get_data
    'PacketTimeMean': packet_time.get_mean(),
  File "/home/ubuntu/Desktop/DoHlyzer-master/meter/features/packet_time.py", line 94, in get_mean
    mean = numpy.mean(self._get_packet_times())
  File "<__array_function__ internals>", line 6, in mean
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv37/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3420, in mean
    out=out, **kwargs)
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv37/lib/python3.7/site-packages/numpy/core/_methods.py", line 190, in _mean
    ret = ret / rcount
  File "/home/ubuntu/Desktop/DoHlyzer-master/venv37/lib/python3.7/site-packages/scapy/utils.py", line 84, in __truediv__
    return EDecimal(Decimal.__truediv__(self, Decimal(other), **kwargs))
TypeError: conversion from numpy.int64 to Decimal is not supported

Python 3.8 couldn't have worked as well:

ERROR: Could not find a version that satisfies the requirement tensorflow==2.1.0
ERROR: No matching distribution found for tensorflow==2.1.0

Tested on Windows 10 & Ubuntu 20.04 Command-line: (venv3X) ubuntu@ubuntu-vm:~/Desktop/DoHlyzer-master$ python meter/dohlyzer.py -f '/home/ubuntu/Desktop/dump_00005_20200113142226.pcap' -c ./output.csv

It would help if you could write what Python interpreter version you have used.

Tnx :)

hsouna commented 3 years ago

For the ERROR: Could not find a version that satisfies the requirement tensorflow==2.1.0 ERROR: No matching distribution found for tensorflow==2.1.0 error, all you have to do is upgrade pip using: $ python -m pip install --upgrade pip But for the TypeError: __init__() got multiple values for argument 'prn' I'm using Python 3.7.5 and I had same output :( Any solution?

AmirSalari commented 2 years ago

I also have this problem: TypeError: __init__() got multiple values for argument 'prn' did you guys find any solution for it?

mlouielu commented 1 year ago

Is because of scapy, we should pinned the version to scapy==2.4.3