简体   繁体   中英

pdfdump in python not working using scapy

    #!/bin/bash/python3
from scapy3k.all import *``
import subprocess
import os

def ifac111():
    pkts = sniff(filter="tcp", iface="tun0", count=100)
    inp = input('want to see a \'pdfdump?\' \n Y/N--> ')
    fag = pkts.summary()
    print('-' * 60)
    what_df = pkts.show()
    print("^^^ Here you got {} packets {}.".format("100", "scanned"))
    print("The {} ones are {} and second ones are just {} command".format("first", "summary", "show" ))
    print(inp)
    if inp == 'Y':
        pkts[0].pdfdump()
    else:
        print("got ya \f hex0")

while 1 > 0:
    SSS = input('enter your command\'s here:-> \t ') #\t moves 4 spaces
    if SSS == 'packets':

        ifac111()

         elif SSS == 'nworkscan':
         os.system('sudo nmap localhost/24')
    elif SSS == 'Virusscan':
        os.system('sudo chkrootkit')
     elif SSS == 'clear':
        subprocess.call('clear')

when i run the pdfdump i get this error

Traceback (most recent call last):
  File "scapy2.py", line 27, in <module>
    ifac111()
  File "scapy2.py", line 16, in ifac111
    pkts[0].pdfdump()
  File "/usr/local/lib/python3.6/dist-packages/scapy3k/packet.py", line 418, in pdfdump
    canvas = self.canvas_dump(**kargs)
  File "/usr/local/lib/python3.6/dist-packages/scapy3k/packet.py", line 428, in canvas_dump
    canvas = pyx.canvas.canvas()
NameError: name 'pyx' is not defined

sorry if the question is stupid I'm new with coding and been trying to do some research with no result I used ICMP instead of TCP also before on my old os but its not working after changing to parrot os and when I run pdfdump I get that error above

This isa bug in scapy3k.packet indeed - it tries to import pyx and silently continue if there's any import error, which leads to your problem:

try:
    import pyx
except ImportError:
    pass

You should fill a bug report in the project's github - the package should properly declare it's dependencies on 3rd part packages so they get installed alongside, and it should definitly not silence the fact that a required import failed.

In the meantime you can try installing pyx yourself - it might just work, or it might break elsewhere depending on versions compat.

You should use scapy instead of scapy3k, it contains those fixes and a better interception of PyX

FTR:

  • scapy3k = fork based on scapy 2.2.0 which used to be the only one supporting python 3
  • scapy (from secdev) = the original one, up-to-date that also works with python 3 since scapy 2.4.0+

Hard to believe this issue is still around after 3yrs. This is to inform anyone else who lands here wanting to know how to fix this problem.

It is due to "Intended" lazy import placed on the installation as it would require GB/s of downloaded files to support the TeX backend. Thus, this is an intentional error by the scapy project itself.

You need to install MikTeX and LiveTex as it is not evident.

LiveTex can be downloaded from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM