zoukankan      html  css  js  c++  java
  • 编译EXE文件的时候pcap编译不进去。 pyinstaller pcap pypcap 报错

     如果生成的exe源码中有import pcap

    那么你目标机上就要先装npcap 并勾选winpcap API。

    然后就不出这个问题了。

    暂时的办法是第一个exe不包含import pcap。自检npcap的安装状态。如果有npcap就打开第二个exe,这个就可以import pcap了。

    并且pypcap 貌似只在win10上能用。

    from scapy.all import *
    
    pkts = sniff(prn=lambda x: x.sprintf("{IP:%IP.src% -> %IP.dst%
    }{Raw:%Raw.load%
    }"))

    简单尝试scapy,也可以抓包,明天试试,如果打包顺利,就换一下抓包工具。

    192.168.1.169 -> 172.217.160.106
    b' x85x00xb5x12x81x8d,Q039x05x92x84x0fWm(>G5#xd2!xa0x01x05x14CHLOx12x00x00x00PADx00xd6x03x00x00SNIx00xe8x03x00x00VERx00xecx03x00x00CCSx00xfcx03x00x00MSPCx00x04x00x00UAID0x04x00x00TCID4x04x00x00PDMD8x04x00x00SMHL<x04x00x00ICSL@x04x00x00CTIMHx04x00x00NONPhx04x00x00MIDSlx04x00x00SCLSpx04x00x00CSCTpx04x00x00COPTtx04x00x00CFCWxx04x00x00SFCW|x04x00x00----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------www.googleapis.comQ039x01xe8x81`x92x92x1axe8~xedx80x86xa2x15x82x91dx00x00x00Chrome/64.0.3282.119 Windows NT 10.0; Win64; x64x00x00x00x00X509x01x00x00x00x1ex00x00x00*i|Zx00x00x00x00x1dp-xedx1e Qx91xbaxeaok]%xb4x0bSxebxb9<te6xc5xf1jxaex11Uxc4xf8Zdx00x00x00x01x00x00x005RTOx00x00xf0x00x00x00`x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00'

    https://github.com/pyinstaller/pyinstaller/issues/3282

    pyinstall 官方提交了问题。

    https://stackoverflow.com/questions/48678451/pyinstall-cannot-build-pypcap-in-windows-10-64bit

    stackoverflow也提交了问题。

    按我的水平,只能等待了。

    i try build exe with pyinstaller.

    the test.py is
    print('hello')

    the warntest.txt
    missing module named resource - imported by posix, D:PythonTest\test.py
    missing module named posix - imported by os, D:PythonTest\test.py
    missing module named _posixsubprocess - imported by subprocess, D:PythonTest\test.py
    missing module named 'org.python' - imported by pickle, D:PythonTest\test.py, xml.sax
    missing module named readline - imported by cmd, code, pdb, D:PythonTest\test.py
    excluded module named _frozen_importlib - imported by importlib, importlib.abc, D:PythonTest\test.py
    missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, D:PythonTest\test.py
    missing module named _winreg - imported by platform, D:PythonTest\test.py
    missing module named _scproxy - imported by urllib.request
    missing module named java - imported by platform, D:PythonTest\test.py
    missing module named 'java.lang' - imported by platform, D:PythonTest\test.py, xml.sax._exceptions
    missing module named vms_lib - imported by platform, D:PythonTest\test.py
    missing module named termios - imported by tty, D:PythonTest\test.py, getpass
    missing module named grp - imported by shutil, tarfile, D:PythonTest\test.py
    missing module named pwd - imported by posixpath, shutil, tarfile, http.server, webbrowser, D:PythonTest\test.py, netrc, getpass
    missing module named _dummy_threading - imported by dummy_threading, D:PythonTest\test.py
    missing module named org - imported by copy, D:PythonTest\test.py

    dist test.exe work on some computer.


    then i try add code with pypcap:
    import pcap
    pc = pcap.pcap()
    for d,b in pc:
    print(d,b)

    pyinstaller test.py

    the warntest.txt same old one. no missing pcap or pypcap.
    missing module named resource - imported by posix, D:PythonTest\test.py
    missing module named posix - imported by os, D:PythonTest\test.py
    missing module named _posixsubprocess - imported by subprocess, D:PythonTest\test.py
    missing module named org - imported by pickle, D:PythonTest\test.py
    missing module named readline - imported by cmd, code, pdb, D:PythonTest\test.py
    excluded module named _frozen_importlib - imported by importlib, importlib.abc, D:PythonTest\test.py
    missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, D:PythonTest\test.py
    missing module named _winreg - imported by platform, D:PythonTest\test.py
    missing module named _scproxy - imported by urllib.request
    missing module named java - imported by platform, D:PythonTest\test.py
    missing module named 'java.lang' - imported by platform, D:PythonTest\test.py, xml.sax._exceptions
    missing module named vms_lib - imported by platform, D:PythonTest\test.py
    missing module named termios - imported by tty, D:PythonTest\test.py, getpass
    missing module named grp - imported by shutil, tarfile, D:PythonTest\test.py
    missing module named pwd - imported by posixpath, shutil, tarfile, http.server, webbrowser, D:PythonTest\test.py, netrc, getpass
    missing module named _dummy_threading - imported by dummy_threading, D:PythonTest\test.py
    missing module named 'org.python' - imported by copy, D:PythonTest\test.py, xml.sax

    dist test.exe worked on my build computer.
    the other computer prompt DLL load failed:

    PS C:UsersJackDesktopdist est> . est.exe
    hello
    Traceback (most recent call last):
    File "test.py", line 10, in <module>
    File "D:PythonEnvilibsite-packagesPyInstallerloaderpyimod03_importers.py", line 714, in load_module
    ImportError: DLL load failed: 找不到指定的模块。
    [2360] Failed to execute script test

    the line 10 is :
    import pcap


    so i try other way :
    pyinstaller.exe --hidden-import pcap test.py
    pyinstaller.exe -p D:PythonEnviLibsite-packages --hidden-import pcap D:PythonTest\test.py


    windows10 Home 64bit
    python 3.63
    pyinstaller 3.3.1
    pypcap 1.20
    npcap 0.98 installer
    npcap sdd 0.1
    Microsoft Visual C++ Build Tools 2015

  • 相关阅读:
    AUC ROC PR曲线
    L1,L2范数和正则化 到lasso ridge regression
    目标函数和损失函数
    logistic回归和线性回归
    [转]如何处理不均衡数据?
    将Maven项目打包成可执行 jar文件(引用第三方jar)
    Postgresql VACUUM COPY等
    linux安装xgboost
    java社区推荐
    rabbitmq-java api
  • 原文地址:https://www.cnblogs.com/jackadam/p/8433199.html
Copyright © 2011-2022 走看看