7

I am trying to use scapy in python 3.6 to parse pcap files, and of the features I am trying to use is pdfdump.

from scapy.all import *
packets = rdpcap('***path***/nitroba.pcap')
for packet in packets[0:1]:
  packet.psdump("isakmp_pkt.eps",layer_shift=1)

And I am getting the following error: "ImportError: PyX and its depedencies must be installed"

Obviously I installed it, and a simple "import pyx" works, but the error persists. I did some digging and found that the problem originates in this code:

def _test_pyx():
"""Returns if PyX is correctly installed or not"""
try:
    with open(os.devnull, 'wb') as devnull:
        r = subprocess.check_call(["pdflatex", "--version"], stdout=devnull, stderr=subprocess.STDOUT)
except:
    return False
else:
    return r == 0

when executed, it determines if pyx is installed correctly, but it says "FileNotFoundError: [WinError 2] The system cannot find the file specified".

Ideas?

SockworkOrange
  • 355
  • 4
  • 14

3 Answers3

8

In my case (Ubuntu 18, scapy 2.4.3), I had to install pdflatex, i.e.,

sudo apt install texlive-latex-base  
Roei Schus
  • 315
  • 3
  • 8
2

Got the answer myself - when I entered the scapy command line interface it said that I needed to install miktex which is a dependency of PyX, so I did. The second error simply looks like a bug - it looks like there is a missing "import os" statement in the packet.py module, but there is an os.startfile in line 531.

I added it, and it worked:)

SockworkOrange
  • 355
  • 4
  • 14
1

Its currently 2022 in the future and this works for me with Jupyer labs running on Ubuntu 20.04

pip install pyx

At least this works for me:

from scapy.all import *

pkt = IP()

pkt.canvas_dump()

enter image description here

bbartling
  • 3,288
  • 9
  • 43
  • 88