-1

I am working on a dns_spoof school project. I have imported the following to my program:

import netfilterqueue
import scapy.all as scapy

My problem is that when I try to run the program via terminal with the python2 interpreter scapy doesn't work and when I try to run it in terminal with the python3 interpreter then netfilterqueue does not work.

When trying to run the program with the python2 interpreter I get the following error:

root@kali:~/PycharmProjects/dns_spoof# python dns_spoof.py

        PIP package scapy-python3 used to provide scapy3k, which was a fork from scapy implementing python3 compatibility since 2016. This package was included in some of the Linux distros under name of python3-scapy. Starting from scapy version 2.4 (released in March, 2018) mainstream scapy supports python3. To reduce any confusion scapy3k was renamed to kamene. 
You should use either pip package kamene for scapy3k (see http://github.com/phaethon/kamene for differences in use) or mainstream scapy (pip package scapy, http://github.com/secdev/scapy).  

Traceback (most recent call last):
  File "dns_spoof.py", line 3, in <module>
    import scapy.all as scapy
  File "/usr/local/lib/python2.7/dist-packages/scapy/all.py", line 5, in <module>
    raise Exception(msg)
Exception: 
        PIP package scapy-python3 used to provide scapy3k, which was a fork from scapy implementing python3 compatibility since 2016. This package was included in some of the Linux distros under name of python3-scapy. Starting from scapy version 2.4 (released in March, 2018) mainstream scapy supports python3. To reduce any confusion scapy3k was renamed to kamene. 
You should use either pip package kamene for scapy3k (see http://github.com/phaethon/kamene for differences in use) or mainstream scapy (pip package scapy, http://github.com/secdev/scapy). 

When I try to run the program with the python3 interpreter via the terminal I get the following error:

root@kali:~/PycharmProjects/dns_spoof# python3 dns_spoof.py
Traceback (most recent call last):
  File "dns_spoof.py", line 2, in <module>
    import netfilterqueue
ModuleNotFoundError: No module named 'netfilterqueue'

So netfilterqueue is only working in python2 and scapy is only working in python3. How do I solve this? I need to use both at the same time.

CodingStudent
  • 179
  • 1
  • 2
  • 12

2 Answers2

0

Install the proper scapy version

pip uninstall scapy-python3
pip install scapy

To fix python 2

Cukic0d
  • 5,111
  • 2
  • 19
  • 48
  • pip uninstall scapy-python3 worked. pip install scapy says it is already installed and then when I try to run it I still get an error with import scapy.all as scapy. The following is from my terminal root@kali:~/PycharmProjects/dns_spoof# python dns_spoof.py Traceback (most recent call last): File "dns_spoof.py", line 3, in import scapy.all as scapy ImportError: No module named all – CodingStudent Apr 18 '20 at 13:39
  • It's always the same issue.. you have different environments and you're not installing in the wrong one – Cukic0d Apr 18 '20 at 22:07
0

netfilterqueue for python3+ is named nfqp3, you can install it with

pip3 install nfqp3

but you will import it in a python3 script with "import netfilterqueue" ... don't ask me why

don't forget to first install netfilterqueue on your linux machine